nameVisibleCheckBox.setNullable(ev.getNewValue() == null);
nameVisibleCheckBox.setValue((Boolean)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.NAME_VISIBLE, nameVisibleChangeListener);
this.nameVisibleCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.NAME_VISIBLE, nameVisibleChangeListener);
controller.setNameVisible(nameVisibleCheckBox.getValue());
controller.addPropertyChangeListener(HomeFurnitureController.Property.NAME_VISIBLE, nameVisibleChangeListener);
}
});
// Create X label and its spinner bound to X controller property
this.xLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "xLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel xSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, -100000f, 100000f);
this.xSpinner = new NullableSpinner(xSpinnerModel);
xSpinnerModel.setNullable(controller.getX() == null);
xSpinnerModel.setLength(controller.getX());
final PropertyChangeListener xChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
xSpinnerModel.setNullable(ev.getNewValue() == null);
xSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.X, xChangeListener);
xSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.X, xChangeListener);
controller.setX(xSpinnerModel.getLength());
controller.addPropertyChangeListener(HomeFurnitureController.Property.X, xChangeListener);
}
});
// Create Y label and its spinner bound to Y controller property
this.yLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "yLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel ySpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, -100000f, 100000f);
this.ySpinner = new NullableSpinner(ySpinnerModel);
ySpinnerModel.setNullable(controller.getY() == null);
ySpinnerModel.setLength(controller.getY());
final PropertyChangeListener yChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
ySpinnerModel.setNullable(ev.getNewValue() == null);
ySpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.Y, yChangeListener);
ySpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.Y, yChangeListener);
controller.setY(ySpinnerModel.getLength());
controller.addPropertyChangeListener(HomeFurnitureController.Property.Y, yChangeListener);
}
});
// Create elevation label and its spinner bound to ELEVATION controller property
this.elevationLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "elevationLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel elevationSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, 0f, 2500f);
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);
elevationSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.ELEVATION,
elevationChangeListener);
elevationSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.ELEVATION,
elevationChangeListener);
controller.setElevation(elevationSpinnerModel.getLength());
controller.addPropertyChangeListener(HomeFurnitureController.Property.ELEVATION,
elevationChangeListener);
}
});
// Create angle label and its spinner bound to ANGLE_IN_DEGREES controller property
this.angleLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "angleLabel.text"));
final NullableSpinner.NullableSpinnerNumberModel angleSpinnerModel =
new NullableSpinner.NullableSpinnerNumberModel(0, 0, 360, 1);
this.angleSpinner = new NullableSpinner(angleSpinnerModel);
Integer angle = controller.getAngleInDegrees();
angleSpinnerModel.setNullable(angle == null);
angleSpinnerModel.setValue(angle);
final PropertyChangeListener angleChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
Float newAngle = (Float)ev.getNewValue();
angleSpinnerModel.setNullable(newAngle == null);
angleSpinnerModel.setValue(newAngle);
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.ANGLE_IN_DEGREES, angleChangeListener);
angleSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.ANGLE_IN_DEGREES, angleChangeListener);
Number value = (Number)angleSpinnerModel.getValue();
if (value == null) {
controller.setAngleInDegrees(null);
} else {
controller.setAngleInDegrees(value.intValue());
}
controller.addPropertyChangeListener(HomeFurnitureController.Property.ANGLE_IN_DEGREES, angleChangeListener);
}
});
// Create base plan item check box bound to BASE_PLAN_ITEM controller property
this.basePlanItemCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "basePlanItemCheckBox.text"));
String basePlanItemToolTip = preferences.getLocalizedString(
HomeFurniturePanel.class, "basePlanItemCheckBox.tooltip");
if (basePlanItemToolTip.length() > 0) {
this.basePlanItemCheckBox.setToolTipText(basePlanItemToolTip);
}
this.basePlanItemCheckBox.setNullable(controller.getBasePlanItem() == null);
this.basePlanItemCheckBox.setValue(controller.getBasePlanItem());
final PropertyChangeListener basePlanItemModelChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
basePlanItemCheckBox.setNullable(ev.getNewValue() == null);
basePlanItemCheckBox.setValue((Boolean)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.BASE_PLAN_ITEM, basePlanItemModelChangeListener);
this.basePlanItemCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.BASE_PLAN_ITEM, basePlanItemModelChangeListener);
controller.setBasePlanItem(basePlanItemCheckBox.getValue());
controller.addPropertyChangeListener(HomeFurnitureController.Property.BASE_PLAN_ITEM, basePlanItemModelChangeListener);
}
});
this.basePlanItemCheckBox.setEnabled(controller.isBasePlanItemEditable());
// Create width label and its spinner bound to WIDTH controller property
this.widthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "widthLabel.text", unitName));
final float minimumLength = preferences.getLengthUnit().getMinimumLength();
final NullableSpinner.NullableSpinnerLengthModel widthSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
this.widthSpinner = new NullableSpinner(widthSpinnerModel);
final PropertyChangeListener widthChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
Float width = controller.getWidth();
widthSpinnerModel.setNullable(width == null);
widthSpinnerModel.setLength(width);
if (width != null) {
widthSpinnerModel.setMinimum(Math.min(width, minimumLength));
}
}
};
widthChangeListener.propertyChange(null);
controller.addPropertyChangeListener(HomeFurnitureController.Property.WIDTH, widthChangeListener);
widthSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.WIDTH, widthChangeListener);
controller.setWidth(widthSpinnerModel.getLength());
controller.addPropertyChangeListener(HomeFurnitureController.Property.WIDTH, widthChangeListener);
}
});
// Create depth label and its spinner bound to DEPTH controller property
this.depthLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.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(HomeFurnitureController.Property.DEPTH, depthChangeListener);
depthSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.DEPTH, depthChangeListener);
controller.setDepth(depthSpinnerModel.getLength());
controller.addPropertyChangeListener(HomeFurnitureController.Property.DEPTH, depthChangeListener);
}
});
// Create height label and its spinner bound to HEIGHT controller property
this.heightLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.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(HomeFurnitureController.Property.HEIGHT, heightChangeListener);
heightSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.HEIGHT, heightChangeListener);
controller.setHeight(heightSpinnerModel.getLength());
controller.addPropertyChangeListener(HomeFurnitureController.Property.HEIGHT, heightChangeListener);
}
});
// Create keep proportions check box bound to PROPORTIONAL controller property
this.keepProportionsCheckBox = new JCheckBox(SwingTools.getLocalizedLabelText(preferences,
ImportedFurnitureWizardStepsPanel.class, "keepProportionsCheckBox.text"));
this.keepProportionsCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent ev) {
controller.setProportional(keepProportionsCheckBox.isSelected());
}
});
this.keepProportionsCheckBox.setSelected(controller.isProportional());
controller.addPropertyChangeListener(HomeFurnitureController.Property.PROPORTIONAL,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
// If proportional property changes update keep proportions check box
keepProportionsCheckBox.setSelected(controller.isProportional());
}
});
// Create mirror check box bound to MODEL_MIRRORED controller property
this.mirroredModelCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "mirroredModelCheckBox.text"));
String mirroredModelToolTip = preferences.getLocalizedString(
HomeFurniturePanel.class, "mirroredModelCheckBox.tooltip");
if (mirroredModelToolTip.length() > 0) {
this.mirroredModelCheckBox.setToolTipText(mirroredModelToolTip);
}
this.mirroredModelCheckBox.setNullable(controller.getModelMirrored() == null);
this.mirroredModelCheckBox.setValue(controller.getModelMirrored());
final PropertyChangeListener mirroredModelChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
mirroredModelCheckBox.setNullable(ev.getNewValue() == null);
mirroredModelCheckBox.setValue((Boolean)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.MODEL_MIRRORED, mirroredModelChangeListener);
this.mirroredModelCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.MODEL_MIRRORED, mirroredModelChangeListener);
controller.setModelMirrored(mirroredModelCheckBox.getValue());
controller.addPropertyChangeListener(HomeFurnitureController.Property.MODEL_MIRRORED, mirroredModelChangeListener);
}
});
// Create radio buttons bound to COLOR and TEXTURE controller properties
this.defaultColorAndTextureRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "defaultColorAndTextureRadioButton.text"));
this.defaultColorAndTextureRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (defaultColorAndTextureRadioButton.isSelected()) {
controller.setPaint(HomeFurnitureController.FurniturePaint.DEFAULT);
}
}
});
controller.addPropertyChangeListener(HomeFurnitureController.Property.PAINT,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateColorAndTextureRadioButtons(controller);
}
});
this.colorRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "colorRadioButton.text"));
this.colorRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (colorRadioButton.isSelected()) {
controller.setPaint(HomeFurnitureController.FurniturePaint.COLORED);
}
}
});
this.colorButton = new ColorButton();
this.colorButton.setColorDialogTitle(preferences.getLocalizedString(
HomeFurniturePanel.class, "colorDialog.title"));
this.colorButton.setColor(controller.getColor());
this.colorButton.addPropertyChangeListener(ColorButton.COLOR_PROPERTY,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
controller.setColor(colorButton.getColor());
controller.setPaint(HomeFurnitureController.FurniturePaint.COLORED);
}
});
controller.addPropertyChangeListener(HomeFurnitureController.Property.COLOR,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
colorButton.setColor(controller.getColor());
}
});
this.textureRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "textureRadioButton.text"));
this.textureRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (textureRadioButton.isSelected()) {
controller.setPaint(HomeFurnitureController.FurniturePaint.TEXTURED);
}
}
});
TextureChoiceController textureController = controller.getTextureController();
if (textureController != null) {
this.textureComponent = (JComponent)textureController.getView();
}
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(this.defaultColorAndTextureRadioButton);
buttonGroup.add(this.colorRadioButton);
buttonGroup.add(this.textureRadioButton);
updateColorAndTextureRadioButtons(controller);
// Create radio buttons bound to SHININESS controller properties
this.defaultShininessRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "defaultShininessRadioButton.text"));
this.defaultShininessRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (defaultShininessRadioButton.isSelected()) {
controller.setShininess(HomeFurnitureController.FurnitureShininess.DEFAULT);
}
}
});
controller.addPropertyChangeListener(HomeFurnitureController.Property.SHININESS,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateShininessRadioButtons(controller);
}
});
this.mattRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "mattRadioButton.text"));
this.mattRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (mattRadioButton.isSelected()) {
controller.setShininess(HomeFurnitureController.FurnitureShininess.MATT);
}
}
});
this.shinyRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "shinyRadioButton.text"));
this.shinyRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (shinyRadioButton.isSelected()) {
controller.setShininess(HomeFurnitureController.FurnitureShininess.SHINY);
}
}
});
buttonGroup = new ButtonGroup();
buttonGroup.add(this.defaultShininessRadioButton);
buttonGroup.add(this.mattRadioButton);
buttonGroup.add(this.shinyRadioButton);
updateShininessRadioButtons(controller);
// Create visible check box bound to VISIBLE controller property
this.visibleCheckBox = new NullableCheckBox(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "visibleCheckBox.text"));
this.visibleCheckBox.setNullable(controller.getVisible() == null);
this.visibleCheckBox.setValue(controller.getVisible());
final PropertyChangeListener visibleChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
visibleCheckBox.setNullable(ev.getNewValue() == null);
visibleCheckBox.setValue((Boolean)ev.getNewValue());
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.VISIBLE, visibleChangeListener);
this.visibleCheckBox.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.VISIBLE, visibleChangeListener);
controller.setVisible(visibleCheckBox.getValue());
controller.addPropertyChangeListener(HomeFurnitureController.Property.VISIBLE, visibleChangeListener);
}
});
// Create power label and its spinner bound to POWER controller property
if (controller.isLightPowerEditable()) {
this.lightPowerLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
HomeFurniturePanel.class, "lightPowerLabel.text", unitName));
final NullableSpinner.NullableSpinnerNumberModel lightPowerSpinnerModel =
new NullableSpinner.NullableSpinnerNumberModel(0, 0, 100, 5);
this.lightPowerSpinner = new NullableSpinner(lightPowerSpinnerModel);
lightPowerSpinnerModel.setNullable(controller.getLightPower() == null);
lightPowerSpinnerModel.setValue(controller.getLightPower() != null ? Math.round(controller.getLightPower() * 100) : null);
final PropertyChangeListener lightPowerChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
Float lightPower = (Float)ev.getNewValue();
lightPowerSpinnerModel.setNullable(lightPower == null);
lightPowerSpinnerModel.setValue(lightPower != null ? Math.round((Float)ev.getNewValue() * 100) : null);
}
};
controller.addPropertyChangeListener(HomeFurnitureController.Property.LIGHT_POWER, lightPowerChangeListener);
lightPowerSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(HomeFurnitureController.Property.LIGHT_POWER, lightPowerChangeListener);
controller.setLightPower(((Number)lightPowerSpinnerModel.getValue()).floatValue() / 100f);
controller.addPropertyChangeListener(HomeFurnitureController.Property.LIGHT_POWER, lightPowerChangeListener);
}