Commit 6ff838c9 authored by legoc's avatar legoc
Browse files

Added length to the reference axis list

parent 9278736a
......@@ -4,6 +4,7 @@ import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.math.RoundingMode;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
......@@ -198,36 +199,17 @@ public class EditorMenuBar extends MenuBar {
}
}
private static final DecimalFormat df = new DecimalFormat("0.000");
public static class AxisTableEntry {
public static class BaseAxisTableEntry {
private final SimpleStringProperty axisName;
private final SimpleStringProperty componentName;
private final SimpleStringProperty type;
private final SimpleDoubleProperty currentValue;
private AxisTableEntry(String axisName, String componentName, String type, double value) {
private BaseAxisTableEntry(String axisName, String componentName) {
super();
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty(type);
this.currentValue = new SimpleDoubleProperty(value);
}
private AxisTableEntry(String axisName, String componentName, String type) {
super();
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty(type);
this.currentValue = new SimpleDoubleProperty(0);
}
private AxisTableEntry(String axisName, String componentName) {
super();
this.axisName = new SimpleStringProperty(axisName);
this.componentName = new SimpleStringProperty(componentName);
this.type = new SimpleStringProperty("");
this.currentValue = new SimpleDoubleProperty(0);
}
public String getAxisName() {
......@@ -238,6 +220,25 @@ public class EditorMenuBar extends MenuBar {
return componentName.get();
}
}
public static class AxisTableEntry extends BaseAxisTableEntry {
private final SimpleStringProperty type;
private final SimpleDoubleProperty currentValue;
private AxisTableEntry(String axisName, String componentName, String type, double value) {
super(axisName, componentName);
this.type = new SimpleStringProperty(type);
this.currentValue = new SimpleDoubleProperty(value);
}
private AxisTableEntry(String axisName, String componentName, String type) {
super(axisName, componentName);
this.type = new SimpleStringProperty(type);
this.currentValue = new SimpleDoubleProperty(0);
}
public String getType() {
return type.get();
}
......@@ -250,6 +251,20 @@ public class EditorMenuBar extends MenuBar {
currentValue.set(value);
}
}
public static class ReferenceAxisTableEntry extends BaseAxisTableEntry {
private final SimpleStringProperty length;
private ReferenceAxisTableEntry(String axisName, String componentName, String length) {
super(axisName, componentName);
this.length = new SimpleStringProperty(length);
}
public String getLength() {
return length.get();
}
}
/**
* A new Camera class to copy the original camera parameters into SimpleDoubleProperty type
......@@ -334,6 +349,7 @@ public class EditorMenuBar extends MenuBar {
this.activeConfiguration = null;
this.activeLod = 0;
this.subdividedChilds = new LinkedList<>();
df.setRoundingMode(RoundingMode.CEILING);
this.file = new Menu("File");
MenuItem openItem = new MenuItem("Open");
......@@ -2184,33 +2200,37 @@ public class EditorMenuBar extends MenuBar {
GridPane scenePane = new GridPane();
Scene displayScene = new Scene(scenePane);
Stage displayStage = new Stage(StageStyle.UTILITY);
displayStage.setWidth(600);
displayStage.setWidth(810);
displayStage.setTitle("Reference Axes");
displayStage.setScene(displayScene);
displayStage.initOwner(Nomad3DEditor.getInstance().getStage());
TableView<AxisTableEntry> tableView = new TableView();
TableView<ReferenceAxisTableEntry> tableView = new TableView();
tableView.setEditable(false);
TableColumn axisNameColumn = new TableColumn<>("Name");
axisNameColumn.setMinWidth(300);
axisNameColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("axisName"));
axisNameColumn.setCellValueFactory(new PropertyValueFactory<ReferenceAxisTableEntry, String>("axisName"));
TableColumn componentNameColumn = new TableColumn<>("Component Name");
componentNameColumn.setMinWidth(300);
componentNameColumn.setCellValueFactory(new PropertyValueFactory<AxisTableEntry, String>("componentName"));
componentNameColumn.setCellValueFactory(new PropertyValueFactory<ReferenceAxisTableEntry, String>("componentName"));
TableColumn lengthColumn = new TableColumn<>("Length");
lengthColumn.setMinWidth(200);
lengthColumn.setCellValueFactory(new PropertyValueFactory<ReferenceAxisTableEntry, String>("length"));
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<AxisTableEntry>() {
tableView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<ReferenceAxisTableEntry>() {
@Override
public void changed(ObservableValue<? extends AxisTableEntry> observable, AxisTableEntry oldValue,
AxisTableEntry newValue) {
public void changed(ObservableValue<? extends ReferenceAxisTableEntry> observable, ReferenceAxisTableEntry oldValue,
ReferenceAxisTableEntry newValue) {
referenceAxisDisplay.select(newValue.getAxisName(), newValue.getComponentName());
}
});
final ObservableList<AxisTableEntry> data = FXCollections.observableArrayList();
final ObservableList<ReferenceAxisTableEntry> data = FXCollections.observableArrayList();
List<ReferenceAxis> axes = ReferenceAxisList.getInstance().get();
for (ReferenceAxis axis : axes) {
......@@ -2218,14 +2238,14 @@ public class EditorMenuBar extends MenuBar {
Component owner = axis.getComponent();
if (owner != null) {
data.add(new AxisTableEntry(axis.getName(), owner.getName()));
data.add(new ReferenceAxisTableEntry(axis.getName(), owner.getName(), df.format(axis.getDirection().magnitude())));
} else {
data.add(new AxisTableEntry(axis.getName(), ""));
data.add(new ReferenceAxisTableEntry(axis.getName(), "", df.format(axis.getDirection().magnitude())));
}
}
tableView.setItems(data);
tableView.getColumns().addAll(axisNameColumn, componentNameColumn);
tableView.getColumns().addAll(axisNameColumn, componentNameColumn, lengthColumn);
scenePane.addRow(0, tableView);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment