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

📄 demodatasetfactory.java

📁 JfreeChart 常用图表例子
💻 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.] * * ----------------------- * DemoDatasetFactory.java * ----------------------- * (C) Copyright 2001-2004, by Object Refinery Limited. * * Original Author:  David Gilbert (for Object Refinery Limited); * Contributor(s):   Bryan Scott; *                   Bill Kelemen; *                   David Browning; *                   Robert Redburn; * * $Id: DemoDatasetFactory.java,v 1.27 2004/04/26 19:11:54 taqua Exp $ * * Changes * ------- * 10-Dec-2001 : Version 1 (DG); * 15-Mar-2002 : Added createHighLowOpenCloseDataset() method (DG); * 20-Jun-2002 : Added createMeterDataset() method (BRS); * 24-Jun-2002 : Moved createGanttDataset() method from GanttDemo (BRS); * 10-Oct-2002 : Fixed errors reported by Checkstyle (DG); * 24-May-2003 : Added createSegmentedHighLowDataset(..) (BK); * 05-Aug-2003 : Added createBoxAndWhiskerDataset() method (DB); * 08-Aug-2003 : Refined createBoxAndWhiskerDataset() method (DB); * 19-Jan-2004 : Added createWaferMapDataset() and *                     createRandomWaferMapDataset() methods (RR); * */package org.jfree.chart.demo;import java.util.Date;import java.util.Random;import org.jfree.chart.axis.SegmentedTimeline;import org.jfree.data.category.CategoryDataset;import org.jfree.data.category.IntervalCategoryDataset;import org.jfree.data.general.DatasetUtilities;import org.jfree.data.general.WaferMapDataset;import org.jfree.data.time.Day;import org.jfree.data.time.FixedMillisecond;import org.jfree.data.time.TimeSeries;import org.jfree.data.time.TimeSeriesCollection;import org.jfree.data.time.Year;import org.jfree.data.xy.DefaultHighLowDataset;import org.jfree.data.xy.DefaultWindDataset;import org.jfree.data.xy.SignalsDataset;import org.jfree.data.xy.WindDataset;import org.jfree.data.xy.XYDataset;import org.jfree.date.DateUtilities;import org.jfree.date.MonthConstants;/** * A utility class for generating sample datasets for the demos. * <p> * These datasets are hard-coded so that they are easily accessible for the demonstration * applications.  In a real application, you would create datasets dynamically by reading data from * a file, a database, or some other source. * */public abstract class DemoDatasetFactory {        /**     * Creates and returns a {@link CategoryDataset} for the demo charts.     *     * @return a sample dataset.     */    public static CategoryDataset createCategoryDataset() {        final double[][] data = new double[][]            {{10.0, 4.0, 15.0, 14.0},             {-5.0, -7.0, 14.0, -3.0},             {6.0, 17.0, -12.0, 7.0},             {7.0, 15.0, 11.0, 0.0},             {-8.0, -6.0, 10.0, -9.0},             {9.0, 8.0, 0.0, 6.0},             {-10.0, 9.0, 7.0, 7.0},             {11.0, 13.0, 9.0, 9.0},             {-3.0, 7.0, 11.0, -10.0}};        return DatasetUtilities.createCategoryDataset("Series ", "Category ", data);    }    /**     * Creates and returns a category dataset with JUST ONE CATEGORY for the demo charts.     *     * @return a sample category dataset.     */    public static CategoryDataset createSingleCategoryDataset() {        final Number[][] data = new Integer[][]            {{new Integer(10)},             {new Integer(-5)},             {new Integer(6)},             {new Integer(7)},             {new Integer(-8)},             {new Integer(9)},             {new Integer(-10)},             {new Integer(11)},             {new Integer(-3)}};        return DatasetUtilities.createCategoryDataset("Series ", "Category ", data);    }    /**     * Creates and returns a category dataset for the demo charts.     *     * @return a sample category dataset.     */    public static CategoryDataset createSingleSeriesCategoryDataset() {        final double[][] data = new double[][] {{10.0, -4.0, 15.0, 14.0}};        return DatasetUtilities.createCategoryDataset("Series ", "Category ", data);    }    /**     * Returns a null interval category dataset.     *     * @return null.     */    public static IntervalCategoryDataset createIntervalCategoryDataset() {        return null;    }    /**     * Returns a sample XY dataset.     *     * @return a sample XY dataset.     */    public static XYDataset createSampleXYDataset() {        return new SampleXYDataset();    }    /**     * Returns a dataset consisting of one annual series.     *     * @return a sample time series collection.     */    public static TimeSeriesCollection createTimeSeriesCollection1() {        final TimeSeries t1 = new TimeSeries("Annual", "Year", "Value", Year.class);        try {            t1.add(new Year(1990), new Double(50.1));            t1.add(new Year(1991), new Double(12.3));            t1.add(new Year(1992), new Double(23.9));            t1.add(new Year(1993), new Double(83.4));            t1.add(new Year(1994), new Double(-34.7));            t1.add(new Year(1995), new Double(76.5));            t1.add(new Year(1996), new Double(10.0));            t1.add(new Year(1997), new Double(-14.7));            t1.add(new Year(1998), new Double(43.9));            t1.add(new Year(1999), new Double(49.6));            t1.add(new Year(2000), new Double(37.2));            t1.add(new Year(2001), new Double(17.1));        }        catch (Exception e) {            System.err.println(e.getMessage());        }        return new TimeSeriesCollection(t1);    }    /**     * Creates a time series collection containing JPY/GBP exchange rates.     *     * @return a sample time series collection.

⌨️ 快捷键说明

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