public PlotPropertyEditPanel(Plot plot) {
this.plotInsets = plot.getInsets();
this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint());
this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke());
this.outlinePaintSample = new PaintSample(plot.getOutlinePaint());
if (plot instanceof CategoryPlot) {
this.plotOrientation = ((CategoryPlot) plot).getOrientation();
}
else if (plot instanceof XYPlot) {
this.plotOrientation = ((XYPlot) plot).getOrientation();
}
if (plot instanceof CategoryPlot) {
CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer();
if (renderer instanceof LineAndShapeRenderer) {
LineAndShapeRenderer r = (LineAndShapeRenderer) renderer;
this.drawLines = BooleanUtilities.valueOf(r.isLinesVisible());
this.drawShapes = BooleanUtilities.valueOf(r.isShapesVisible());
}
}
else if (plot instanceof XYPlot) {
XYItemRenderer renderer = ((XYPlot) plot).getRenderer();
if (renderer instanceof StandardXYItemRenderer) {
StandardXYItemRenderer r = (StandardXYItemRenderer) renderer;
this.drawLines = BooleanUtilities.valueOf(r.getPlotLines());
this.drawShapes = BooleanUtilities.valueOf(r.getPlotShapes());
}
}
setLayout(new BorderLayout());
this.availableStrokeSamples = new StrokeSample[3];
this.availableStrokeSamples[0]
= new StrokeSample(new BasicStroke(1.0f));
this.availableStrokeSamples[1]
= new StrokeSample(new BasicStroke(2.0f));
this.availableStrokeSamples[2]
= new StrokeSample(new BasicStroke(3.0f));
// create a panel for the settings...
JPanel panel = new JPanel(new BorderLayout());
panel.setBorder(
BorderFactory.createTitledBorder(
BorderFactory.createEtchedBorder(),
plot.getPlotType() + localizationResources.getString(":")
)
);
JPanel general = new JPanel(new BorderLayout());
general.setBorder(
BorderFactory.createTitledBorder(
localizationResources.getString("General")
)
);
JPanel interior = new JPanel(new LCBLayout(7));
interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
// interior.add(new JLabel(localizationResources.getString("Insets")));
// JButton button = new JButton(
// localizationResources.getString("Edit...")
// );
// button.setActionCommand("Insets");
// button.addActionListener(this);
//
// this.insetsTextField = new InsetsTextField(this.plotInsets);
// this.insetsTextField.setEnabled(false);
// interior.add(this.insetsTextField);
// interior.add(button);
interior.add(
new JLabel(localizationResources.getString("Outline_stroke"))
);
JButton button = new JButton(localizationResources.getString("Select..."));
button.setActionCommand("OutlineStroke");
button.addActionListener(this);
interior.add(this.outlineStrokeSample);
interior.add(button);
interior.add(
new JLabel(localizationResources.getString("Outline_Paint"))
);
button = new JButton(localizationResources.getString("Select..."));
button.setActionCommand("OutlinePaint");
button.addActionListener(this);
interior.add(this.outlinePaintSample);
interior.add(button);
interior.add(
new JLabel(localizationResources.getString("Background_paint"))
);
button = new JButton(localizationResources.getString("Select..."));
button.setActionCommand("BackgroundPaint");
button.addActionListener(this);
interior.add(this.backgroundPaintSample);
interior.add(button);
if (this.plotOrientation != null) {
boolean isVertical
= this.plotOrientation.equals(PlotOrientation.VERTICAL);
int index
= isVertical ? ORIENTATION_VERTICAL : ORIENTATION_HORIZONTAL;
interior.add(
new JLabel(localizationResources.getString("Orientation"))
);
this.orientationCombo = new JComboBox(orientationNames);
this.orientationCombo.setSelectedIndex(index);
this.orientationCombo.setActionCommand("Orientation");
this.orientationCombo.addActionListener(this);
interior.add(new JPanel());
interior.add(this.orientationCombo);
}
if (this.drawLines != null) {
interior.add(
new JLabel(localizationResources.getString("Draw_lines"))
);
this.drawLinesCheckBox = new JCheckBox();
this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue());
this.drawLinesCheckBox.setActionCommand("DrawLines");
this.drawLinesCheckBox.addActionListener(this);
interior.add(new JPanel());
interior.add(this.drawLinesCheckBox);
}
if (this.drawShapes != null) {
interior.add(
new JLabel(localizationResources.getString("Draw_shapes"))
);
this.drawShapesCheckBox = new JCheckBox();
this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue());
this.drawShapesCheckBox.setActionCommand("DrawShapes");
this.drawShapesCheckBox.addActionListener(this);
interior.add(new JPanel());
interior.add(this.drawShapesCheckBox);
}
general.add(interior, BorderLayout.NORTH);
JPanel appearance = new JPanel(new BorderLayout());
appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
appearance.add(general, BorderLayout.NORTH);
JTabbedPane tabs = new JTabbedPane();
tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
Axis domainAxis = null;
if (plot instanceof CategoryPlot) {
domainAxis = ((CategoryPlot) plot).getDomainAxis();
}
else if (plot instanceof XYPlot) {
domainAxis = ((XYPlot) plot).getDomainAxis();
}
this.domainAxisPropertyPanel
= AxisPropertyEditPanel.getInstance(domainAxis);
if (this.domainAxisPropertyPanel != null) {
this.domainAxisPropertyPanel.setBorder(
BorderFactory.createEmptyBorder(2, 2, 2, 2)
);
tabs.add(
localizationResources.getString("Domain_Axis"),
this.domainAxisPropertyPanel
);
}
Axis rangeAxis = null;
if (plot instanceof CategoryPlot) {
rangeAxis = ((CategoryPlot) plot).getRangeAxis();
}
else if (plot instanceof XYPlot) {
rangeAxis = ((XYPlot) plot).getRangeAxis();
}
this.rangeAxisPropertyPanel
= AxisPropertyEditPanel.getInstance(rangeAxis);
if (this.rangeAxisPropertyPanel != null) {
this.rangeAxisPropertyPanel.setBorder(
BorderFactory.createEmptyBorder(2, 2, 2, 2)
);
tabs.add(
localizationResources.getString("Range_Axis"),
this.rangeAxisPropertyPanel
);
}
//dmo: added this panel for colorbar control. (start dmo additions)
ColorBar colorBar = null;
if (plot instanceof ContourPlot) {
colorBar = ((ContourPlot) plot).getColorBar();
}
this.colorBarAxisPropertyPanel
= ColorBarPropertyEditPanel.getInstance(colorBar);
if (this.colorBarAxisPropertyPanel != null) {
this.colorBarAxisPropertyPanel.setBorder(
BorderFactory.createEmptyBorder(2, 2, 2, 2)
);
tabs.add(
localizationResources.getString("Color_Bar"),
this.colorBarAxisPropertyPanel
);
}
//dmo: (end dmo additions)
tabs.add(localizationResources.getString("Appearance"), appearance);
panel.add(tabs);
add(panel);
}
Standard constructor - constructs a panel for editing the properties of
the specified plot.
In designing the panel, we need to be aware that subclasses of Plot will
need to implement subclasses of PlotPropertyEditPanel - so we need to
leave one or two 'slots' where the subclasses can extend the user
interface. Parameters:
plot - the plot, which should be changed.
|