Example usage for org.jfree.eastwood GCategoryPlot GCategoryPlot

List of usage examples for org.jfree.eastwood GCategoryPlot GCategoryPlot

Introduction

In this page you can find the example usage for org.jfree.eastwood GCategoryPlot GCategoryPlot.

Prototype

public GCategoryPlot() 

Source Link

Document

Default constructor.

Usage

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a bar chart with the specified orientation and using the
 * specified renderer./*from w w w . j a v  a 2s  .  c om*/
 *
 * @param orientation  the plot orientation.
 * @param renderer     the renderer.
 *
 * @return A bar chart.
 */
private static JFreeChart createBarChart(PlotOrientation orientation, BarRenderer renderer) {
    GCategoryPlot plot = new GCategoryPlot();
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(null);
    plot.setRenderer(renderer);
    StandardBarPainter bp = new StandardBarPainter();
    renderer.setBarPainter(bp);
    renderer.setShadowVisible(false);
    renderer.setBasePaint(new Color(0xFFCC33));
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelGenerator(new GCategoryPlot.LabelGenerator());
    renderer.setItemLabelPaint(new Color(0x333435));
    renderer.setDrawBarOutline(false);
    renderer.setItemMargin(0.07);

    if (orientation == PlotOrientation.HORIZONTAL) {
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_RIGHT));
    } else {
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
    }

    GCategoryAxis xAxis = new GCategoryAxis();
    xAxis.setAxisLineVisible(true);
    xAxis.setTickLabelsVisible(false);
    xAxis.setMaximumCategoryLabelLines(5);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setAxisLineVisible(true);
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a bar chart with the specified orientation and using the
 * specified renderer./*from ww w  . ja  v  a2s  . c o m*/
 *
 * @param orientation  the plot orientation.
 * @param renderer     the renderer.
 *
 * @return A bar chart.
 */
private static JFreeChart createBarChart3D(PlotOrientation orientation, BarRenderer renderer) {
    GCategoryPlot plot = new GCategoryPlot();
    plot.setOrientation(orientation);
    if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(null);
    plot.setRenderer(renderer);
    renderer.setBasePaint(new Color(0xFFCC33));
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBasePaint(new Color(0xFFCC33));
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelGenerator(new GCategoryPlot.LabelGenerator());
    renderer.setItemLabelPaint(new Color(0x333435));

    if (orientation == PlotOrientation.HORIZONTAL) {
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_RIGHT));
    } else {
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
    }

    GCategoryAxis3D xAxis = new GCategoryAxis3D();
    xAxis.setAxisLineVisible(true);
    xAxis.setTickLabelsVisible(false);
    xAxis.setMaximumCategoryLabelLines(5);
    plot.setDomainAxis(xAxis);
    GValueAxis3D yAxis = new GValueAxis3D();
    yAxis.setAxisLineVisible(true);
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}