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

📄 jfreechartdemobase.java

📁 这是一个segy数据显示程序
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* =========================================================== * 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.] * * ----------------------- * JFreeChartDemoBase.java * ----------------------- * (C) Copyright 2000-2004, by Object Refinery Limited and Contributors. * * Original Author:  David Gilbert (for Object Refinery Limited); * Contributor(s):   Andrzej Porebski; *                   Matthew Wright; *                   Serge V. Grachov; *                   Bill Kelemen; *                   Achilleus Mantzios; *                   Bryan Scott; *                   Robert Redburn; * * $Id: JFreeChartDemoBase.java,v 1.41 2004/05/24 16:14:52 mungady Exp $ * * Changes * ------- * 27-Jul-2002 : Created (BRS); * 10-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 19-Jan-2004 : Added createWaferMapChart(), createWaferMapChartValueIndexed(), *                 createWaferMapChartPositionIndexed() methods (RR); * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); * 27-Apr-2004 : Modified for changes to XYPlot class (DG); * 27-Apr-2004 : added createPieChartThree for comparable pie dataset (Benoit Xhenseval) * */package org.jfree.chart.demo;import java.awt.Color;import java.awt.Font;import java.awt.GradientPaint;import java.lang.reflect.Method;import java.text.DecimalFormat;import java.text.NumberFormat;import java.text.SimpleDateFormat;import java.util.Calendar;import java.util.Date;import java.util.ResourceBundle;import org.jfree.chart.ChartFactory;import org.jfree.chart.JFreeChart;import org.jfree.chart.Legend;import org.jfree.chart.axis.DateAxis;import org.jfree.chart.axis.LogarithmicAxis;import org.jfree.chart.axis.NumberAxis;import org.jfree.chart.axis.ValueAxis;import org.jfree.chart.labels.HighLowItemLabelGenerator;import org.jfree.chart.labels.StandardPieItemLabelGenerator;import org.jfree.chart.labels.StandardXYToolTipGenerator;import org.jfree.chart.plot.CategoryPlot;import org.jfree.chart.plot.CombinedDomainXYPlot;import org.jfree.chart.plot.CombinedRangeXYPlot;import org.jfree.chart.plot.CompassPlot;import org.jfree.chart.plot.DialShape;import org.jfree.chart.plot.MeterPlot;import org.jfree.chart.plot.PiePlot;import org.jfree.chart.plot.Plot;import org.jfree.chart.plot.PlotOrientation;import org.jfree.chart.plot.ThermometerPlot;import org.jfree.chart.plot.WaferMapPlot;import org.jfree.chart.plot.XYPlot;import org.jfree.chart.renderer.HighLowRenderer;import org.jfree.chart.renderer.StandardXYItemRenderer;import org.jfree.chart.renderer.WaferMapRenderer;import org.jfree.chart.renderer.XYBarRenderer;import org.jfree.chart.renderer.XYItemRenderer;import org.jfree.chart.title.TextTitle;import org.jfree.data.CategoryDataset;import org.jfree.data.CombinedDataset;import org.jfree.data.DatasetUtilities;import org.jfree.data.DefaultValueDataset;import org.jfree.data.HighLowDataset;import org.jfree.data.IntervalCategoryDataset;import org.jfree.data.MovingAverage;import org.jfree.data.PieDataset;import org.jfree.data.SignalsDataset;import org.jfree.data.SubSeriesDataset;import org.jfree.data.WaferMapDataset;import org.jfree.data.WindDataset;import org.jfree.data.XYDataset;import org.jfree.data.gantt.Task;import org.jfree.data.gantt.TaskSeries;import org.jfree.data.gantt.TaskSeriesCollection;import org.jfree.data.time.SimpleTimePeriod;import org.jfree.data.time.TimeSeries;import org.jfree.data.time.TimeSeriesCollection;import org.jfree.ui.HorizontalAlignment;import org.jfree.ui.RectangleEdge;import org.jfree.ui.Spacer;/** * A simple class that allows the swing and servlet chart demonstrations * to share chart generating code. * * If you would like to add a chart to the swing and/or servlet demo do so here. * */public class JFreeChartDemoBase {    /**     * CHART_COMMANDS holds information on charts that can be created     * Format is     *   Name, Creation Method, Resource file prefix     *     * Steps To add a chart     * 1) Create a createChart method which returns a JFreeChart     * 2) Append details to CHART_COMMANDS     * 3) Append details to DemoResources     */    public static final String[][] CHART_COMMANDS = {        {"HORIZONTAL_BAR_CHART", "createHorizontalBarChart", "chart1"},        {"HORIZONTAL_STACKED_BAR_CHART", "createStackedHorizontalBarChart", "chart2"},        {"VERTICAL_BAR_CHART", "createVerticalBarChart", "chart3"},        {"VERTICAL_3D_BAR_CHART", "createVertical3DBarChart", "chart4"},        {"VERTICAL_STACKED_BAR_CHART", "createVerticalStackedBarChart", "chart5"},        {"VERTICAL_STACKED_3D_BAR_CHART", "createVerticalStacked3DBarChart", "chart6"},        {"PIE_CHART_1", "createPieChartOne", "chart7"},        {"PIE_CHART_2", "createPieChartTwo", "chart8"},        {"PIE_CHART_3", "createPieChartThree", "chart39"},        {"XY_PLOT", "createXYPlot", "chart9"},        {"TIME_SERIES_1_CHART", "createTimeSeries1Chart", "chart10"},        {"TIME_SERIES_2_CHART", "createTimeSeries2Chart", "chart11"},        {"TIME_SERIES_WITH_MA_CHART", "createTimeSeriesWithMAChart", "chart12"},        {"HIGH_LOW_CHART", "createHighLowChart", "chart13"},        {"CANDLESTICK_CHART", "createCandlestickChart", "chart14"},        {"SIGNAL_CHART", "createSignalChart", "chart15"},        {"WIND_PLOT", "createWindPlot", "chart16"},        {"SCATTER_PLOT", "createScatterPlot", "chart17"},        {"LINE_CHART", "createLineChart", "chart18"},        {"VERTICAL_XY_BAR_CHART", "createVerticalXYBarChart", "chart19"},        {"XY_PLOT_NULL", "createNullXYPlot", "chart20"},        {"XY_PLOT_ZERO", "createXYPlotZeroData", "chart21"},        {"TIME_SERIES_CHART_SCROLL", "createTimeSeriesChartInScrollPane", "chart22"},        {"SINGLE_SERIES_BAR_CHART", "createSingleSeriesBarChart", "chart23"},        {"DYNAMIC_CHART", "createDynamicXYChart", "chart24"},        {"OVERLAID_CHART", "createOverlaidChart", "chart25"},        {"HORIZONTALLY_COMBINED_CHART", "createHorizontallyCombinedChart", "chart26"},        {"VERTICALLY_COMBINED_CHART", "createVerticallyCombinedChart", "chart27"},        {"COMBINED_OVERLAID_CHART", "createCombinedAndOverlaidChart1", "chart28"},        {"COMBINED_OVERLAID_DYNAMIC_CHART", "createCombinedAndOverlaidDynamicXYChart", "chart29"},        {"THERMOMETER_CHART", "createThermometerChart", "chart30"},        {"METER_CHART", "createMeterChartCircle", "chart31"},        {"GANTT_CHART", "createGanttChart", "chart32"},        {"METER_CHART2", "createMeterChartPie", "chart33"},        {"METER_CHART3", "createMeterChartChord", "chart34"},        {"COMPASS_CHART", "createCompassChart", "chart35"},        {"WAFERMAP_CHART", "createWaferMapChart", "chart36"},        {"WAFERMAP_VALUE_CHART", "createWaferMapChartValueIndexed", "chart37"},        {"WAFERMAP_POSITION_CHART", "createWaferMapChartPositionIndexed", "chart38"},    };    /** Base class name for localised resources. */    public static final String BASE_RESOURCE_CLASS        = "org.jfree.chart.demo.resources.DemoResources";    /** Localised resources. */    private ResourceBundle resources;    /** An array of charts. */    private JFreeChart[] charts = new JFreeChart[CHART_COMMANDS.length];    /**     * Default constructor.     */    public JFreeChartDemoBase() {        this.resources = ResourceBundle.getBundle(BASE_RESOURCE_CLASS);    }    /**     * Returns a chart.     *     * @param i  the chart index.     *     * @return a chart.     */    public JFreeChart getChart(int i) {        if ((i < 0) && (i >= this.charts.length)) {            i = 0;        }        if (this.charts[i] == null) {            /// Utilise reflection to invoke method to create new chart if required.            try {                final Method method = getClass().getDeclaredMethod(CHART_COMMANDS[i][1], null);                this.charts[i] = (JFreeChart) method.invoke(this, null);            }            catch (Exception ex) {                ex.printStackTrace();            }        }        return this.charts[i];    }    /**     * This makes the resources bundle available.  Basically an optimisation so     * the demo servlet can access the same resource file.     * @return the resources bundle.     */    public ResourceBundle getResources() {      return this.resources;    }    /**     * Create a horizontal bar chart.     *     * @return a horizontal bar chart.     */    public JFreeChart createHorizontalBarChart() {        // create a default chart based on some sample data...        final String title = this.resources.getString("bar.horizontal.title");        final String domain = this.resources.getString("bar.horizontal.domain");        final String range = this.resources.getString("bar.horizontal.range");        final CategoryDataset data = DemoDatasetFactory.createCategoryDataset();        final JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data,                                                       PlotOrientation.HORIZONTAL,                                                       true,                                                       true,                                                       false);        // then customise it a little...        chart.getLegend().setAnchor(Legend.EAST);        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.orange));        final CategoryPlot plot = chart.getCategoryPlot();        plot.setRangeCrosshairVisible(false);        final NumberAxis axis = (NumberAxis) plot.getRangeAxis();        axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());        axis.setInverted(true);        return chart;    }    /**     * Creates and returns a sample stacked horizontal bar chart.     *     * @return a sample stacked horizontal bar chart.     */    public JFreeChart createStackedHorizontalBarChart() {        // create a default chart based on some sample data...        final String title = this.resources.getString("bar.horizontal-stacked.title");        final String domain = this.resources.getString("bar.horizontal-stacked.domain");        final String range = this.resources.getString("bar.horizontal-stacked.range");        final CategoryDataset data = DemoDatasetFactory.createCategoryDataset();        final JFreeChart chart = ChartFactory.createStackedBarChart(title, domain, range,                                                              data,                                                              PlotOrientation.HORIZONTAL,                                                              true,                                                              true,                                                              false);        // then customise it a little...        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue));        return chart;    }    /**     * Creates and returns a sample vertical bar chart.     *     * @return a sample vertical bar chart.     */    public JFreeChart createVerticalBarChart() {        final String title = this.resources.getString("bar.vertical.title");        final String domain = this.resources.getString("bar.vertical.domain");        final String range = this.resources.getString("bar.vertical.range");        final CategoryDataset data = DemoDatasetFactory.createCategoryDataset();        final JFreeChart chart = ChartFactory.createBarChart(title, domain, range, data,                                                       PlotOrientation.VERTICAL,                                                       true,                                                       true,                                                       false);        // then customise it a little...        chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.red));        final CategoryPlot plot = (CategoryPlot) chart.getPlot();        plot.setForegroundAlpha(0.9f);        final NumberAxis verticalAxis = (NumberAxis) plot.getRangeAxis();

⌨️ 快捷键说明

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