org.jfree.chart.renderer.category.BarRenderer3D Java Examples

The following examples show how to use org.jfree.chart.renderer.category.BarRenderer3D. 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: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createBar3DChart() throws JRException
{
	JFreeChart jfreeChart = super.createBar3DChart();
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	BarRenderer3D barRenderer3D = (BarRenderer3D)categoryPlot.getRenderer();

	barRenderer3D = new GradientBarRenderer3D(barRenderer3D);
	categoryPlot.setRenderer(barRenderer3D);

	barRenderer3D.setItemMargin(0);
	barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT);
	//categoryPlot.setOrientation(PlotOrientation.HORIZONTAL);

	barRenderer3D.setItemMargin(0);

	CategoryDataset categoryDataset = categoryPlot.getDataset();
	if (categoryDataset != null)
	{
		for (int i = 0; i < categoryDataset.getRowCount(); i++)
		{
			barRenderer3D.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
		}
	}
	return jfreeChart;
}
 
Example #3
Source File: AegeanChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createStackedBar3DChart() throws JRException
{
	JFreeChart jfreeChart = super.createStackedBar3DChart();
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	BarRenderer3D barRenderer3D = (BarRenderer3D)categoryPlot.getRenderer();
	barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT);
	barRenderer3D.setItemMargin(0);
	CategoryDataset categoryDataset = categoryPlot.getDataset();
	if(categoryDataset != null)
	{
		for(int i = 0; i < categoryDataset.getRowCount(); i++)
		{
			barRenderer3D.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
		}
	}
	return jfreeChart;
}
 
Example #4
Source File: AegeanChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createBar3DChart() throws JRException
{
	JFreeChart jfreeChart = super.createBar3DChart();
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	BarRenderer3D barRenderer3D = (BarRenderer3D)categoryPlot.getRenderer();
	barRenderer3D.setItemMargin(0);
	barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT);
	//categoryPlot.setOrientation(PlotOrientation.HORIZONTAL);
	CategoryDataset categoryDataset = categoryPlot.getDataset();
	if(categoryDataset != null)
	{
		for(int i = 0; i < categoryDataset.getRowCount(); i++)
		{
			barRenderer3D.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
		}
	}
	return jfreeChart;
}
 
Example #5
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 */
public StandardChartTheme(String name) {
    if (name == null) {
        throw new IllegalArgumentException("Null 'name' argument.");
    }
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = true;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
}
 
Example #6
Source File: BarRenderer3DTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode.
 */
public void testHashcode() {
    BarRenderer3D r1 = new BarRenderer3D();
    BarRenderer3D r2 = new BarRenderer3D();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #7
Source File: BarRenderer3DTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Two objects that are equal are required to return the same hashCode. 
 */
public void testHashcode() {
    BarRenderer3D r1 = new BarRenderer3D();
    BarRenderer3D r2 = new BarRenderer3D();
    assertTrue(r1.equals(r2));
    int h1 = r1.hashCode();
    int h2 = r2.hashCode();
    assertEquals(h1, h2);
}
 
Example #8
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
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: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
Example #11
Source File: ChartFactory.java    From SIMVA-SoS with Apache License 2.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 #12
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.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 #13
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
Example #14
Source File: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
protected JFreeChart createStackedBar3DChart() throws JRException
{
	JFreeChart jfreeChart = super.createStackedBar3DChart();
	CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
	BarRenderer3D barRenderer3D = (BarRenderer3D)categoryPlot.getRenderer();
	barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT);

	//CategoryDataset categoryDataset = categoryPlot.getDataset();
	barRenderer3D.setItemMargin(0);
	return jfreeChart;
}
 
Example #15
Source File: ChartFactory.java    From buffer_bci with GNU General Public License v3.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 #16
Source File: StandardChartTheme.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
Example #17
Source File: ChartFactory.java    From ccu-historian with GNU General Public License v3.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 #18
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
Example #19
Source File: ChartFactory.java    From openstock with GNU General Public License v3.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 #20
Source File: StandardChartTheme.java    From openstock with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a new default instance.
 *
 * @param name  the name of the theme (<code>null</code> not permitted).
 * @param shadow  a flag that controls whether a shadow generator is 
 *                included.
 *
 * @since 1.0.14
 */
public StandardChartTheme(String name, boolean shadow) {
    ParamChecks.nullNotPermitted(name, "name");
    this.name = name;
    this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20);
    this.largeFont = new Font("Tahoma", Font.BOLD, 14);
    this.regularFont = new Font("Tahoma", Font.PLAIN, 12);
    this.smallFont = new Font("Tahoma", Font.PLAIN, 10);
    this.titlePaint = Color.black;
    this.subtitlePaint = Color.black;
    this.legendBackgroundPaint = Color.white;
    this.legendItemPaint = Color.darkGray;
    this.chartBackgroundPaint = Color.white;
    this.drawingSupplier = new DefaultDrawingSupplier();
    this.plotBackgroundPaint = Color.lightGray;
    this.plotOutlinePaint = Color.black;
    this.labelLinkPaint = Color.black;
    this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE;
    this.axisOffset = new RectangleInsets(4, 4, 4, 4);
    this.domainGridlinePaint = Color.white;
    this.rangeGridlinePaint = Color.white;
    this.baselinePaint = Color.black;
    this.crosshairPaint = Color.blue;
    this.axisLabelPaint = Color.darkGray;
    this.tickLabelPaint = Color.darkGray;
    this.barPainter = new GradientBarPainter();
    this.xyBarPainter = new GradientXYBarPainter();
    this.shadowVisible = false;
    this.shadowPaint = Color.gray;
    this.itemLabelPaint = Color.black;
    this.thermometerPaint = Color.white;
    this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT;
    this.errorIndicatorPaint = Color.black;
    this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null;
}
 
Example #21
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 4 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) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    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);

    return chart;

}
 
Example #22
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");

    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }

    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);

    // now we handle some special cases - yes, UGLY code alert!

    // BarRenderer
    if (renderer instanceof BarRenderer) {
        BarRenderer br = (BarRenderer) renderer;
        br.setBarPainter(this.barPainter);
        br.setShadowVisible(this.shadowVisible);
        br.setShadowPaint(this.shadowPaint);
    }

    // BarRenderer3D
    if (renderer instanceof BarRenderer3D) {
        BarRenderer3D br3d = (BarRenderer3D) renderer;
        br3d.setWallPaint(this.wallPaint);
    }

    // LineRenderer3D
    if (renderer instanceof LineRenderer3D) {
        LineRenderer3D lr3d = (LineRenderer3D) renderer;
        lr3d.setWallPaint(this.wallPaint);
    }

    //  StatisticalBarRenderer
    if (renderer instanceof StatisticalBarRenderer) {
        StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer;
        sbr.setErrorIndicatorPaint(this.errorIndicatorPaint);
    }

    // MinMaxCategoryRenderer
    if (renderer instanceof MinMaxCategoryRenderer) {
        MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer;
        mmcr.setGroupPaint(this.errorIndicatorPaint);
    }
}
 
Example #23
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 4 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) {

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

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseURLGenerator(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);

    return chart;

}
 
Example #24
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) {
    if (renderer == null) {
        throw new IllegalArgumentException("Null 'renderer' argument.");
    }

    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }

    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);

    // now we handle some special cases - yes, UGLY code alert!

    // BarRenderer
    if (renderer instanceof BarRenderer) {
        BarRenderer br = (BarRenderer) renderer;
        br.setBarPainter(this.barPainter);
        br.setShadowVisible(this.shadowVisible);
        br.setShadowPaint(this.shadowPaint);
    }

    // BarRenderer3D
    if (renderer instanceof BarRenderer3D) {
        BarRenderer3D br3d = (BarRenderer3D) renderer;
        br3d.setWallPaint(this.wallPaint);
    }

    // LineRenderer3D
    if (renderer instanceof LineRenderer3D) {
        LineRenderer3D lr3d = (LineRenderer3D) renderer;
        lr3d.setWallPaint(this.wallPaint);
    }

    //  StatisticalBarRenderer
    if (renderer instanceof StatisticalBarRenderer) {
        StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer;
        sbr.setErrorIndicatorPaint(this.errorIndicatorPaint);
    }

    // MinMaxCategoryRenderer
    if (renderer instanceof MinMaxCategoryRenderer) {
        MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer;
        mmcr.setGroupPaint(this.errorIndicatorPaint);
    }
}
 
Example #25
Source File: StandardChartTheme.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");

    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }

    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);

    // now we handle some special cases - yes, UGLY code alert!

    // BarRenderer
    if (renderer instanceof BarRenderer) {
        BarRenderer br = (BarRenderer) renderer;
        br.setBarPainter(this.barPainter);
        br.setShadowVisible(this.shadowVisible);
        br.setShadowPaint(this.shadowPaint);
    }

    // BarRenderer3D
    if (renderer instanceof BarRenderer3D) {
        BarRenderer3D br3d = (BarRenderer3D) renderer;
        br3d.setWallPaint(this.wallPaint);
    }

    // LineRenderer3D
    if (renderer instanceof LineRenderer3D) {
        LineRenderer3D lr3d = (LineRenderer3D) renderer;
        lr3d.setWallPaint(this.wallPaint);
    }

    //  StatisticalBarRenderer
    if (renderer instanceof StatisticalBarRenderer) {
        StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer;
        sbr.setErrorIndicatorPaint(this.errorIndicatorPaint);
    }

    // MinMaxCategoryRenderer
    if (renderer instanceof MinMaxCategoryRenderer) {
        MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer;
        mmcr.setGroupPaint(this.errorIndicatorPaint);
    }
}
 
Example #26
Source File: BarRenderer3DTests.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check that this class implements PublicCloneable.
 */
public void testPublicCloneable() {
    BarRenderer3D r1 = new BarRenderer3D();
    assertTrue(r1 instanceof PublicCloneable);
}
 
Example #27
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");

    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }

    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);

    // now we handle some special cases - yes, UGLY code alert!

    // BarRenderer
    if (renderer instanceof BarRenderer) {
        BarRenderer br = (BarRenderer) renderer;
        br.setBarPainter(this.barPainter);
        br.setShadowVisible(this.shadowVisible);
        br.setShadowPaint(this.shadowPaint);
    }

    // BarRenderer3D
    if (renderer instanceof BarRenderer3D) {
        BarRenderer3D br3d = (BarRenderer3D) renderer;
        br3d.setWallPaint(this.wallPaint);
    }

    // LineRenderer3D
    if (renderer instanceof LineRenderer3D) {
        LineRenderer3D lr3d = (LineRenderer3D) renderer;
        lr3d.setWallPaint(this.wallPaint);
    }

    //  StatisticalBarRenderer
    if (renderer instanceof StatisticalBarRenderer) {
        StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer;
        sbr.setErrorIndicatorPaint(this.errorIndicatorPaint);
    }

    // MinMaxCategoryRenderer
    if (renderer instanceof MinMaxCategoryRenderer) {
        MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer;
        mmcr.setGroupPaint(this.errorIndicatorPaint);
    }
}
 
Example #28
Source File: StandardChartTheme.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");

    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }

    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);

    // now we handle some special cases - yes, UGLY code alert!

    // BarRenderer
    if (renderer instanceof BarRenderer) {
        BarRenderer br = (BarRenderer) renderer;
        br.setBarPainter(this.barPainter);
        br.setShadowVisible(this.shadowVisible);
        br.setShadowPaint(this.shadowPaint);
    }

    // BarRenderer3D
    if (renderer instanceof BarRenderer3D) {
        BarRenderer3D br3d = (BarRenderer3D) renderer;
        br3d.setWallPaint(this.wallPaint);
    }

    // LineRenderer3D
    if (renderer instanceof LineRenderer3D) {
        LineRenderer3D lr3d = (LineRenderer3D) renderer;
        lr3d.setWallPaint(this.wallPaint);
    }

    //  StatisticalBarRenderer
    if (renderer instanceof StatisticalBarRenderer) {
        StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer;
        sbr.setErrorIndicatorPaint(this.errorIndicatorPaint);
    }

    // MinMaxCategoryRenderer
    if (renderer instanceof MinMaxCategoryRenderer) {
        MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer;
        mmcr.setGroupPaint(this.errorIndicatorPaint);
    }
}
 
Example #29
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createBar3DChart() throws JRException 
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createBarChart3D(
					evaluateTextExpression(getChart().getTitleExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
					(CategoryDataset)getDataset(),
					getPlot().getOrientationValue().getOrientation(),
					isShowLegend(),
					true,
					false );

		configureChart(jfreeChart, getPlot());

		CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
		JRBar3DPlot bar3DPlot = (JRBar3DPlot)getPlot();

		BarRenderer3D barRenderer3D =
			new BarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);

		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		barRenderer3D.setBaseItemLabelsVisible( isShowLabels );
		if (isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();
			JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : new JRBaseFont(getChart(), null);
			barRenderer3D.setBaseItemLabelFont(getFontUtil().getAwtFont(font, getLocale()));
			if (itemLabel != null)
			{
				if (itemLabel.getColor() != null)
				{
					barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if (itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
					barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}

		categoryPlot.setRenderer(barRenderer3D);
		
		// Handle the axis formating for the category axis
		configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
				bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
				bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(),bar3DPlot.getCategoryAxisVerticalTickLabels(),
				bar3DPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression())
				);

		// Handle the axis formating for the value axis
		configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(),
				bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(),
				bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(),bar3DPlot.getValueAxisVerticalTickLabels(),
				bar3DPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(),
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())
				);
		
		return jfreeChart;
	}
 
Example #30
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createBar3DChart() throws JRException 
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createBarChart3D(
					evaluateTextExpression(getChart().getTitleExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
					(CategoryDataset)getDataset(),
					getPlot().getOrientationValue().getOrientation(),
					isShowLegend(),
					true,
					false );

		configureChart(jfreeChart, getPlot());

		CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
		JRBar3DPlot bar3DPlot = (JRBar3DPlot)getPlot();

		BarRenderer3D barRenderer3D =
			new BarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);

		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		barRenderer3D.setBaseItemLabelsVisible( isShowLabels );
		if (isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();
			Integer baseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
			JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
			barRenderer3D.setBaseItemLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));
			
			if (itemLabel != null)
			{
				if (itemLabel.getColor() != null)
				{
					barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if (itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
					barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}

		categoryPlot.setRenderer(barRenderer3D);
		
		// Handle the axis formating for the category axis
		configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
				bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
				bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(),
				bar3DPlot.getOwnCategoryAxisLineColor(), false,
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression()));


		// Handle the axis formating for the value axis
		configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(),
				bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(),
				bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(), bar3DPlot.getValueAxisVerticalTickLabels(),
				bar3DPlot.getOwnValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression()));
		
		return jfreeChart;
	}