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

📄 swtothereditor.java

📁 java图形利器
💻 JAVA
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2006, 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.] * * ------------------- * SWTOtherEditor.java * ------------------- * (C) Copyright 2006, by Henry Proudhon and Contributors. * * Original Author:  Henry Proudhon (henry.proudhon AT insa-lyon.fr); * Contributor(s):   David Gilbert (for Object Refinery Limited); * * Changes * ------- * 01-Aug-2006 : New class (HP); *  */package org.jfree.experimental.chart.swt.editor;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.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.Group;import org.eclipse.swt.widgets.Label;import org.jfree.chart.JFreeChart;import org.jfree.experimental.swt.SWTPaintCanvas;import org.jfree.experimental.swt.SWTUtils;/** * An editor for miscellaneous chart properties. */class SWTOtherEditor extends Composite {        /** A checkbox indicating whether or not      * the chart is drawn with anti-aliasing. */    private Button antialias;    /** The chart background color. */    private SWTPaintCanvas backgroundPaintCanvas;    /** The resourceBundle for the localization. */    protected static ResourceBundle localizationResources         = ResourceBundle.getBundle("org.jfree.chart.editor.LocalizationBundle");    /**     * Creates a new instance.     *      * @param parent  the parent.     * @param style  the style.     * @param chart  the chart.     */    public SWTOtherEditor(Composite parent, int style, JFreeChart chart)    {        super(parent, style);        FillLayout layout = new FillLayout();        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: antialiasing        antialias = new Button(general, SWT.CHECK);        antialias.setText(localizationResources.getString("Draw_anti-aliased"));        antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false,                3, 1));        antialias.setSelection(chart.getAntiAlias());                //row 2: background paint for the chart        new Label(general, SWT.NONE).setText(localizationResources.getString(                "Background_paint"));        backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE,                 SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint()));        GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false);        bgGridData.heightHint = 20;        backgroundPaintCanvas.setLayoutData(bgGridData);        Button selectBgPaint = new Button(general, SWT.PUSH);        selectBgPaint.setText(localizationResources.getString("Select..."));        selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false,                false));        selectBgPaint.addSelectionListener(                new SelectionAdapter() {                    public void widgetSelected(SelectionEvent event) {                        ColorDialog dlg = new ColorDialog(getShell());                        dlg.setText(localizationResources.getString(                                "Background_paint"));                        dlg.setRGB(backgroundPaintCanvas.getColor().getRGB());                        RGB rgb = dlg.open();                        if (rgb != null) {                            backgroundPaintCanvas.setColor(                                    new Color(getDisplay(), rgb));                        }                    }                }        );    }        /**     * Updates the chart.     *      * @param chart  the chart.     */    public void updateChartProperties(JFreeChart chart) {        chart.setAntiAlias(this.antialias.getSelection());        chart.setBackgroundPaint(SWTUtils.toAwtColor(                this.backgroundPaintCanvas.getColor()));            }}

⌨️ 快捷键说明

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