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

📄 meterplot.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* =========================================================== * JFreeChart : a free chart library for the Java(tm) platform * =========================================================== * * (C) Copyright 2000-2004, 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.] * * -------------- * MeterPlot.java * -------------- * (C) Copyright 2000-2004, by Hari and Contributors. * * Original Author:  Hari (ourhari@hotmail.com); * Contributor(s):   David Gilbert (for Object Refinery Limited); *                   Bob Orchard; *                   Arnaud Lelievre; *                   Nicolas Brodu; * * $Id: MeterPlot.java,v 1.29 2004/05/26 13:03:22 mungady Exp $ * * Changes * ------- * 01-Apr-2002 : Version 1, contributed by Hari (DG); * 23-Apr-2002 : Moved dataset from JFreeChart to Plot (DG); * 22-Aug-2002 : Added changes suggest by Bob Orchard, changed Color to Paint for consistency, *               plus added Javadoc comments (DG); * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 23-Jan-2003 : Removed one constructor (DG); * 26-Mar-2003 : Implemented Serializable (DG); * 20-Aug-2003 : Changed dataset from MeterDataset --> ValueDataset, added equals(...) method, * 08-Sep-2003 : Added internationalization via use of properties resourceBundle (RFE 690236) (AL);  *               implemented Cloneable, and various other changes (DG); * 08-Sep-2003 : Added serialization methods (NB); * 11-Sep-2003 : Added cloning support (NB); * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); * 25-Sep-2003 : Fix useless cloning. Correct dataset listener registration in constructor. (NB) * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); * 17-Jan-2004 : Changed to allow dialBackgroundPaint to be set to null - see bug 823628 (DG); * 07-Apr-2004 : Changed string bounds calculation (DG); * 12-May-2004 : Added tickLabelFormat attribute - see RFE 949566.  Also updated the equals()  *               method (DG); * */package org.jfree.chart.plot;import java.awt.AlphaComposite;import java.awt.BasicStroke;import java.awt.Color;import java.awt.Composite;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics2D;import java.awt.Insets;import java.awt.Paint;import java.awt.Polygon;import java.awt.Shape;import java.awt.geom.Arc2D;import java.awt.geom.Ellipse2D;import java.awt.geom.Line2D;import java.awt.geom.Rectangle2D;import java.io.IOException;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import java.io.Serializable;import java.text.NumberFormat;import java.util.List;import java.util.ResourceBundle;import org.jfree.chart.LegendItemCollection;import org.jfree.chart.event.PlotChangeEvent;import org.jfree.data.DatasetChangeEvent;import org.jfree.data.MeterDataset;import org.jfree.data.Range;import org.jfree.data.ValueDataset;import org.jfree.io.SerialUtilities;import org.jfree.text.TextUtilities;import org.jfree.util.ObjectUtils;/** * A plot that displays a single value in the context of several ranges ('normal', 'warning' * and 'critical'). */public class MeterPlot extends Plot implements Serializable, Cloneable {    /** Constant to indicate the normal data range. */    public static final int NORMAL_DATA_RANGE = 0;        /** Constant to indicate the warning data range. */    public static final int WARNING_DATA_RANGE = 1;    /** Constant to indicate the critical data range. */    public static final int CRITICAL_DATA_RANGE = 2;    /** Constant to indicate the full data range. */    public static final int FULL_DATA_RANGE = 3;        /** The default text for the normal level. */    public static final String NORMAL_TEXT = "Normal";    /** The default text for the warning level. */    public static final String WARNING_TEXT = "Warning";    /** The default text for the critical level. */    public static final String CRITICAL_TEXT = "Critical";    /** The default 'normal' level color. */    static final Paint DEFAULT_NORMAL_PAINT = Color.green;    /** The default 'warning' level color. */    static final Paint DEFAULT_WARNING_PAINT = Color.yellow;    /** The default 'critical' level color. */    static final Paint DEFAULT_CRITICAL_PAINT = Color.red;    /** The default background paint. */    static final Paint DEFAULT_DIAL_BACKGROUND_PAINT = Color.black;    /** The default needle paint. */    static final Paint DEFAULT_NEEDLE_PAINT = Color.green;    /** The default value font. */    static final Font DEFAULT_VALUE_FONT = new Font("SansSerif", Font.BOLD, 12);    /** The default value paint. */    static final Paint DEFAULT_VALUE_PAINT = Color.yellow;    /** The default meter angle. */    public static final int DEFAULT_METER_ANGLE = 270;    /** The default border size. */    public static final float DEFAULT_BORDER_SIZE = 3f;    /** The default circle size. */    public static final float DEFAULT_CIRCLE_SIZE = 10f;    /** The default background color. */    public static final Paint DEFAULT_BACKGROUND_PAINT = Color.lightGray;    /** The default label font. */    public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", Font.BOLD, 10);    /** Constant for the label type. */    public static final int NO_LABELS = 0;    /** Constant for the label type. */    public static final int VALUE_LABELS = 1;    /** The dataset. */    private ValueDataset dataset;    /** The units displayed on the dial. */        private String units;        /** The overall range. */    private Range range;        /** The normal range. */    private Range normalRange;        /** The warning range. */    private Range warningRange;        /** The critical range. */    private Range criticalRange;        /** The outline paint. */    private transient Paint dialOutlinePaint;    /** The 'normal' level color. */    private transient Paint normalPaint = DEFAULT_NORMAL_PAINT;    /** The 'warning' level color. */    private transient Paint warningPaint = DEFAULT_WARNING_PAINT;    /** The 'critical' level color. */    private transient Paint criticalPaint = DEFAULT_CRITICAL_PAINT;    /** The dial shape (background shape). */    private DialShape shape = DialShape.CIRCLE;    /** The paint for the dial background. */    private transient Paint dialBackgroundPaint;    /** The paint for the needle. */    private transient Paint needlePaint;    /** The font for the value displayed in the center of the dial. */    private Font valueFont;    /** The paint for the value displayed in the center of the dial. */    private transient Paint valuePaint;    /** The tick label type (NO_LABELS, VALUE_LABELS). */    private int tickLabelType;    /** The tick label font. */    private Font tickLabelFont;    /** The tick label format. */    private NumberFormat tickLabelFormat;        /** A flag that controls whether or not the border is drawn. */    private boolean drawBorder;    /** ??? */    private int meterCalcAngle = -1;    /** ??? */    private double meterRange = -1;    /** The resourceBundle for the localization. */    protected static ResourceBundle localizationResources =                             ResourceBundle.getBundle("org.jfree.chart.plot.LocalizationBundle");    /** The dial extent. */    private int meterAngle = DEFAULT_METER_ANGLE;    /** The minimum meter value. */    private double minMeterValue = 0.0;    /**     * Creates a new plot with no dataset.     */    public MeterPlot() {        this(null);       }        /**     * Creates a new plot that displays the value in the supplied dataset.     *     * @param dataset  the dataset (<code>null</code> permitted).     */    public MeterPlot(ValueDataset dataset) {        super();        this.units = "Units";        this.range = new Range(0.0, 100.0);        this.normalRange = new Range(0.0, 60.0);        this.warningRange = new Range(60.0, 90.0);        this.criticalRange = new Range(90.0, 100.0);        this.tickLabelType = MeterPlot.VALUE_LABELS;        this.tickLabelFont = MeterPlot.DEFAULT_LABEL_FONT;        this.tickLabelFormat = NumberFormat.getInstance();        this.dialBackgroundPaint = MeterPlot.DEFAULT_DIAL_BACKGROUND_PAINT;        this.needlePaint = MeterPlot.DEFAULT_NEEDLE_PAINT;        this.valueFont = MeterPlot.DEFAULT_VALUE_FONT;        this.valuePaint = MeterPlot.DEFAULT_VALUE_PAINT;        setDataset(dataset);    }    /**     * Returns the units for the dial.     *      * @return The units.     */    public String getUnits() {        return this.units;    }        /**     * Sets the units for the dial.     *      * @param units  the units.     */    public void setUnits(String units) {        this.units = units;            notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the overall range for the dial.     *      * @return The overall range.     */    public Range getRange() {        return this.range;        }        /**     * Sets the overall range for the dial.     *      * @param range  the range.     */    public void setRange(Range range) {        this.range = range;        }        /**     * Returns the normal range for the dial.     *      * @return The normal range.     */    public Range getNormalRange() {        return this.normalRange;        }        /**     * Sets the normal range for the dial.     *      * @param range  the range.     */    public void setNormalRange(Range range) {        this.normalRange = range;            notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the warning range for the dial.     *      * @return The warning range.     */    public Range getWarningRange() {        return this.warningRange;        }        /**     * Sets the warning range for the dial.     *      * @param range  the range.     */    public void setWarningRange(Range range) {        this.warningRange = range;            notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the critical range for the dial.     *      * @return The critical range.     */    public Range getCriticalRange() {        return this.criticalRange;        }        /**     * Sets the critical range for the dial.     *      * @param range  the range.     */    public void setCriticalRange(Range range) {        this.criticalRange = range;            notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the dial shape.     *      * @return The dial shape.     */    public DialShape getDialShape() {        return this.shape;    }        /**     * Sets the dial shape.     *      * @param shape  the shape.     */    public void setDialShape(DialShape shape) {        this.shape = shape;        notifyListeners(new PlotChangeEvent(this));    }        /**     * Returns the paint for the dial background.     *     * @return The paint (possibly <code>null</code>).     */    public Paint getDialBackgroundPaint() {        return this.dialBackgroundPaint;    }    /**     * Sets the paint used to fill the dial background.     *     * @param paint  the paint (<code>null</code> permitted).     */    public void setDialBackgroundPaint(Paint paint) {        this.dialBackgroundPaint = paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the paint for the needle.     *     * @return The paint.     */    public Paint getNeedlePaint() {        return this.needlePaint;    }    /**     * Sets the paint used to display the needle.     * <P>     * If you set this to null, it will revert to the default color.     *     * @param paint The paint.     */    public void setNeedlePaint(Paint paint) {        this.needlePaint = paint == null ? DEFAULT_NEEDLE_PAINT : paint;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the font for the value label.     *     * @return The font.     */    public Font getValueFont() {        return this.valueFont;    }    /**     * Sets the font used to display the value label.     * <P>     * If you set this to null, it will revert to the default font.     *     * @param font The font.     */    public void setValueFont(Font font) {        this.valueFont = (font == null) ? DEFAULT_VALUE_FONT : font;        notifyListeners(new PlotChangeEvent(this));    }    /**     * Returns the paint for the value label.     *     * @return The paint.     */    public Paint getValuePaint() {        return this.valuePaint;    }    /**     * Sets the paint used to display the value label.     * <P>     * If you set this to null, it will revert to the default paint.     *     * @param paint The paint.     */    public void setValuePaint(Paint paint) {

⌨️ 快捷键说明

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