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

📄 dialplot.java

📁 java图形利器
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2007, 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.] * * ------------- * DialPlot.java * ------------- * (C) Copyright 2006, 2007, by Object Refinery Limited. * * Original Author:  David Gilbert (for Object Refinery Limited); * Contributor(s):   -; * * $Id: DialPlot.java,v 1.1.2.5 2007/03/08 16:51:07 mungady Exp $ * * Changes * ------- * 03-Nov-2006 : Version 1 (DG); * 08-Mar-2007 : Fix in hashCode() (DG); *  */package org.jfree.experimental.chart.plot.dial;import java.awt.Graphics2D;import java.awt.Shape;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.util.Iterator;import java.util.List;import org.jfree.chart.JFreeChart;import org.jfree.chart.event.PlotChangeEvent;import org.jfree.chart.plot.Plot;import org.jfree.chart.plot.PlotRenderingInfo;import org.jfree.chart.plot.PlotState;import org.jfree.data.general.DatasetChangeEvent;import org.jfree.data.general.ValueDataset;import org.jfree.util.ObjectList;import org.jfree.util.ObjectUtilities;/** * A dial plot. */public class DialPlot extends Plot implements DialLayerChangeListener {    /**     * The background layer (optional).     */    private DialLayer background;        /**     * The needle cap (optional).     */    private DialLayer cap;        /**     * The dial frame.     */    private DialFrame dialFrame;        /**     * The dataset(s) for the dial plot.     */    private ObjectList datasets;        /**     * The scale(s) for the dial plot.      */    private ObjectList scales;        /** Storage for keys that map datasets to scales. */    private ObjectList datasetToScaleMap;    /**     * The drawing layers for the dial plot.     */    private List layers;        /**     * The x-coordinate for the view window.     */    private double viewX;        /**     * The y-coordinate for the view window.     */    private double viewY;        /**     * The width of the view window, expressed as a percentage.     */    private double viewW;        /**     * The height of the view window, expressed as a percentage.     */    private double viewH;        /**      * Creates a new instance of <code>DialPlot</code>.     */    public DialPlot() {        this.background = null;        this.cap = null;        this.dialFrame = new StandardDialFrame();        this.datasets = new ObjectList();        this.scales = new ObjectList();        this.datasetToScaleMap = new ObjectList();        this.layers = new java.util.ArrayList();        this.viewX = 0.0;        this.viewY = 0.0;        this.viewW = 1.0;        this.viewH = 1.0;    }    /**     * Returns the background.     *     * @return The background (possibly <code>null</code>).     *     * @see #setBackground(DialLayer)     */    public DialLayer getBackground() {        return this.background;    }        /**     * Sets the background layer.     *     * @param background  the background layer (<code>null</code> permitted).     *     * @see #getBackground()     */    public void setBackground(DialLayer background) {        this.background = background;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the cap.     *     * @return The cap (possibly <code>null</code>).     *     * @see #setCap(DialLayer)     */    public DialLayer getCap() {        return this.cap;    }        /**     * Sets the cap.     *     * @param cap  the cap (<code>null</code> permitted).     *     * @see #getCap()     */    public void setCap(DialLayer cap) {        this.cap = cap;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the dial's frame.     *     * @return The dial's frame (never <code>null</code>).     *     * @see #setDialFrame(DialFrame)     */    public DialFrame getDialFrame() {        return this.dialFrame;    }        /**     * Sets the dial's frame.     *     * @param frame  the frame (<code>null</code> not permitted).     *     * @see #getDialFrame()     */    public void setDialFrame(DialFrame frame) {        if (frame == null) {            throw new IllegalArgumentException("Null 'frame' argument.");        }        this.dialFrame = frame;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the x-coordinate of the viewing rectangle.  This is specified     * in the range 0.0 to 1.0, relative to the dial's framing rectangle.     *      * @return The x-coordinate of the viewing rectangle.     *      * @see #setView(double, double, double, double)     */    public double getViewX() {        return this.viewX;    }        /**     * Returns the y-coordinate of the viewing rectangle.  This is specified     * in the range 0.0 to 1.0, relative to the dial's framing rectangle.     *      * @return The y-coordinate of the viewing rectangle.     *      * @see #setView(double, double, double, double)     */    public double getViewY() {        return this.viewY;    }        /**     * Returns the width of the viewing rectangle.  This is specified     * in the range 0.0 to 1.0, relative to the dial's framing rectangle.     *      * @return The width of the viewing rectangle.     *      * @see #setView(double, double, double, double)     */    public double getViewWidth() {        return this.viewW;    }        /**     * Returns the height of the viewing rectangle.  This is specified     * in the range 0.0 to 1.0, relative to the dial's framing rectangle.     *      * @return The height of the viewing rectangle.     *      * @see #setView(double, double, double, double)     */    public double getViewHeight() {        return this.viewH;    }        /**     * Sets the viewing rectangle, relative to the dial's framing rectangle.     *      * @param x  the x-coordinate (in the range 0.0 to 1.0).     * @param y  the y-coordinate (in the range 0.0 to 1.0).     * @param w  the width (in the range 0.0 to 1.0).     * @param h  the height (in the range 0.0 to 1.0).     *      * @see #getViewX()     * @see #getViewY()     * @see #getViewWidth()     * @see #getViewHeight()     */    public void setView(double x, double y, double w, double h) {        this.viewX = x;        this.viewY = y;        this.viewW = w;        this.viewH = h;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Adds a layer to the plot.     *      * @param layer  the layer (<code>null</code> not permitted).     */    public void addLayer(DialLayer layer) {        if (layer == null) {            throw new IllegalArgumentException("Null 'layer' argument.");        }        this.layers.add(layer);            notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the primary dataset for the plot.     *     * @return The primary dataset (possibly <code>null</code>).     */    public ValueDataset getDataset() {        return getDataset(0);    }    /**     * Returns the dataset at the given index.     *     * @param index  the dataset index.     *     * @return The dataset (possibly <code>null</code>).     */    public ValueDataset getDataset(int index) {        ValueDataset result = null;        if (this.datasets.size() > index) {            result = (ValueDataset) this.datasets.get(index);        }        return result;    }    /**     * Sets the dataset for the plot, replacing the existing dataset, if there 

⌨️ 快捷键说明

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