Commit c4aab8a7 authored by legoc's avatar legoc
Browse files

Hiding zero value reference boxes and labels depending on the type of axis

parent 3e2acac2
......@@ -261,6 +261,10 @@ public class EditorMenuBar extends MenuBar {
Label yPosField = new Label("-");
Label zPosField = new Label("-");
// List of reference axes.
ObservableList<String> references = FXCollections.observableArrayList("");
references.addAll(ReferenceAxisList.getInstance().getNames());
///////////////////////////////////////////////////////////////////////////////////////
// Controller
......@@ -314,6 +318,55 @@ public class EditorMenuBar extends MenuBar {
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference for first zero value
Label zeroValueReference1Label = new Label("Zero Value Reference 1 : ");
ComboBox<String> zeroValueReference1Box = new ComboBox<>(references);
zeroValueReference1Label.setVisible(selectedAxis.getType() == Axis.Type.ROTATION || selectedAxis.getType() == Axis.Type.TRANSLATION);
zeroValueReference1Box.setVisible(selectedAxis.getType() == Axis.Type.ROTATION || selectedAxis.getType() == Axis.Type.TRANSLATION);
// Select the reference axis.
if (selectedAxis.getZeroValueReferenceAxis1() != null) {
zeroValueReference1Box.getSelectionModel().select(selectedAxis.getZeroValueReferenceAxis1().getName());
}
zeroValueReference1Box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the selected axis with the reference.
selectedAxis.setZeroValueReferenceAxis1(referenceAxis);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference for second zero value
Label zeroValueReference2Label = new Label("Zero Value Reference 2 : ");
ComboBox<String> zeroValueReference2Box = new ComboBox<>(references);
zeroValueReference2Label.setVisible(selectedAxis.getType() == Axis.Type.ROTATION);
zeroValueReference2Box.setVisible(selectedAxis.getType() == Axis.Type.ROTATION);
// Select the reference axis.
if (selectedAxis.getZeroValueReferenceAxis2() != null) {
zeroValueReference2Box.getSelectionModel().select(selectedAxis.getZeroValueReferenceAxis2().getName());
}
zeroValueReference2Box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the selected axis with the reference.
selectedAxis.setZeroValueReferenceAxis2(referenceAxis);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Type
Label typeLabel = new Label("Type : ");
......@@ -330,15 +383,19 @@ public class EditorMenuBar extends MenuBar {
// Change the visibility of the rotation direction box.
rotationDirectionBox.setVisible(newValue == Axis.Type.ROTATION);
// Change the visibility of the zero value reference boxes and labels.
zeroValueReference1Label.setVisible(newValue == Axis.Type.ROTATION || newValue == Axis.Type.TRANSLATION);
zeroValueReference1Box.setVisible(newValue == Axis.Type.ROTATION || newValue == Axis.Type.TRANSLATION);
zeroValueReference2Label.setVisible(newValue == Axis.Type.ROTATION);
zeroValueReference2Box.setVisible(newValue == Axis.Type.ROTATION);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference
Label referenceLabel = new Label("Reference : ");
ObservableList<String> references = FXCollections.observableArrayList("");
references.addAll(ReferenceAxisList.getInstance().getNames());
ComboBox<String> referenceBox = new ComboBox<>(references);
if (selectedAxis.getReferenceAxis() != null) {
......@@ -474,50 +531,7 @@ public class EditorMenuBar extends MenuBar {
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference for first zero value
Label zeroValueReference1Label = new Label("Zero Value Reference 1 : ");
ComboBox<String> zeroValueReference1Box = new ComboBox<>(references);
// Select the reference axis.
if (selectedAxis.getZeroValueReferenceAxis1() != null) {
zeroValueReference1Box.getSelectionModel().select(selectedAxis.getZeroValueReferenceAxis1().getName());
}
zeroValueReference1Box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the selected axis with the reference.
selectedAxis.setZeroValueReferenceAxis1(referenceAxis);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// Reference for second zero value
Label zeroValueReference2Label = new Label("Zero Value Reference 2 : ");
ComboBox<String> zeroValueReference2Box = new ComboBox<>(references);
// Select the reference axis.
if (selectedAxis.getZeroValueReferenceAxis2() != null) {
zeroValueReference2Box.getSelectionModel().select(selectedAxis.getZeroValueReferenceAxis2().getName());
}
zeroValueReference2Box.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
// Get the reference axis.
ReferenceAxis referenceAxis = ReferenceAxisList.getInstance().getAxis(newValue);
// Set the selected axis with the reference.
selectedAxis.setZeroValueReferenceAxis2(referenceAxis);
}
});
///////////////////////////////////////////////////////////////////////////////////////
// OK and Cancel
......
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