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

📄 swtaxiseditor.java

📁 jfreechart-1.0.12 开发包和文档等
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2008, 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, * USA. * * [Java is a trademark or registered trademark of Sun Microsystems, Inc. * in the United States and other countries.] * * ------------------ * SWTAxisEditor.java * ------------------ * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. * * Original Author:  Henry Proudhon (henry.proudhon AT ensmp.fr); * Contributor(s):   David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); * 07-Feb-2007 : Fixed bug 1647749, handle null axis labels (DG); * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by *               Jess Thrysoee (DG); * */package org.jfree.experimental.chart.swt.editor;import java.awt.Paint;import java.util.ResourceBundle;import org.eclipse.swt.SWT;import org.eclipse.swt.events.SelectionAdapter;import org.eclipse.swt.events.SelectionEvent;import org.eclipse.swt.graphics.Color;import org.eclipse.swt.graphics.Font;import org.eclipse.swt.graphics.FontData;import org.eclipse.swt.graphics.RGB;import org.eclipse.swt.layout.FillLayout;import org.eclipse.swt.layout.GridData;import org.eclipse.swt.layout.GridLayout;import org.eclipse.swt.widgets.Button;import org.eclipse.swt.widgets.ColorDialog;import org.eclipse.swt.widgets.Composite;import org.eclipse.swt.widgets.FontDialog;import org.eclipse.swt.widgets.Group;import org.eclipse.swt.widgets.Label;import org.eclipse.swt.widgets.TabFolder;import org.eclipse.swt.widgets.TabItem;import org.eclipse.swt.widgets.Text;import org.jfree.chart.axis.Axis;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.util.ResourceBundleWrapper;import org.jfree.experimental.swt.SWTPaintCanvas;import org.jfree.experimental.swt.SWTUtils;/** * An editor for axis properties. */class SWTAxisEditor extends Composite {    /** The axis label. */    private Text label;    /** The font used to draw the axis labels. */    private FontData labelFont;    /** The paint (color) used to draw the axis labels. */    private Color labelPaintColor;    /** The font used to draw the axis tick labels. */    private FontData tickLabelFont;    /** The paint (color) used to draw the axis tick labels. */    private Color tickLabelPaintColor;    /** A field showing a description of the label font. */    private Text labelFontField;    /**     * A field containing a description of the font     * for displaying tick labels on the axis.     */    private Text tickLabelFontField;    /** The resourceBundle for the localization. */    protected static ResourceBundle localizationResources            =  ResourceBundleWrapper.getBundle(                    "org.jfree.chart.editor.LocalizationBundle");    /** Font object used to handle a change of font. */    private Font font;    /** A flag that indicates whether or not the tick labels are visible. */    private Button showTickLabelsCheckBox;    /** A flag that indicates whether or not the tick marks are visible. */    private Button showTickMarksCheckBox;    /** A tabbed pane for... */    private TabFolder otherTabs;    /**     * Standard constructor: builds a composite for displaying/editing     * the properties of the specified axis.     *     * @param parent The parent composite.     * @param style The SWT style of the SwtAxisEditor.     * @param axis  the axis whose properties are to be displayed/edited     *              in the composite.     */    public SWTAxisEditor(Composite parent, int style, Axis axis) {        super(parent, style);        this.labelFont = SWTUtils.toSwtFontData(getDisplay(),                axis.getLabelFont(), true);        this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(),                axis.getLabelPaint());        this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(),                axis.getTickLabelFont(), true);        this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(),                axis.getTickLabelPaint());        FillLayout layout = new FillLayout(SWT.VERTICAL);        layout.marginHeight = layout.marginWidth = 4;        setLayout(layout);        Group general = new Group(this, SWT.NONE);        general.setLayout(new GridLayout(3, false));        general.setText(localizationResources.getString("General"));        // row 1        new Label(general, SWT.NONE).setText(localizationResources.getString(                "Label"));        this.label = new Text(general, SWT.BORDER);        if (axis.getLabel() != null) {            this.label.setText(axis.getLabel());        }        this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true,                false));        new Label(general, SWT.NONE).setText(""); //empty cell        // row 2        new Label(general, SWT.NONE).setText(localizationResources.getString(                "Font"));        this.labelFontField = new Text(general, SWT.BORDER);        this.labelFontField.setText(this.labelFont.toString());        this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER,                true, false));        Button selectFontButton = new Button(general, SWT.PUSH);        selectFontButton.setText(localizationResources.getString("Select..."));        selectFontButton.addSelectionListener(                new SelectionAdapter() {                    public void widgetSelected(SelectionEvent event) {                        // Create the color-change dialog                        FontDialog dlg = new FontDialog(getShell());                        dlg.setText(localizationResources.getString(                                "Font_Selection"));                        dlg.setFontList(new FontData[] {                                SWTAxisEditor.this.labelFont });                        if (dlg.open() != null) {                            // Dispose of any fonts we have created                            if (SWTAxisEditor.this.font != null) {                                SWTAxisEditor.this.font.dispose();                            }                            // Create the new font and set it into the title                            // label                            SWTAxisEditor.this.font = new Font(                                    getShell().getDisplay(), dlg.getFontList());                            //label.setFont(font);                            SWTAxisEditor.this.labelFontField.setText(                                    SWTAxisEditor.this.font.getFontData()[0]                                    .toString());                            SWTAxisEditor.this.labelFont                                    = SWTAxisEditor.this.font.getFontData()[0];                        }                    }                }        );

⌨️ 快捷键说明

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