📄 samplexysymbolicdataset.java
字号:
/* =========================================================== * 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.] * * ---------------------------- * SampleXYSymbolicDataset.java * ---------------------------- * (C) Copyright 2000-2004, by Anthony Boulestreau and Contributors; * * Original Author: Anthony Boulestreau. * Contributor(s): David Gilbert (for Object Refinery Limited); * * Changes * ------- * 29-Mar-2002 : Version 1 (AB); * 11-Oct-2002 : Fixed errors reported by Checkstyle (DG); * */package org.jfree.chart.demo;import java.lang.reflect.Array;import java.util.List;import java.util.Vector;import org.jfree.data.AbstractSeriesDataset;import org.jfree.data.XYDataset;import org.jfree.data.XisSymbolic;import org.jfree.data.YisSymbolic;/** * Random data for a symbolic plot demo. * * @author Anthony Boulestreau */public class SampleXYSymbolicDataset extends AbstractSeriesDataset implements XYDataset, XisSymbolic, YisSymbolic { /** Series names. */ private String[] seriesName; /** Items. */ private int[] item; /** A series index. */ private int serie; /** X values. */ private Integer[][] xValues; /** Y values. */ private Integer[][] yValues; /** X symbolic values. */ private String[] xSymbolicValues; /** Y symbolic values. */ private String[] ySymbolicValues; /** The dataset name. */ private String datasetName; /** * Creates a new dataset. * * @param datasetName the dataset name. * @param xValues the x values. * @param yValues the y values. * @param xSymbolicValues the x symbols. * @param ySymbolicValues the y symbols. * @param seriesName the series name. */ public SampleXYSymbolicDataset(final String datasetName, final Integer[][] xValues, final Integer[][] yValues, final String[] xSymbolicValues, final String[] ySymbolicValues, final String[] seriesName) { this.datasetName = datasetName; this.xValues = xValues; this.yValues = yValues; this.xSymbolicValues = xSymbolicValues; this.ySymbolicValues = ySymbolicValues; this.serie = xValues.length; this.item = new int[this.serie]; for (int i = 0; i < this.serie; i++) { this.item[i] = xValues[i].length; } this.seriesName = seriesName; } /** * Returns the x-value for the specified series and item. Series are * numbered 0, 1, ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * * @return the x-value for the specified series and item. */ public Number getXValue(final int series, final int item) { return this.xValues[series][item]; } /** * Returns the x-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The x-value. */ public double getX(int series, int item) { double result = Double.NaN; Number x = getXValue(series, item); if (x != null) { result = x.doubleValue(); } return result; } /** * Returns the y-value for the specified series and item. Series are * numbered 0, 1, ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * * @return the y-value for the specified series and item. */ public Number getYValue(final int series, final int item) { return this.yValues[series][item]; } /** * Returns the y-value (as a double primitive) for an item within a series. * * @param series the series (zero-based index). * @param item the item (zero-based index). * * @return The y-value. */ public double getY(int series, int item) { double result = Double.NaN; Number y = getYValue(series, item); if (y != null) { result = y.doubleValue(); } return result; } /** * Sets the x-value for the specified series and item with the specified * new <CODE>Number</CODE> value. Series are numbered 0, 1, ... * <P> * This method is used by combineXSymbolicDataset to modify the reference * to the symbolic value ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * @param newValue the value to set. */ public void setXValue(final int series, final int item, final Number newValue) { this.xValues[series][item] = (Integer) newValue; } /** * Sets the y-value for the specified series and item with the specified * new <CODE>Number</CODE> value. Series are numbered 0, 1, ... * <P> * This method is used by combineYSymbolicDataset to modify the reference * to the symbolic value ... * * @param series the index (zero-based) of the series. * @param item the index (zero-based) of the required item. * @param newValue the value to set. */ public void setYValue(final int series, final int item, final Number newValue) { this.yValues[series][item] = (Integer) newValue; } /** * Returns the number of series in the dataset. * * @return The number of series in the dataset. */ public int getSeriesCount() { return this.serie; } /** * Returns the name of the series. * * @param series the index (zero-based) of the series. * * @return the name of the series. */ public String getSeriesName(final int series) { if (this.seriesName != null) { return this.seriesName[series]; } else { return this.datasetName + series; } } /** * Returns the number of items in the specified series. * * @param series the index (zero-based) of the series. * @return the number of items in the specified series. */ public int getItemCount(final int series) { return this.item[series]; } /** * Returns the list of X symbolic values. * * @return array of symbolic value. */ public String[] getXSymbolicValues() {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -