// Create depth label and its spinner bound to DEPTH controller property
this.depthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "depthLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel depthSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
this.depthSpinner = new NullableSpinner(depthSpinnerModel);
final PropertyChangeListener depthChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
Float depth = controller.getDepth();
depthSpinnerModel.setNullable(depth == null);
depthSpinnerModel.setLength(depth);
if (depth != null) {
depthSpinnerModel.setMinimum(Math.min(depth, minimumLength));
}
}
};
depthChangeListener.propertyChange(null);
controller.addPropertyChangeListener(FurnitureController.Property.DEPTH, depthChangeListener);
depthSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.DEPTH, depthChangeListener);
controller.setDepth(depthSpinnerModel.getLength());
if (!controller.isProportional()) {
resetIcon(false);
}
controller.addPropertyChangeListener(FurnitureController.Property.DEPTH, depthChangeListener);
}
});
// Create height label and its spinner bound to HEIGHT controller property
this.heightLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "heightLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel heightSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
this.heightSpinner = new NullableSpinner(heightSpinnerModel);
final PropertyChangeListener heightChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
Float height = controller.getHeight();
heightSpinnerModel.setNullable(height == null);
heightSpinnerModel.setLength(height);
if (height != null) {
heightSpinnerModel.setMinimum(Math.min(height, minimumLength));
}
}
};
heightChangeListener.propertyChange(null);
controller.addPropertyChangeListener(FurnitureController.Property.HEIGHT, heightChangeListener);
heightSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(FurnitureController.Property.HEIGHT, heightChangeListener);
controller.setHeight(heightSpinnerModel.getLength());
if (!controller.isProportional()) {
resetIcon(false);
}
controller.addPropertyChangeListener(FurnitureController.Property.HEIGHT, heightChangeListener);
}
});
this.keepProportionsCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "keepProportionsCheckBox.text"), controller.isProportional());
this.keepProportionsCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
controller.setProportional(keepProportionsCheckBox.isSelected());
}
});
controller.addPropertyChangeListener(FurnitureController.Property.PROPORTIONAL,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
// If proportional property changes update keep proportions check box
keepProportionsCheckBox.setSelected(controller.isProportional());
}
});
// Create elevation label and its spinner bound to ELEVATION controller property
this.elevationLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
FurniturePanel.class, "elevationLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel elevationSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, 0f, 1000f);
this.elevationSpinner = new NullableSpinner(elevationSpinnerModel);
elevationSpinnerModel.setNullable(controller.getElevation() == null);
elevationSpinnerModel.setLength(controller.getElevation());
final PropertyChangeListener elevationChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
elevationSpinnerModel.setNullable(ev.getNewValue() == null);