org.jfree.chart.urls.StandardCategoryURLGenerator Java Examples

The following examples show how to use org.jfree.chart.urls.StandardCategoryURLGenerator. 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: StandardCategoryURLGeneratorTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Some tests for the generateURL() method.
 */
public void testGenerateURL() {
    StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(1.0, "R1", "C1");
    dataset.addValue(2.0, "R2", "C2");
    dataset.addValue(3.0, "R&", "C&");
    assertEquals("index.html?series=R1&category=C1",
            g1.generateURL(dataset, 0, 0));
    assertEquals("index.html?series=R1&category=C2",
            g1.generateURL(dataset, 0, 1));
    assertEquals("index.html?series=R2&category=C2",
            g1.generateURL(dataset, 1, 1));
    assertEquals("index.html?series=R%26&category=C%26",
            g1.generateURL(dataset, 2, 2));
}
 
Example #2
Source File: LineChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false);
    assertTrue(url2 == url1);
}
 
Example #3
Source File: ChartFactory.java    From astor with GNU General Public License v2.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.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 #4
Source File: LineChartTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertSame(url2, url1);
}
 
Example #5
Source File: ChartFactory.java    From ECG-Viewer 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 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 #6
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a Gantt chart using the supplied attributes plus default values
 * where required.  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 DateAxis} as the range axis, and a
 * {@link GanttRenderer} 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 dateAxisLabel  the label for the date 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.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A Gantt chart.
 */
public static JFreeChart createGanttChart(String title,
        String categoryAxisLabel, String dateAxisLabel,
        IntervalCategoryDataset dataset, boolean legend, boolean tooltips,
        boolean urls) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    DateAxis dateAxis = new DateAxis(dateAxisLabel);

    CategoryItemRenderer renderer = new GanttRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new IntervalCategoryToolTipGenerator(
                "{3} - {4}", DateFormat.getDateInstance()));
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(
                new StandardCategoryURLGenerator());
    }

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

}
 
Example #7
Source File: ChartFactory.java    From ECG-Viewer 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) {

    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 #8
Source File: LineChart3DTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false);
    assertTrue(url2 == url1);
}
 
Example #9
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 5 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 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 bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(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);

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

    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.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

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

}
 
Example #10
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.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 #11
Source File: BarChart3DTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertSame(url2, url1);
}
 
Example #12
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 5 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 orientation  the plot orientation (<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 An area chart.
 */
public static JFreeChart createAreaChart(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);

    AreaRenderer renderer = new AreaRenderer();
    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 #13
Source File: WaterfallChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #14
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.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 #15
Source File: AreaChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #16
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.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 #17
Source File: AreaChartTest.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertSame(url2, url1);
}
 
Example #18
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 5 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 orientation  the plot orientation (<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 An area chart.
 */
public static JFreeChart createAreaChart(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);
    categoryAxis.setCategoryMargin(0.0);

    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    AreaRenderer renderer = new AreaRenderer();
    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 #19
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 #20
Source File: StackedBarChart3DTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false);
    assertTrue(url2 == url1);
}
 
Example #21
Source File: StackedBarChartTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getURLGenerator(0, 0, false);
    assertTrue(url2 == url1);
}
 
Example #22
Source File: WaterfallChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #23
Source File: StackedBarChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #24
Source File: LineChart3DTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertSame(url2, url1);
}
 
Example #25
Source File: BarChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #26
Source File: AbstractCategoryItemRendererTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
@Test
public void testEquals_ObjectList3() {
    BarRenderer r1 = new BarRenderer();
    r1.setSeriesItemURLGenerator(0, new StandardCategoryURLGenerator());
    BarRenderer r2 = new BarRenderer();
    r2.setSeriesItemURLGenerator(0, new StandardCategoryURLGenerator());
    assertEquals(r1, r2);
    r2.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator());
    assertNotEquals(r1, r2);
}
 
Example #27
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a Gantt chart using the supplied attributes plus default values 
 * where required.  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 DateAxis} as the range axis, and a 
 * {@link GanttRenderer} 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 dateAxisLabel  the label for the date 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.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A Gantt chart.
 */
public static JFreeChart createGanttChart(String title,
                                          String categoryAxisLabel,
                                          String dateAxisLabel,
                                          IntervalCategoryDataset dataset,
                                          boolean legend,
                                          boolean tooltips,
                                          boolean urls) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    DateAxis dateAxis = new DateAxis(dateAxisLabel);

    CategoryItemRenderer renderer = new GanttRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new IntervalCategoryToolTipGenerator(
                "{3} - {4}", DateFormat.getDateInstance()));
    }
    if (urls) {
        renderer.setBaseURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, 
            renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);

    return chart;

}
 
Example #28
Source File: StackedAreaChartTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #29
Source File: StackedBarChart3DTest.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertTrue(url2 == url1);
}
 
Example #30
Source File: AreaChartTest.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Check that setting a URL generator for a series does override the
 * default generator.
 */
@Test
public void testSetSeriesURLGenerator() {
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    StandardCategoryURLGenerator url1
            = new StandardCategoryURLGenerator();
    renderer.setSeriesItemURLGenerator(0, url1);
    CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
    assertSame(url2, url1);
}