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

📄 samplexysymbolicdataset.java

📁 大家打开看看啊, 很有用的东西
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* ======================================
 * JFreeChart : a free Java chart library
 * ======================================
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 * Project Lead:  David Gilbert (david.gilbert@object-refinery.com);
 *
 * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
 *
 * 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.
 *
 * ----------------------------
 * SampleXYSymbolicDataset.java
 * ----------------------------
 * (C) Copyright 2000-2003, 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(String datasetName,
                                   Integer[][] xValues,
                                   Integer[][] yValues,
                                   String[] xSymbolicValues,
                                   String[] ySymbolicValues,
                                   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[serie];
        for (int i = 0; i < 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(int series, int item) {
        return xValues[series][item];
    }

    /**
     * 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(int series, int item) {
        return yValues[series][item];
    }

    /**
     * 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(int series, int item, Number newValue) {
        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(int series, int item, Number newValue) {
        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 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(int series) {
        if (seriesName != null) {
            return seriesName[series];
        }
        else {
            return 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(int series) {
        return item[series];
    }

    /**
     * Returns the list of X symbolic values.
     *
     * @return array of symbolic value.
     */
    public String[] getXSymbolicValues() {
        return xSymbolicValues;
    }

    /**
     * Returns the list of Y symbolic values.
     *
     * @return array of symbolic value.
     */
    public String[] getYSymbolicValues() {
        return ySymbolicValues;
    }

    /**
     * Sets the list of X symbolic values.
     *
     * @param sValues the new list of symbolic value.
     */

⌨️ 快捷键说明

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