📄 plotpropertyeditpanel.java
字号:
rangeAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
tabs.add(localizationResources.getString("Range_Axis"), rangeAxisPropertyPanel);
}
//dmo: added this panel for colorbar control. (start dmo additions)
ColorBar colorBar = null;
if (plot instanceof ContourPlot) {
colorBar = ((ContourPlot) plot).getColorBar();
}
colorBarAxisPropertyPanel = ColorBarPropertyEditPanel.getInstance(colorBar);
if (colorBarAxisPropertyPanel != null) {
colorBarAxisPropertyPanel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
tabs.add(localizationResources.getString("Color_Bar"), colorBarAxisPropertyPanel);
}
//dmo: (end dmo additions)
tabs.add(localizationResources.getString("Appearance"), appearance);
panel.add(tabs);
add(panel);
}
/**
* Returns the current plot insets.
* @return the current plot insets.
*/
public Insets getPlotInsets() {
if (plotInsets == null) {
plotInsets = new Insets(0, 0, 0, 0);
}
return plotInsets;
}
/**
* Returns the current background paint.
* @return the current background paint.
*/
public Paint getBackgroundPaint() {
return backgroundPaintSample.getPaint();
}
/**
* Returns the current outline stroke.
* @return the current outline stroke.
*/
public Stroke getOutlineStroke() {
return outlineStrokeSample.getStroke();
}
/**
* Returns the current outline paint.
* @return the current outline paint.
*/
public Paint getOutlinePaint() {
return outlinePaintSample.getPaint();
}
/**
* Returns a reference to the panel for editing the properties of the
* domain axis.
*
* @return a reference to a panel.
*/
public AxisPropertyEditPanel getDomainAxisPropertyEditPanel() {
return domainAxisPropertyPanel;
}
/**
* Returns a reference to the panel for editing the properties of the
* range axis.
*
* @return a reference to a panel.
*/
public AxisPropertyEditPanel getRangeAxisPropertyEditPanel() {
return rangeAxisPropertyPanel;
}
/**
* Handles user actions generated within the panel.
* @param event the event
*/
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("BackgroundPaint")) {
attemptBackgroundPaintSelection();
}
else if (command.equals("OutlineStroke")) {
attemptOutlineStrokeSelection();
}
else if (command.equals("OutlinePaint")) {
attemptOutlinePaintSelection();
}
else if (command.equals("Insets")) {
editInsets();
}
}
/**
* Allow the user to change the background paint.
*/
private void attemptBackgroundPaintSelection() {
Color c;
c = JColorChooser.showDialog(this, localizationResources.getString("Background_Color"),
Color.blue);
if (c != null) {
backgroundPaintSample.setPaint(c);
}
}
/**
* Allow the user to change the outline stroke.
*/
private void attemptOutlineStrokeSelection() {
StrokeChooserPanel panel = new StrokeChooserPanel(null, availableStrokeSamples);
int result = JOptionPane.showConfirmDialog(this, panel,
localizationResources.getString("Stroke_Selection"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
outlineStrokeSample.setStroke(panel.getSelectedStroke());
}
}
/**
* Allow the user to change the outline paint. We use JColorChooser, so
* the user can only choose colors (a subset of all possible paints).
*/
private void attemptOutlinePaintSelection() {
Color c;
c = JColorChooser.showDialog(this, localizationResources.getString("Outline_Color"),
Color.blue);
if (c != null) {
outlinePaintSample.setPaint(c);
}
}
/**
* Allow the user to edit the individual insets' values.
*/
private void editInsets() {
InsetsChooserPanel panel = new InsetsChooserPanel(plotInsets);
int result = JOptionPane.showConfirmDialog(this, panel,
localizationResources.getString("Edit_Insets"),
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
plotInsets = panel.getInsets();
insetsTextField.setInsets(plotInsets);
}
}
/**
* Updates the plot properties to match the properties defined on the panel.
*
* @param plot The plot.
*/
public void updatePlotProperties(Plot plot) {
// set the plot properties...
plot.setOutlinePaint(getOutlinePaint());
plot.setOutlineStroke(getOutlineStroke());
plot.setBackgroundPaint(getBackgroundPaint());
plot.setInsets(getPlotInsets());
// then the axis properties...
if (this.domainAxisPropertyPanel != null) {
Axis domainAxis = null;
if (plot instanceof CategoryPlot) {
CategoryPlot p = (CategoryPlot) plot;
domainAxis = p.getDomainAxis();
}
else if (plot instanceof XYPlot) {
XYPlot p = (XYPlot) plot;
domainAxis = p.getDomainAxis();
}
if (domainAxis != null) {
this.domainAxisPropertyPanel.setAxisProperties(domainAxis);
}
}
if (this.rangeAxisPropertyPanel != null) {
Axis rangeAxis = null;
if (plot instanceof CategoryPlot) {
CategoryPlot p = (CategoryPlot) plot;
rangeAxis = p.getRangeAxis();
}
else if (plot instanceof XYPlot) {
XYPlot p = (XYPlot) plot;
rangeAxis = p.getRangeAxis();
}
if (rangeAxis != null) {
this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis);
}
}
//dmo: added this panel for colorbar control. (start dmo additions)
if (this.colorBarAxisPropertyPanel != null) {
ColorBar colorBar = null;
if (plot instanceof ContourPlot) {
ContourPlot p = (ContourPlot) plot;
colorBar = p.getColorBar();
}
if (colorBar != null) {
this.colorBarAxisPropertyPanel.setAxisProperties(colorBar);
}
}
//dmo: (end dmo additions)
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -