xStartSpinnerModel.setNullable(ev.getNewValue() == null);
xStartSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.X_START, xStartChangeListener);
xStartSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.X_START, xStartChangeListener);
controller.setXStart(xStartSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.X_START, xStartChangeListener);
}
});
// Create Y start label and its spinner bound to Y_START controller property
this.yStartLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "yLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel yStartSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, -100000f, 100000f);
this.yStartSpinner = new NullableSpinner(yStartSpinnerModel);
yStartSpinnerModel.setNullable(controller.getYStart() == null);
yStartSpinnerModel.setLength(controller.getYStart());
final PropertyChangeListener yStartChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
yStartSpinnerModel.setNullable(ev.getNewValue() == null);
yStartSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.Y_START, yStartChangeListener);
yStartSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.Y_START, yStartChangeListener);
controller.setYStart(yStartSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.Y_START, yStartChangeListener);
}
});
// Create X end label and its spinner bound to X_END controller property
this.xEndLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "xLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel xEndSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, -100000f, 100000f);
this.xEndSpinner = new NullableSpinner(xEndSpinnerModel);
xEndSpinnerModel.setNullable(controller.getXEnd() == null);
xEndSpinnerModel.setLength(controller.getXEnd());
final PropertyChangeListener xEndChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
xEndSpinnerModel.setNullable(ev.getNewValue() == null);
xEndSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.X_END, xEndChangeListener);
xEndSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.X_END, xEndChangeListener);
controller.setXEnd(xEndSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.X_END, xEndChangeListener);
}
});
// Create Y end label and its spinner bound to Y_END controller property
this.yEndLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "yLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel yEndSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, -100000f, 100000f);
this.yEndSpinner = new NullableSpinner(yEndSpinnerModel);
yEndSpinnerModel.setNullable(controller.getYEnd() == null);
yEndSpinnerModel.setLength(controller.getYEnd());
final PropertyChangeListener yEndChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
yEndSpinnerModel.setNullable(ev.getNewValue() == null);
yEndSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.Y_END, yEndChangeListener);
yEndSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.Y_END, yEndChangeListener);
controller.setYEnd(yEndSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.Y_END, yEndChangeListener);
}
});
// Create distance to end point label and its spinner bound to DISTANCE_TO_END_POINT controller property
this.distanceToEndPointLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "distanceToEndPointLabel.text", unitName));
float minimumLength = preferences.getLengthUnit().getMinimumLength();
final NullableSpinner.NullableSpinnerLengthModel distanceToEndPointSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 100000f);
this.distanceToEndPointSpinner = new NullableSpinner(distanceToEndPointSpinnerModel);
distanceToEndPointSpinnerModel.setNullable(controller.getLength() == null);
distanceToEndPointSpinnerModel.setLength(controller.getLength());
final PropertyChangeListener distanceToEndPointChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
distanceToEndPointSpinnerModel.setNullable(ev.getNewValue() == null);
distanceToEndPointSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.DISTANCE_TO_END_POINT,
distanceToEndPointChangeListener);
distanceToEndPointSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.DISTANCE_TO_END_POINT,
distanceToEndPointChangeListener);
controller.setLength(distanceToEndPointSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.DISTANCE_TO_END_POINT,
distanceToEndPointChangeListener);
}
});
// Left side color and texture buttons bound to left side controller properties
this.leftSideColorRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "leftSideColorRadioButton.text"));
this.leftSideColorRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (leftSideColorRadioButton.isSelected()) {
controller.setLeftSidePaint(WallController.WallPaint.COLORED);
}
}
});
controller.addPropertyChangeListener(WallController.Property.LEFT_SIDE_PAINT,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateLeftSideColorRadioButtons(controller);
}
});
this.leftSideColorButton = new ColorButton();
this.leftSideColorButton.setColorDialogTitle(preferences.getLocalizedString(
WallPanel.class, "leftSideColorDialog.title"));
this.leftSideColorButton.setColor(controller.getLeftSideColor());
this.leftSideColorButton.addPropertyChangeListener(ColorButton.COLOR_PROPERTY,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
controller.setLeftSideColor(leftSideColorButton.getColor());
controller.setLeftSidePaint(WallController.WallPaint.COLORED);
}
});
controller.addPropertyChangeListener(WallController.Property.LEFT_SIDE_COLOR,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
leftSideColorButton.setColor(controller.getLeftSideColor());
}
});
this.leftSideTextureRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "leftSideTextureRadioButton.text"));
this.leftSideTextureRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (leftSideTextureRadioButton.isSelected()) {
controller.setLeftSidePaint(WallController.WallPaint.TEXTURED);
}
}
});
this.leftSideTextureComponent = (JComponent)controller.getLeftSideTextureController().getView();
ButtonGroup leftSideColorButtonGroup = new ButtonGroup();
leftSideColorButtonGroup.add(this.leftSideColorRadioButton);
leftSideColorButtonGroup.add(this.leftSideTextureRadioButton);
updateLeftSideColorRadioButtons(controller);
// Left side shininess radio buttons bound to LEFT_SIDE_SHININESS controller property
this.leftSideMattRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "leftSideMattRadioButton.text"));
this.leftSideMattRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (leftSideMattRadioButton.isSelected()) {
controller.setLeftSideShininess(0f);
}
}
});
PropertyChangeListener leftSideShininessListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateLeftSideShininessRadioButtons(controller);
}
};
controller.addPropertyChangeListener(WallController.Property.LEFT_SIDE_SHININESS,
leftSideShininessListener);
this.leftSideShinyRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "leftSideShinyRadioButton.text"));
this.leftSideShinyRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (leftSideShinyRadioButton.isSelected()) {
controller.setLeftSideShininess(0.25f);
}
}
});
controller.addPropertyChangeListener(WallController.Property.LEFT_SIDE_SHININESS,
leftSideShininessListener);
ButtonGroup leftSideShininessButtonGroup = new ButtonGroup();
leftSideShininessButtonGroup.add(this.leftSideMattRadioButton);
leftSideShininessButtonGroup.add(this.leftSideShinyRadioButton);
updateLeftSideShininessRadioButtons(controller);
// Right side color and texture buttons bound to right side controller properties
this.rightSideColorRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "rightSideColorRadioButton.text"));
this.rightSideColorRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (rightSideColorRadioButton.isSelected()) {
controller.setRightSidePaint(WallController.WallPaint.COLORED);
}
}
});
controller.addPropertyChangeListener(WallController.Property.RIGHT_SIDE_PAINT,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateRightSideColorRadioButtons(controller);
}
});
this.rightSideColorButton = new ColorButton();
this.rightSideColorButton.setColor(controller.getRightSideColor());
this.rightSideColorButton.setColorDialogTitle(preferences.getLocalizedString(
WallPanel.class, "rightSideColorDialog.title"));
this.rightSideColorButton.addPropertyChangeListener(ColorButton.COLOR_PROPERTY,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
controller.setRightSideColor(rightSideColorButton.getColor());
controller.setRightSidePaint(WallController.WallPaint.COLORED);
}
});
controller.addPropertyChangeListener(WallController.Property.RIGHT_SIDE_COLOR,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
rightSideColorButton.setColor(controller.getRightSideColor());
}
});
this.rightSideTextureRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "rightSideTextureRadioButton.text"));
this.rightSideTextureRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (rightSideTextureRadioButton.isSelected()) {
controller.setRightSidePaint(WallController.WallPaint.TEXTURED);
}
}
});
this.rightSideTextureComponent = (JComponent)controller.getRightSideTextureController().getView();
ButtonGroup rightSideColorButtonGroup = new ButtonGroup();
rightSideColorButtonGroup.add(this.rightSideColorRadioButton);
rightSideColorButtonGroup.add(this.rightSideTextureRadioButton);
updateRightSideColorRadioButtons(controller);
// Right side shininess radio buttons bound to LEFT_SIDE_SHININESS controller property
this.rightSideMattRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "rightSideMattRadioButton.text"));
this.rightSideMattRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (rightSideMattRadioButton.isSelected()) {
controller.setRightSideShininess(0f);
}
}
});
PropertyChangeListener rightSideShininessListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateRightSideShininessRadioButtons(controller);
}
};
controller.addPropertyChangeListener(WallController.Property.RIGHT_SIDE_SHININESS,
rightSideShininessListener);
this.rightSideShinyRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "rightSideShinyRadioButton.text"));
this.rightSideShinyRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (rightSideShinyRadioButton.isSelected()) {
controller.setRightSideShininess(0.25f);
}
}
});
controller.addPropertyChangeListener(WallController.Property.RIGHT_SIDE_SHININESS,
rightSideShininessListener);
ButtonGroup rightSideShininessButtonGroup = new ButtonGroup();
rightSideShininessButtonGroup.add(this.rightSideMattRadioButton);
rightSideShininessButtonGroup.add(this.rightSideShinyRadioButton);
updateRightSideShininessRadioButtons(controller);
this.rectangularWallRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "rectangularWallRadioButton.text"));
this.rectangularWallRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (rectangularWallRadioButton.isSelected()) {
controller.setShape(WallController.WallShape.RECTANGULAR_WALL);
}
}
});
controller.addPropertyChangeListener(WallController.Property.SHAPE,
new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
updateWallShapeRadioButtons(controller);
}
});
// Create height label and its spinner bound to RECTANGULAR_WALL_HEIGHT controller property
this.rectangularWallHeightLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "rectangularWallHeightLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel rectangularWallHeightSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 10000f);
this.rectangularWallHeightSpinner = new NullableSpinner(rectangularWallHeightSpinnerModel);
rectangularWallHeightSpinnerModel.setNullable(controller.getRectangularWallHeight() == null);
rectangularWallHeightSpinnerModel.setLength(controller.getRectangularWallHeight());
final PropertyChangeListener rectangularWallHeightChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
rectangularWallHeightSpinnerModel.setNullable(ev.getNewValue() == null);
rectangularWallHeightSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.RECTANGULAR_WALL_HEIGHT,
rectangularWallHeightChangeListener);
rectangularWallHeightSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.RECTANGULAR_WALL_HEIGHT,
rectangularWallHeightChangeListener);
controller.setRectangularWallHeight(rectangularWallHeightSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.RECTANGULAR_WALL_HEIGHT,
rectangularWallHeightChangeListener);
}
});
this.slopingWallRadioButton = new JRadioButton(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "slopingWallRadioButton.text"));
this.slopingWallRadioButton.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
if (slopingWallRadioButton.isSelected()) {
controller.setShape(WallController.WallShape.SLOPING_WALL);
}
}
});
ButtonGroup wallHeightButtonGroup = new ButtonGroup();
wallHeightButtonGroup.add(this.rectangularWallRadioButton);
wallHeightButtonGroup.add(this.slopingWallRadioButton);
updateWallShapeRadioButtons(controller);
// Create height at start label and its spinner bound to SLOPING_WALL_HEIGHT_AT_START controller property
this.slopingWallHeightAtStartLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "slopingWallHeightAtStartLabel.text"));
final NullableSpinner.NullableSpinnerLengthModel slopingWallHeightAtStartSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 10000f);
this.slopingWallHeightAtStartSpinner = new NullableSpinner(slopingWallHeightAtStartSpinnerModel);
slopingWallHeightAtStartSpinnerModel.setNullable(controller.getSlopingWallHeightAtStart() == null);
slopingWallHeightAtStartSpinnerModel.setLength(controller.getSlopingWallHeightAtStart());
final PropertyChangeListener slopingWallHeightAtStartChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
slopingWallHeightAtStartSpinnerModel.setNullable(ev.getNewValue() == null);
slopingWallHeightAtStartSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.SLOPING_WALL_HEIGHT_AT_START,
slopingWallHeightAtStartChangeListener);
slopingWallHeightAtStartSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.SLOPING_WALL_HEIGHT_AT_START,
slopingWallHeightAtStartChangeListener);
controller.setSlopingWallHeightAtStart(slopingWallHeightAtStartSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.SLOPING_WALL_HEIGHT_AT_START,
slopingWallHeightAtStartChangeListener);
}
});
// Create height at end label and its spinner bound to SLOPING_WALL_HEIGHT_AT_END controller property
this.slopingWallHeightAtEndLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "slopingWallHeightAtEndLabel.text"));
final NullableSpinner.NullableSpinnerLengthModel slopingWallHeightAtEndSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 10000f);
this.slopingWallHeightAtEndSpinner = new NullableSpinner(slopingWallHeightAtEndSpinnerModel);
slopingWallHeightAtEndSpinnerModel.setNullable(controller.getSlopingWallHeightAtEnd() == null);
slopingWallHeightAtEndSpinnerModel.setLength(controller.getSlopingWallHeightAtEnd());
final PropertyChangeListener slopingWallHeightAtEndChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
slopingWallHeightAtEndSpinnerModel.setNullable(ev.getNewValue() == null);
slopingWallHeightAtEndSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.SLOPING_WALL_HEIGHT_AT_END,
slopingWallHeightAtEndChangeListener);
slopingWallHeightAtEndSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.SLOPING_WALL_HEIGHT_AT_END,
slopingWallHeightAtEndChangeListener);
controller.setSlopingWallHeightAtEnd(slopingWallHeightAtEndSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.SLOPING_WALL_HEIGHT_AT_END,
slopingWallHeightAtEndChangeListener);
}
});
// Create thickness label and its spinner bound to THICKNESS controller property
this.thicknessLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "thicknessLabel.text", unitName));
final NullableSpinner.NullableSpinnerLengthModel thicknessSpinnerModel =
new NullableSpinner.NullableSpinnerLengthModel(preferences, minimumLength, 10000f);
this.thicknessSpinner = new NullableSpinner(thicknessSpinnerModel);
thicknessSpinnerModel.setNullable(controller.getThickness() == null);
thicknessSpinnerModel.setLength(controller.getThickness());
final PropertyChangeListener thicknessChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
thicknessSpinnerModel.setNullable(ev.getNewValue() == null);
thicknessSpinnerModel.setLength((Float)ev.getNewValue());
}
};
controller.addPropertyChangeListener(WallController.Property.THICKNESS,
thicknessChangeListener);
thicknessSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.THICKNESS,
thicknessChangeListener);
controller.setThickness(thicknessSpinnerModel.getLength());
controller.addPropertyChangeListener(WallController.Property.THICKNESS,
thicknessChangeListener);
}
});
// Create arc extent label and its spinner bound to ARC_EXTENT_IN_DEGREES controller property
this.arcExtentLabel = new JLabel(SwingTools.getLocalizedLabelText(preferences,
WallPanel.class, "arcExtentLabel.text", unitName));
final NullableSpinner.NullableSpinnerNumberModel arcExtentSpinnerModel =
new NullableSpinner.NullableSpinnerNumberModel(new Float(0), new Float(-270), new Float(270), new Float(5));
this.arcExtentSpinner = new NullableSpinner(arcExtentSpinnerModel);
arcExtentSpinnerModel.setNullable(controller.getArcExtentInDegrees() == null);
arcExtentSpinnerModel.setValue(controller.getArcExtentInDegrees());
final PropertyChangeListener arcExtentChangeListener = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent ev) {
arcExtentSpinnerModel.setNullable(ev.getNewValue() == null);
arcExtentSpinnerModel.setValue(((Number)ev.getNewValue()).floatValue());
}
};
controller.addPropertyChangeListener(WallController.Property.ARC_EXTENT_IN_DEGREES,
arcExtentChangeListener);
arcExtentSpinnerModel.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent ev) {
controller.removePropertyChangeListener(WallController.Property.ARC_EXTENT_IN_DEGREES,
arcExtentChangeListener);
controller.setArcExtentInDegrees(((Number)arcExtentSpinnerModel.getValue()).floatValue());
controller.addPropertyChangeListener(WallController.Property.ARC_EXTENT_IN_DEGREES,