org.jfree.chart.labels.StandardCategoryToolTipGenerator Java Examples

The following examples show how to use org.jfree.chart.labels.StandardCategoryToolTipGenerator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a bar chart with a 3D effect. The chart object returned by this
 * method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link BarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the 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 bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);
    BarRenderer3D renderer = new BarRenderer3D();
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setForegroundAlpha(0.75f);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #2
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates an area chart with default settings.  The chart object returned
 * by this method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and an {@link AreaRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the 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 An area chart.
 */
public static JFreeChart createAreaChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    AreaRenderer renderer = new AreaRenderer();
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #3
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a line chart with default settings.  The chart object returned
 * by this method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link LineAndShapeRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the 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 line chart.
 */
public static JFreeChart createLineChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #4
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a bar chart.  The chart object returned by this method uses a
 * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
 * for the domain axis, a {@link NumberAxis} as the range axis, and a
 * {@link BarRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the 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 bar chart.
 */
public static JFreeChart createBarChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    BarRenderer renderer = new BarRenderer();
    ItemLabelPosition position1 = new ItemLabelPosition(
            ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
    renderer.setBasePositiveItemLabelPosition(position1);
    ItemLabelPosition position2 = new ItemLabelPosition(
            ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
    renderer.setBaseNegativeItemLabelPosition(position2);
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #5
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a stacked bar chart with default settings.  The chart object
 * returned by this method uses a {@link CategoryPlot} instance as the
 * plot, with a {@link CategoryAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}
 * as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param domainAxisLabel  the label for the category axis
 *                         (<code>null</code> permitted).
 * @param rangeAxisLabel  the 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 stacked bar chart.
 */
public static JFreeChart createStackedBarChart(String title,
        String domainAxisLabel, String rangeAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
    ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);
    StackedBarRenderer renderer = new StackedBarRenderer();
    renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #6
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a line chart with default settings. The chart object returned by
 * this method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link LineRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the 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 line chart.
 */
public static JFreeChart createLineChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, boolean legend) {

    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    LineRenderer3D renderer = new LineRenderer3D();
    renderer.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator());
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #7
Source File: IntervalCategoryToolTipGeneratorTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that the subclass is not equal to an instance of the superclass.
 */
public void testEquals2() {
    IntervalCategoryToolTipGenerator g1
            = new IntervalCategoryToolTipGenerator();
    StandardCategoryToolTipGenerator g2
            = new StandardCategoryToolTipGenerator(
            IntervalCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING,
            NumberFormat.getInstance());
    assertFalse(g1.equals(g2));
}
 
Example #8
Source File: BarChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertTrue(tt2 == tt);
}
 
Example #9
Source File: StandardCategoryToolTipGeneratorTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug 1481087.
 */
public void testEquals1481087() {
    StandardCategoryToolTipGenerator g1 
        = new StandardCategoryToolTipGenerator("{0}", 
                new DecimalFormat("0.00"));
    StandardCategoryItemLabelGenerator g2 
        = new StandardCategoryItemLabelGenerator("{0}", 
                new DecimalFormat("0.00"));
    assertFalse(g1.equals(g2));
}
 
Example #10
Source File: BarChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0,
            false);
    assertTrue(tt2 == tt);
}
 
Example #11
Source File: StackedBarChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertTrue(tt2 == tt);
}
 
Example #12
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a stacked bar chart with default settings.  The chart object 
 * returned by this method uses a {@link CategoryPlot} instance as the
 * plot, with a {@link CategoryAxis} for the domain axis, a 
 * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer} 
 * as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param domainAxisLabel  the label for the category axis 
 *                         (<code>null</code> permitted).
 * @param rangeAxisLabel  the label for the value axis 
 *                        (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation of the chart (horizontal or 
 *                     vertical) (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked bar chart.
 */
public static JFreeChart createStackedBarChart(String title,
                                               String domainAxisLabel,
                                               String rangeAxisLabel,
                                               CategoryDataset dataset,
                                               PlotOrientation orientation,
                                               boolean legend,
                                               boolean tooltips,
                                               boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }

    CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
    ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);

    StackedBarRenderer renderer = new StackedBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
            renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);

    return chart;

}
 
Example #13
Source File: LineChart3DTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertSame(tt2, tt);
}
 
Example #14
Source File: StandardCategoryItemLabelGeneratorTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * A test for bug 1481087.
 */
public void testEquals1481087() {
    StandardCategoryItemLabelGenerator g1
            = new StandardCategoryItemLabelGenerator("{0}",
            new DecimalFormat("0.00"));
    StandardCategoryToolTipGenerator g2
            = new StandardCategoryToolTipGenerator("{0}",
            new DecimalFormat("0.00"));
    assertFalse(g1.equals(g2));
}
 
Example #15
Source File: StackedBarChart3DTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertTrue(tt2 == tt);
}
 
Example #16
Source File: CombinedRangeCategoryPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a sample plot.
 *
 * @return A plot.
 */
private CombinedRangeCategoryPlot createPlot() {
    CategoryDataset dataset1 = createDataset1();
    CategoryAxis catAxis1 = new CategoryAxis("Category");
    LineAndShapeRenderer renderer1 = new LineAndShapeRenderer();
    renderer1.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator());
    CategoryPlot subplot1 = new CategoryPlot(dataset1, catAxis1, null,
            renderer1);
    subplot1.setDomainGridlinesVisible(true);

    CategoryDataset dataset2 = createDataset2();
    CategoryAxis catAxis2 = new CategoryAxis("Category");
    BarRenderer renderer2 = new BarRenderer();
    renderer2.setBaseToolTipGenerator(
            new StandardCategoryToolTipGenerator());
    CategoryPlot subplot2 = new CategoryPlot(dataset2, catAxis2, null,
            renderer2);
    subplot2.setDomainGridlinesVisible(true);

    NumberAxis rangeAxis = new NumberAxis("Value");
    CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot(
            rangeAxis);
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);
    return plot;
}
 
Example #17
Source File: GanttChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0,
            false);
    assertTrue(tt2 == tt);
}
 
Example #18
Source File: LeitnerStatePanel.java    From opencards with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void reconfigureColorEncoding() {
    StackedBarRenderer renderer = new StackedBarRenderer();
    renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL));

    renderer.setItemMargin(0.0);

    int barIndex = 0;

    //blue
    Paint p1 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF));
    renderer.setSeriesPaint(barIndex, p1);
    renderer.setSeriesToolTipGenerator(barIndex, new StandardCategoryToolTipGenerator());

    //green
    barIndex++;
    Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88));
    renderer.setSeriesPaint(barIndex, p3);
    renderer.setSeriesToolTipGenerator(barIndex, new StandardCategoryToolTipGenerator());

    if (hightlightItem != null) {
        //red
        barIndex++;
        Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88));
        renderer.setSeriesPaint(barIndex, p2);
        renderer.setSeriesToolTipGenerator(barIndex, new StandardCategoryToolTipGenerator());
    }

    plot.setRenderer(renderer);
}
 
Example #19
Source File: CombinedDomainCategoryPlotTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * 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;

}
 
Example #20
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a stacked bar chart with default settings.  The chart object
 * returned by this method uses a {@link CategoryPlot} instance as the
 * plot, with a {@link CategoryAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}
 * as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param domainAxisLabel  the label for the category axis
 *                         (<code>null</code> permitted).
 * @param rangeAxisLabel  the label for the value axis
 *                        (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation of the chart (horizontal or
 *                     vertical) (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked bar chart.
 */
public static JFreeChart createStackedBarChart(String title,
        String domainAxisLabel, String rangeAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");

    CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
    ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);

    StackedBarRenderer renderer = new StackedBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #21
Source File: AbstractCategoryItemRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
@Test
public void testEquals_ObjectList2() {
    BarRenderer r1 = new BarRenderer();
    r1.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    BarRenderer r2 = new BarRenderer();
    r2.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator());
    assertEquals(r1, r2);
    r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator("X", new DecimalFormat("0.0")));
    assertNotEquals(r1, r2);
}
 
Example #22
Source File: StackedAreaChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
        = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertTrue(tt2 == tt);
}
 
Example #23
Source File: StackedBarChart3DTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertTrue(tt2 == tt);
}
 
Example #24
Source File: AreaChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a tool tip generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesToolTipGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryToolTipGenerator tt
            = new StandardCategoryToolTipGenerator();
    renderer.setSeriesToolTipGenerator(0, tt);
    CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
    assertSame(tt2, tt);
}
 
Example #25
Source File: CombinedCategoryPlotDemo1.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a chart.
 *
 * @return A chart.
 */
private static JFreeChart createChart() {

    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");
    CombinedCategoryPlot plot = new CombinedCategoryPlot(
            domainAxis, new NumberAxis("Range"));
    plot.add(subplot1, 2);
    plot.add(subplot2, 1);

    JFreeChart result = new JFreeChart(
            "Combined Domain Category Plot Demo",
            new Font("SansSerif", Font.BOLD, 12), plot, true);
    return result;

}
 
Example #26
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a line chart with default settings. The chart object returned by
 * this method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link LineRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the chart orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A line chart.
 */
public static JFreeChart createLineChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    LineRenderer3D renderer = new LineRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #27
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a line chart with default settings.  The chart object returned
 * by this method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the
 * range axis, and a {@link LineAndShapeRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the chart orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A line chart.
 */
public static JFreeChart createLineChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #28
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a stacked area chart with default settings.  The chart object
 * returned by this method uses a {@link CategoryPlot} instance as the
 * plot, with a {@link CategoryAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer}
 * as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked area chart.
 */
public static JFreeChart createStackedAreaChart(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    StackedAreaRenderer renderer = new StackedAreaRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #29
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a line chart with default settings.  The chart object returned 
 * by this method uses a {@link CategoryPlot} instance as the plot, with a 
 * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the 
 * range axis, and a {@link LineAndShapeRenderer} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis 
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code> 
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the chart orientation (horizontal or vertical) 
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A line chart.
 */
public static JFreeChart createLineChart(String title,
                                         String categoryAxisLabel,
                                         String valueAxisLabel,
                                         CategoryDataset dataset,
                                         PlotOrientation orientation,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseURLGenerator(new StandardCategoryURLGenerator());
    }
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, 
            renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);

    return chart;

}
 
Example #30
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a stacked bar chart with a 3D effect and default settings. The
 * chart object returned by this method uses a {@link CategoryPlot}
 * instance as the plot, with a {@link CategoryAxis3D} for the domain axis,
 * a {@link NumberAxis3D} as the range axis, and a
 * {@link StackedBarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked bar chart with a 3D effect.
 */
public static JFreeChart createStackedBarChart3D(String title,
        String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    ParamChecks.nullNotPermitted(orientation, "orientation");
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    // create the renderer...
    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

    // create the plot...
    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
            renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }

    // create the chart...
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}