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


Java CategoryPlot類代碼示例

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


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

示例1: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //導入依賴的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);
    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,代碼來源:BarChart3DTests.java

示例2: test1654215

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * A test for bug 1654215 (where a renderer is added to the plot without
 * a corresponding dataset and it throws an exception at drawing time).
 */
public void test1654215() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y",
            dataset, PlotOrientation.VERTICAL, true, false, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRenderer(1, new LineAndShapeRenderer());
    boolean success = false;
    try {
        BufferedImage image = new BufferedImage(200 , 100, 
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = image.createGraphics();
        chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null);
        g2.dispose();
        success = true;
    }
    catch (Exception e) {
        e.printStackTrace();
        success = false;
    }
    assertTrue(success);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:26,代碼來源:CategoryPlotTests.java

示例3: initialise

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Initialises the renderer and returns a state object that will be passed 
 * to subsequent calls to the drawItem method.  This method gets called 
 * once at the start of the process of drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 * 
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2,
                                            Rectangle2D dataArea,
                                            CategoryPlot plot,
                                            int rendererIndex,
                                            PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, 
            rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

    return state;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:34,代碼來源:BarRenderer.java

示例4: createChart

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
     * Creates a sample chart.
     *
     * @param dataset  the dataset.
     *
     * @return The chart.
     */
    private static JFreeChart createChart(CategoryDataset dataset) {
        JFreeChart chart = ChartFactory.createBarChart(
            "Performance: JFreeSVG vs Batik", null /* x-axis label*/, 
                "Milliseconds" /* y-axis label */, dataset, PlotOrientation.HORIZONTAL,false,false,false);
        chart.addSubtitle(new TextTitle("Time to generate 1000 charts in SVG " 
                + "format (lower bars = better performance)"));
        chart.setBackgroundPaint(Color.white);
        CategoryPlot plot = (CategoryPlot) chart.getPlot();

        // ******************************************************************
        //  More than 150 demo applications are included with the JFreeChart
        //  Developer Guide...for more information, see:
        //
        //  >   http://www.object-refinery.com/jfreechart/guide.html
        //
        // ******************************************************************

        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setDrawBarOutline(false);
//        chart.getLegend().setFrame(BlockBorder.NONE);
        return chart;
    }
 
開發者ID:Yarichi,項目名稱:Proyecto-DASI,代碼行數:32,代碼來源:BarChartDemo1.java

示例5: createBoxAndWhiskerChart

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Creates and returns a default instance of a box and whisker chart
 * based on data from a {@link BoxAndWhiskerCategoryDataset}.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  a label for the category axis 
 *     (<code>null</code> permitted).
 * @param valueAxisLabel  a label for the value axis (<code>null</code> 
 *     permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 *
 * @return A box and whisker chart.
 * 
 * @since 1.0.4
 */
public static JFreeChart createBoxAndWhiskerChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        BoxAndWhiskerCategoryDataset dataset, boolean legend) {
    
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
       
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
            renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 
            legend);
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:33,代碼來源:ChartFactory.java

示例6: visualizarSeriesTiemposRescateVictPorRobots

import org.jfree.chart.plot.CategoryPlot; //導入依賴的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

示例7: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //導入依賴的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

示例8: getDrawingSupplier

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Returns the drawing supplier from the plot.
 *
 * @return The drawing supplier (possibly <code>null</code>).
 */
public DrawingSupplier getDrawingSupplier() {
    DrawingSupplier result = null;
    CategoryPlot cp = getPlot();
    if (cp != null) {
        result = cp.getDrawingSupplier();
    }
    return result;
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:14,代碼來源:AbstractCategoryItemRenderer.java

示例9: drawItem

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Draws the bar for one item in the dataset.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the plot area.
 * @param plot  the plot.
 * @param domainAxis  the domain (category) axis.
 * @param rangeAxis  the range (value) axis.
 * @param data  the data.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 * @param pass  the pass index.
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset data,
                     int row,
                     int column,
                     int pass) {

    PlotOrientation orientation = plot.getOrientation();
    if (orientation == PlotOrientation.HORIZONTAL) {
        drawHorizontalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, 
            data, row, column);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, 
            data, row, column);
    }

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

示例10: testReplaceDataset

import org.jfree.chart.plot.CategoryPlot; //導入依賴的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,代碼來源:StackedBarChartTests.java

示例11: testListenersWithCategoryPlot

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Checks that a CategoryPlot deregisters listeners when clearing markers.
 */
public void testListenersWithCategoryPlot() {
    CategoryPlot plot = new CategoryPlot();
    CategoryMarker marker1 = new CategoryMarker("X");
    ValueMarker marker2 = new ValueMarker(1.0);
    plot.addDomainMarker(marker1);
    plot.addRangeMarker(marker2);
    EventListener[] listeners1 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners1).contains(plot));
    EventListener[] listeners2 = marker1.getListeners(
            MarkerChangeListener.class);
    assertTrue(Arrays.asList(listeners2).contains(plot));
    plot.clearDomainMarkers();
    plot.clearRangeMarkers();
    listeners1 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners1).contains(plot));
    listeners2 = marker1.getListeners(MarkerChangeListener.class);
    assertFalse(Arrays.asList(listeners2).contains(plot));
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:23,代碼來源:MarkerTests.java

示例12: calculateItemWidth

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Calculates the bar width and stores it in the renderer state.
 * 
 * @param plot  the plot.
 * @param dataArea  the data area.
 * @param rendererIndex  the renderer index.
 * @param state  the renderer state.
 */
protected void calculateItemWidth(CategoryPlot plot, 
                                  Rectangle2D dataArea, 
                                  int rendererIndex,
                                  CategoryItemRendererState state) {
                                     
    CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex);
    CategoryDataset dataset = plot.getDataset(rendererIndex);
    if (dataset != null) {
        int columns = dataset.getColumnCount();
        int rows = dataset.getRowCount();
        double space = 0.0;
        PlotOrientation orientation = plot.getOrientation();
        if (orientation == PlotOrientation.HORIZONTAL) {
            space = dataArea.getHeight();
        }
        else if (orientation == PlotOrientation.VERTICAL) {
            space = dataArea.getWidth();
        }
        double maxWidth = space * getMaxItemWidth();
        double categoryMargin = 0.0;
        double currentItemMargin = 0.0;
        if (columns > 1) {
            categoryMargin = domainAxis.getCategoryMargin();
        }
        if (rows > 1) {
            currentItemMargin = getItemMargin();
        }
        double used = space * (1 - domainAxis.getLowerMargin() - domainAxis.getUpperMargin()
                                 - categoryMargin - currentItemMargin);
        if ((rows * columns) > 0) {
            state.setBarWidth(Math.min(used / (rows * columns), maxWidth));
        }
        else {
            state.setBarWidth(Math.min(used, maxWidth));
        }
    }
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:46,代碼來源:LevelRenderer.java

示例13: initialise

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Initialises the renderer and returns a state object that will be passed to subsequent calls 
 * to the drawItem method.  This method gets called once at the start of the process of 
 * drawing a chart.
 *
 * @param g2  the graphics device.
 * @param dataArea  the area in which the data is to be plotted.
 * @param plot  the plot.
 * @param rendererIndex  the renderer index.
 * @param info  collects chart rendering information for return to caller.
 * 
 * @return The renderer state.
 */
public CategoryItemRendererState initialise(Graphics2D g2,
                                            Rectangle2D dataArea,
                                            CategoryPlot plot,
                                            int rendererIndex,
                                            PlotRenderingInfo info) {

    CategoryItemRendererState state = super.initialise(g2, dataArea, plot, rendererIndex, info);

    // get the clipping values...
    ValueAxis rangeAxis = getRangeAxis(plot, rendererIndex);
    this.lowerClip = rangeAxis.getRange().getLowerBound();
    this.upperClip = rangeAxis.getRange().getUpperBound();

    // calculate the bar width
    calculateBarWidth(plot, dataArea, rendererIndex, state);

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

示例14: drawItem

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Draws the bar for one item in the dataset.
 *
 * @param g2  the graphics device.
 * @param state  the renderer state.
 * @param dataArea  the plot area.
 * @param plot  the plot.
 * @param domainAxis  the domain (category) axis.
 * @param rangeAxis  the range (value) axis.
 * @param data  the data.
 * @param row  the row index (zero-based).
 * @param column  the column index (zero-based).
 */
public void drawItem(Graphics2D g2,
                     CategoryItemRendererState state,
                     Rectangle2D dataArea,
                     CategoryPlot plot,
                     CategoryAxis domainAxis,
                     ValueAxis rangeAxis,
                     CategoryDataset data,
                     int row,
                     int column) {

    PlotOrientation orientation = plot.getOrientation();
    if (orientation == PlotOrientation.HORIZONTAL) {
        drawHorizontalItem(g2, state, dataArea,
                           plot, domainAxis, rangeAxis, data, row, column);
    }
    else if (orientation == PlotOrientation.VERTICAL) {
        drawVerticalItem(g2, state, dataArea,
                         plot, domainAxis, rangeAxis, data, row, column);
    }

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

示例15: createPlot

import org.jfree.chart.plot.CategoryPlot; //導入依賴的package包/類
/**
 * Creates a sample plot.
 * 
 * @return A sample plot.
 */
private CombinedDomainCategoryPlot createPlot() {
    
    CategoryDataset dataset1 = createDataset1();
    NumberAxis rangeAxis1 = new NumberAxis("Value");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot1 = new CategoryPlot(dataset1, null, rangeAxis1, renderer1);
    subplot1.setDomainGridlinesVisible(true);
    
    CategoryDataset dataset2 = createDataset2();
    NumberAxis rangeAxis2 = new NumberAxis("Value");
    rangeAxis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot2 = new CategoryPlot(dataset2, null, rangeAxis2, renderer2);
    subplot2.setDomainGridlinesVisible(true);

    CategoryAxis domainAxis = new CategoryAxis("Category");
    CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(domainAxis);
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);
    return plot;
    
}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:31,代碼來源:CombinedDomainCategoryPlotTests.java


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