⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 axispropertyeditpanel.java

📁 JfreeChart 常用图表例子
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors. * * Project Info:  http://www.jfree.org/jfreechart/index.html * * This library is free software; you can redistribute it and/or modify it  * under the terms of the GNU Lesser General Public License as published by  * the Free Software Foundation; either version 2.1 of the License, or  * (at your option) any later version. * * This library is distributed in the hope that it will be useful, but  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public  * License for more details. * * You should have received a copy of the GNU Lesser General Public License  * along with this library; if not, write to the Free Software Foundation,  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc.  * in the United States and other countries.] * * -------------------------- * AxisPropertyEditPanel.java * -------------------------- * (C) Copyright 2000-2004, by Object Refinery Limited and Contributors. * * Original Author:  David Gilbert; * Contributor(s):   Andrzej Porebski; *                   Arnaud Lelievre; * * $Id: AxisPropertyEditPanel.java,v 1.3 2005/04/21 09:43:33 mungady Exp $ * * Changes (from 24-Aug-2001) * -------------------------- * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); * 07-Nov-2001 : Separated the JCommon Class Library classes, JFreeChart now  *               requires jcommon.jar (DG); * 21-Nov-2001 : Allowed for null axes (DG); * 09-Apr-2002 : Minor change to import statement to fix Javadoc error (DG); * 15-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 08-Sep-2003 : Added internationalization via use of properties  *               resourceBundle (RFE 690236) (AL);  * */package org.jfree.chart.ui;import java.awt.BorderLayout;import java.awt.Color;import java.awt.Font;import java.awt.Paint;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.util.ResourceBundle;import javax.swing.BorderFactory;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JColorChooser;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTabbedPane;import javax.swing.JTextField;import org.jfree.chart.axis.Axis;import org.jfree.chart.axis.NumberAxis;import org.jfree.layout.LCBLayout;import org.jfree.ui.FontChooserPanel;import org.jfree.ui.FontDisplayField;import org.jfree.ui.PaintSample;import org.jfree.ui.RectangleInsets;/** * A panel for editing the properties of an axis. * */public class AxisPropertyEditPanel extends JPanel implements ActionListener {    /** The axis label. */    private JTextField label;    /** The label font. */    private Font labelFont;    /** The label paint. */    private PaintSample labelPaintSample;    /** A field showing a description of the label font. */    private JTextField labelFontField;    /** The font for displaying tick labels on the axis. */    private Font tickLabelFont;    /**      * A field containing a description of the font for displaying tick labels      * on the axis.      */    private JTextField tickLabelFontField;    /** The paint (color) for the tick labels. */    private PaintSample tickLabelPaintSample;    /**     * An empty sub-panel for extending the user interface to handle more      * complex axes.      */    private JPanel slot1;    /**      * An empty sub-panel for extending the user interface to handle more      * complex axes.      */    private JPanel slot2;    /** A flag that indicates whether or not the tick labels are visible. */    private JCheckBox showTickLabelsCheckBox;    /** A flag that indicates whether or not the tick marks are visible. */    private JCheckBox showTickMarksCheckBox;//    /** Insets text field. *///    private InsetsTextField tickLabelInsetsTextField;////    /** Label insets text field. *///    private InsetsTextField labelInsetsTextField;    /** The tick label insets. */    private RectangleInsets tickLabelInsets;    /** The label insets. */    private RectangleInsets labelInsets;    /** A tabbed pane for... */    private JTabbedPane otherTabs;    /** The resourceBundle for the localization. */    protected static ResourceBundle localizationResources =         ResourceBundle.getBundle("org.jfree.chart.ui.LocalizationBundle");    /**     * A static method that returns a panel that is appropriate for the axis     * type.     *     * @param axis  the axis whose properties are to be displayed/edited in      *              the panel.     *     * @return A panel or <code>null</code< if axis is <code>null</code>.     */    public static AxisPropertyEditPanel getInstance(Axis axis) {        if (axis != null) {            // figure out what type of axis we have and instantiate the            // appropriate panel            if (axis instanceof NumberAxis) {                return new NumberAxisPropertyEditPanel((NumberAxis) axis);            }            else {                return new AxisPropertyEditPanel(axis);            }        }        else {            return null;        }    }    /**     * Standard constructor: builds a panel for displaying/editing the     * properties of the specified axis.     *     * @param axis  the axis whose properties are to be displayed/edited in      *              the panel.     */    public AxisPropertyEditPanel(Axis axis) {        this.labelFont = axis.getLabelFont();        this.labelPaintSample = new PaintSample(axis.getLabelPaint());        this.tickLabelFont = axis.getTickLabelFont();        this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint());        // Insets values        this.tickLabelInsets = axis.getTickLabelInsets();        this.labelInsets = axis.getLabelInsets();        setLayout(new BorderLayout());        JPanel general = new JPanel(new BorderLayout());        general.setBorder(            BorderFactory.createTitledBorder(                BorderFactory.createEtchedBorder(),                 localizationResources.getString("General")            )        );        JPanel interior = new JPanel(new LCBLayout(5));        interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));        interior.add(new JLabel(localizationResources.getString("Label")));        this.label = new JTextField(axis.getLabel());        interior.add(this.label);        interior.add(new JPanel());        interior.add(new JLabel(localizationResources.getString("Font")));        this.labelFontField = new FontDisplayField(this.labelFont);        interior.add(this.labelFontField);        JButton b = new JButton(localizationResources.getString("Select..."));        b.setActionCommand("SelectLabelFont");        b.addActionListener(this);        interior.add(b);        interior.add(new JLabel(localizationResources.getString("Paint")));        interior.add(this.labelPaintSample);        b = new JButton(localizationResources.getString("Select..."));        b.setActionCommand("SelectLabelPaint");        b.addActionListener(this);        interior.add(b);//        interior.add(//            new JLabel(localizationResources.getString("Label_Insets"))//        );//        b = new JButton(localizationResources.getString("Edit..."));//        b.setActionCommand("LabelInsets");//        b.addActionListener(this);//        this.labelInsetsTextField = new InsetsTextField(this.labelInsets);//        interior.add(this.labelInsetsTextField);//        interior.add(b);////        interior.add(//            new JLabel(localizationResources.getString("Tick_Label_Insets"))//        );//        b = new JButton(localizationResources.getString("Edit..."));//        b.setActionCommand("TickLabelInsets");//        b.addActionListener(this);//        this.tickLabelInsetsTextField //            = new InsetsTextField(this.tickLabelInsets);//        interior.add(this.tickLabelInsetsTextField);//        interior.add(b);        general.add(interior);        add(general, BorderLayout.NORTH);        this.slot1 = new JPanel(new BorderLayout());        JPanel other = new JPanel(new BorderLayout());        other.setBorder(BorderFactory.createTitledBorder(                             BorderFactory.createEtchedBorder(),                              localizationResources.getString("Other")));        this.otherTabs = new JTabbedPane();        this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));        JPanel ticks = new JPanel(new LCBLayout(3));        ticks.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));        this.showTickLabelsCheckBox = new JCheckBox(            localizationResources.getString("Show_tick_labels"),             axis.isTickLabelsVisible()        );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -