?? axispropertyeditpanel.java
字號:
ticks.add(tickLabelFontField);
b = new JButton(localizationResources.getString("Select..."));
b.setActionCommand("SelectTickLabelFont");
b.addActionListener(this);
ticks.add(b);
showTickMarksCheckBox = new JCheckBox(localizationResources.getString("Show_tick_marks"),
axis.isTickMarksVisible());
ticks.add(showTickMarksCheckBox);
ticks.add(new JPanel());
ticks.add(new JPanel());
otherTabs.add(localizationResources.getString("Ticks"), ticks);
other.add(otherTabs);
slot1.add(other);
slot2 = new JPanel(new BorderLayout());
slot2.add(slot1, BorderLayout.NORTH);
add(slot2);
}
/**
* Returns the current axis label.
*
* @return the current axis label.
*/
public String getLabel() {
return label.getText();
}
/**
* Returns the current label font.
*
* @return the current label font.
*/
public Font getLabelFont() {
return labelFont;
}
/**
* Returns the current label paint.
*
* @return the current label paint.
*/
public Paint getLabelPaint() {
return labelPaintSample.getPaint();
}
/**
* Returns a flag that indicates whether or not the tick labels are visible.
*
* @return <code>true</code> if ick mark labels are visible.
*/
public boolean isTickLabelsVisible() {
return showTickLabelsCheckBox.isSelected();
}
/**
* Returns the font used to draw the tick labels (if they are showing).
*
* @return the font used to draw the tick labels.
*/
public Font getTickLabelFont() {
return tickLabelFont;
}
/**
* Returns the current tick label paint.
*
* @return the current tick label paint.
*/
public Paint getTickLabelPaint() {
return tickLabelPaintSample.getPaint();
}
/**
* Returns the current value of the flag that determines whether or not
* tick marks are visible.
*
* @return <code>true</code> if tick marks are visible.
*/
public boolean isTickMarksVisible() {
return showTickMarksCheckBox.isSelected();
}
/**
* Returns the current tick label insets value
*
* @return the current tick label insets value.
*/
public Insets getTickLabelInsets() {
return (this.tickLabelInsets == null)
? new Insets(0, 0, 0, 0)
: this.tickLabelInsets;
}
/**
* Returns the current label insets value
*
* @return the current label insets value.
*/
public Insets getLabelInsets() {
return (this.labelInsets == null) ? new Insets(0, 0, 0, 0) : this.labelInsets;
}
/**
* Returns a reference to the tabbed pane.
*
* @return a reference to the tabbed pane.
*/
public JTabbedPane getOtherTabs() {
return otherTabs;
}
/**
* Handles user interaction with the property panel.
* @param event Information about the event that triggered the call to
* this method.
*/
public void actionPerformed(ActionEvent event) {
String command = event.getActionCommand();
if (command.equals("SelectLabelFont")) {
attemptLabelFontSelection();
}
else if (command.equals("SelectLabelPaint")) {
attemptModifyLabelPaint();
}
else if (command.equals("SelectTickLabelFont")) {
attemptTickLabelFontSelection();
}
else if (command.equals("LabelInsets")) {
editLabelInsets();
}
else if (command.equals("TickLabelInsets")) {
editTickLabelInsets();
}
}
/**
* Presents a font selection dialog to the user.
*/
private void attemptLabelFontSelection() {
FontChooserPanel panel = new FontChooserPanel(labelFont);
int result = JOptionPane.showConfirmDialog(this, panel,
localizationResources.getString("Font_Selection"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
labelFont = panel.getSelectedFont();
labelFontField.setText(labelFont.getFontName() + " " + labelFont.getSize());
}
}
/**
* Allows the user the opportunity to change the outline paint.
*/
private void attemptModifyLabelPaint() {
Color c;
c = JColorChooser.showDialog(this, localizationResources.getString("Label_Color"),
Color.blue);
if (c != null) {
labelPaintSample.setPaint(c);
}
}
/**
* Presents a tick label font selection dialog to the user.
*/
public void attemptTickLabelFontSelection() {
FontChooserPanel panel = new FontChooserPanel(tickLabelFont);
int result = JOptionPane.showConfirmDialog(this, panel,
localizationResources.getString("Font_Selection"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
tickLabelFont = panel.getSelectedFont();
tickLabelFontField.setText(tickLabelFont.getFontName() + " "
+ tickLabelFont.getSize());
}
}
/**
* Presents insets chooser panel allowing user to modify tick label's
* individual insets values. Updates the current insets text field if edit
* is accepted.
*/
private void editTickLabelInsets() {
InsetsChooserPanel panel = new InsetsChooserPanel(this.tickLabelInsets);
int result = JOptionPane.showConfirmDialog(this, panel,
localizationResources.getString("Edit_Insets"),
JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
this.tickLabelInsets = panel.getInsets();
tickLabelInsetsTextField.setInsets(this.tickLabelInsets);
}
}
/**
* Presents insets chooser panel allowing user to modify label's
* individual insets values. Updates the current insets text field if edit
* is accepted.
*/
private void editLabelInsets() {
InsetsChooserPanel panel = new InsetsChooserPanel(this.labelInsets);
int result = JOptionPane.showConfirmDialog(this, panel,
localizationResources.getString("Edit_Insets"),
JOptionPane.PLAIN_MESSAGE);
if (result == JOptionPane.OK_OPTION) {
this.labelInsets = panel.getInsets();
labelInsetsTextField.setInsets(this.labelInsets);
}
}
/**
* Sets the properties of the specified axis to match the properties
* defined on this panel.
*
* @param axis the axis.
*/
public void setAxisProperties(Axis axis) {
axis.setLabel(getLabel());
axis.setLabelFont(getLabelFont());
axis.setLabelPaint(getLabelPaint());
axis.setTickMarksVisible(isTickMarksVisible());
// axis.setTickMarkStroke(getTickMarkStroke());
axis.setTickLabelsVisible(isTickLabelsVisible());
axis.setTickLabelFont(getTickLabelFont());
axis.setTickLabelPaint(getTickLabelPaint());
axis.setTickLabelInsets(getTickLabelInsets());
axis.setLabelInsets(getLabelInsets());
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -