Search in sources :

Example 16 with StandardCategoryURLGenerator

use of org.jfree.chart.urls.StandardCategoryURLGenerator in project SIMVA-SoS by SESoS.

the class ChartFactory method createBarChart3D.

/**
 * 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;
}
Also used : CategoryAxis3D(org.jfree.chart.axis.CategoryAxis3D) StackedBarRenderer3D(org.jfree.chart.renderer.category.StackedBarRenderer3D) BarRenderer3D(org.jfree.chart.renderer.category.BarRenderer3D) CategoryAxis(org.jfree.chart.axis.CategoryAxis) StandardCategoryToolTipGenerator(org.jfree.chart.labels.StandardCategoryToolTipGenerator) ValueAxis(org.jfree.chart.axis.ValueAxis) NumberAxis3D(org.jfree.chart.axis.NumberAxis3D) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 17 with StandardCategoryURLGenerator

use of org.jfree.chart.urls.StandardCategoryURLGenerator in project SIMVA-SoS by SESoS.

the class ChartFactory method createLineChart.

/**
 * 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;
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) StandardCategoryToolTipGenerator(org.jfree.chart.labels.StandardCategoryToolTipGenerator) ValueAxis(org.jfree.chart.axis.ValueAxis) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 18 with StandardCategoryURLGenerator

use of org.jfree.chart.urls.StandardCategoryURLGenerator in project SIMVA-SoS by SESoS.

the class WaterfallChartTest method testSetSeriesURLGenerator.

/**
 * 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);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryURLGenerator(org.jfree.chart.urls.CategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Test(org.junit.Test)

Example 19 with StandardCategoryURLGenerator

use of org.jfree.chart.urls.StandardCategoryURLGenerator in project SIMVA-SoS by SESoS.

the class LineChart3DTest method testSetSeriesURLGenerator.

/**
 * 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);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryURLGenerator(org.jfree.chart.urls.CategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Test(org.junit.Test)

Example 20 with StandardCategoryURLGenerator

use of org.jfree.chart.urls.StandardCategoryURLGenerator in project SIMVA-SoS by SESoS.

the class LineChartTest method testSetSeriesURLGenerator.

/**
 * 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);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryURLGenerator(org.jfree.chart.urls.CategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) StandardCategoryURLGenerator(org.jfree.chart.urls.StandardCategoryURLGenerator) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Test(org.junit.Test)

Aggregations

StandardCategoryURLGenerator (org.jfree.chart.urls.StandardCategoryURLGenerator)27 CategoryPlot (org.jfree.chart.plot.CategoryPlot)24 StandardCategoryToolTipGenerator (org.jfree.chart.labels.StandardCategoryToolTipGenerator)15 CategoryAxis (org.jfree.chart.axis.CategoryAxis)14 ValueAxis (org.jfree.chart.axis.ValueAxis)13 Test (org.junit.Test)13 CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)12 NumberAxis (org.jfree.chart.axis.NumberAxis)10 CategoryURLGenerator (org.jfree.chart.urls.CategoryURLGenerator)10 JFreeChart (org.jfree.chart.JFreeChart)4 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)4 StackedBarRenderer (org.jfree.chart.renderer.category.StackedBarRenderer)4 StackedBarRenderer3D (org.jfree.chart.renderer.category.StackedBarRenderer3D)4 CategoryAxis3D (org.jfree.chart.axis.CategoryAxis3D)3 NumberAxis3D (org.jfree.chart.axis.NumberAxis3D)3 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)3 BarRenderer3D (org.jfree.chart.renderer.category.BarRenderer3D)3 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)3 LineRenderer3D (org.jfree.chart.renderer.category.LineRenderer3D)3 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)3