當前位置: 首頁>>代碼示例>>Java>>正文


Java CategoryDataset類代碼示例

本文整理匯總了Java中org.jfree.data.category.CategoryDataset的典型用法代碼示例。如果您正苦於以下問題:Java CategoryDataset類的具體用法?Java CategoryDataset怎麽用?Java CategoryDataset使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


CategoryDataset類屬於org.jfree.data.category包,在下文中一共展示了CategoryDataset類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createCategoryDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Creates a {@link CategoryDataset} that contains a copy of the data in an
 * array (instances of <code>Double</code> are created to represent the 
 * data items).
 * <p>
 * Row and column keys are created by appending 0, 1, 2, ... to the 
 * supplied prefixes.
 *
 * @param rowKeyPrefix  the row key prefix.
 * @param columnKeyPrefix  the column key prefix.
 * @param data  the data.
 *
 * @return The dataset.
 */
public static CategoryDataset createCategoryDataset(String rowKeyPrefix,
                                                    String columnKeyPrefix,
                                                    double[][] data) {

    DefaultCategoryDataset result = new DefaultCategoryDataset();
    for (int r = 0; r < data.length; r++) {
        String rowKey = rowKeyPrefix + (r + 1);
        for (int c = 0; c < data[r].length; c++) {
            String columnKey = columnKeyPrefix + (c + 1);
            result.addValue(new Double(data[r][c]), rowKey, columnKey);
        }
    }
    return result;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:DatasetUtilities.java

示例2: testReplaceDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
                + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:StackedAreaChartTests.java

示例3: getDataSet

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
private static CategoryDataset getDataSet() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(100, "北京", "蘋果");
    dataset.addValue(100, "上海", "蘋果");
    dataset.addValue(100, "廣州", "蘋果");
    dataset.addValue(200, "北京", "梨子");
    dataset.addValue(200, "上海", "梨子");
    dataset.addValue(200, "廣州", "梨子");
    dataset.addValue(300, "北京", "葡萄");
    dataset.addValue(300, "上海", "葡萄");
    dataset.addValue(300, "廣州", "葡萄");
    dataset.addValue(400, "北京", "香蕉");
    dataset.addValue(400, "上海", "香蕉");
    dataset.addValue(400, "廣州", "香蕉");
    dataset.addValue(500, "北京", "荔枝");
    dataset.addValue(500, "上海", "荔枝");
    dataset.addValue(500, "廣州", "荔枝");
    return dataset;
}
 
開發者ID:leon66666,項目名稱:financehelper,代碼行數:20,代碼來源:BarChart.java

示例4: testReplaceDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Replaces the chart's dataset and then checks that the new dataset is OK.
 */
public void testReplaceDataset() {
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset(
            "S", "C", data);
    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
               + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:25,代碼來源:AreaChartTests.java

示例5: testReplaceDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Replaces the chart's dataset and then checks that the new dataset is OK.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    plot.setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = plot.getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
               + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:28,代碼來源:LineChart3DTests.java

示例6: readCategoryDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Reads a {@link CategoryDataset} from a CSV file or input source.
 * 
 * @param in  the input source.
 * 
 * @return a category dataset.
 * 
 * @throws IOException if there is an I/O problem.
 */
public CategoryDataset readCategoryDataset(Reader in) throws IOException {
    
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    BufferedReader reader = new BufferedReader(in);
    List columnKeys = null;
    int lineIndex = 0;
    String line = reader.readLine();
    while (line != null) {
        if (lineIndex == 0) {  // first line contains column keys
            columnKeys = extractColumnKeys(line);
        }
        else {  // remaining lines contain a row key and data values
            extractRowKeyAndData(line, dataset, columnKeys);
        }
        line = reader.readLine();
        lineIndex++;
    }
    return dataset;     
     
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:30,代碼來源:CSV.java

示例7: visualizarSeriesTiemposRescateVictPorRobots

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
public void  visualizarSeriesTiemposRescateVictPorRobots(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart(
     "Tiempos de Rescate de Victimas por cada robot ", // chart title
     "Robots en el entorno", // domain axis label
     "Tiempo milisegundos", // range axis label
     dataset, // data
     PlotOrientation.VERTICAL, // orientation
     true, // include legend
     true, // tooltips?
     false // URLs?
     );
     ChartPanel chartPanel = new ChartPanel(chart);
     chart.setBackgroundPaint(Color.white);
     CategoryPlot plot = chart.getCategoryPlot();
     plot.setBackgroundPaint(Color.lightGray);
     plot.setDomainGridlinePaint(Color.white);
     plot.setRangeGridlinePaint(Color.white);
     NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
     rangeAxis.setUpperMargin(0.15);
     CategoryItemRenderer renderer = plot.getRenderer();
     renderer.setItemLabelGenerator(new LabelGenerator(50.0));
     renderer.setItemLabelFont(new Font("Serif", Font.PLAIN, 8));
     renderer.setItemLabelsVisible(true);
     chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
     this.visualizar(chartPanel);
}
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:27,代碼來源:VisualizacionJfreechart.java

示例8: createLineChart3D

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Create a line chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createLineChart3D() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    // create the chart...
    return ChartFactory.createLineChart3D(
        "Line Chart",
        "Domain", "Range",
        dataset,
        PlotOrientation.HORIZONTAL,
        true,     // include legend
        true,
        true
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:LineChart3DTests.java

示例9: createItemArray

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Creates the array of items that can be passed to the 
 * {@link MessageFormat} class for creating labels.
 *
 * @param dataset  the dataset (<code>null</code> not permitted).
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 *
 * @return The items (never <code>null</code>).
 */
protected Object[] createItemArray(CategoryDataset dataset, 
                                   int row, int column) {
    Object[] result = new Object[4];
    result[0] = dataset.getRowKey(row).toString();
    result[1] = dataset.getColumnKey(column).toString();
    Number value = dataset.getValue(row, column);
    if (value != null) {
        if (this.numberFormat != null) {
            result[2] = this.numberFormat.format(value);  
        }
        else if (this.dateFormat != null) {
            result[2] = this.dateFormat.format(value);
        }
    }
    else {
        result[2] = this.nullValueString;   
    }
    if (value != null) {
        double total = DataUtilities.calculateColumnTotal(dataset, column);
        double percent = value.doubleValue() / total;
        result[3] = this.percentFormat.format(percent);
    }
   
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:36,代碼來源:AbstractCategoryItemLabelGenerator.java

示例10: createCategoryDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Creates a {@link CategoryDataset} by copying the data from the supplied {@link KeyedValues}
 * instance.
 *
 * @param rowKey  the row key (<code>null</code> not permitted).
 * @param rowData  the row data (<code>null</code> not permitted).
 *
 * @return A dataset.
 */
public static CategoryDataset createCategoryDataset(String rowKey, 
                                                    KeyedValues rowData) {

    if (rowKey == null) {
        throw new IllegalArgumentException("Null 'rowKey' argument.");
    }
    if (rowData == null) {
        throw new IllegalArgumentException("Null 'rowData' argument.");
    }
    DefaultCategoryDataset result = new DefaultCategoryDataset();
    for (int i = 0; i < rowData.getItemCount(); i++) {
        result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i));
    }
    return result;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:DatasetUtilities.java

示例11: testReplaceDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Replaces the dataset and checks that the data range is as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    this.chart.getCategoryPlot().setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = this.chart.getCategoryPlot().getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
               + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:BarChart3DTests.java

示例12: createBarChart3D

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return the chart.
 */
private static JFreeChart createBarChart3D() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", "C", data);

    // create the chart...
    return ChartFactory.createBarChart3D(
        "Bar Chart 3D",
        "Domain", 
        "Range",
        dataset,
        PlotOrientation.HORIZONTAL,
        true,  // include legend
        true,
        false
    );

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:29,代碼來源:BarChart3DTests.java

示例13: testReplaceDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Replaces the dataset and checks that it has changed as expected.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    this.chart.getCategoryPlot().setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = this.chart.getCategoryPlot().getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
                + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:StackedBarChartTests.java

示例14: testReplaceDataset

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Replaces the chart's dataset and then checks that the new dataset is OK.
 */
public void testReplaceDataset() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-30), new Integer(-20)},
         {new Integer(-10), new Integer(10)},
         {new Integer(20), new Integer(30)}};

    CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", "C", data);

    LocalListener l = new LocalListener();
    this.chart.addChangeListener(l);
    this.chart.getCategoryPlot().setDataset(newData);
    assertEquals(true, l.flag);
    ValueAxis axis = this.chart.getCategoryPlot().getRangeAxis();
    Range range = axis.getRange();
    assertTrue("Expecting the lower bound of the range to be around -30: "
               + range.getLowerBound(), range.getLowerBound() <= -30);
    assertTrue("Expecting the upper bound of the range to be around 30: "
               + range.getUpperBound(), range.getUpperBound() >= 30);

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:BarChartTests.java

示例15: isEmptyOrNull

import org.jfree.data.category.CategoryDataset; //導入依賴的package包/類
/**
 * Returns <code>true</code> if the dataset is empty (or <code>null</code>),
 * and <code>false</code> otherwise.
 *
 * @param dataset  the dataset (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean isEmptyOrNull(CategoryDataset dataset) {

    if (dataset == null) {
        return true;
    }

    int rowCount = dataset.getRowCount();
    int columnCount = dataset.getColumnCount();
    if (rowCount == 0 || columnCount == 0) {
        return true;
    }

    for (int r = 0; r < rowCount; r++) {
        for (int c = 0; c < columnCount; c++) {
            if (dataset.getValue(r, c) != null) {
                return false;
            }

        }
    }

    return true;

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:33,代碼來源:DatasetUtilities.java


注:本文中的org.jfree.data.category.CategoryDataset類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。