Example usage for org.jfree.eastwood GValueAxis GValueAxis

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

Introduction

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

Prototype

public GValueAxis() 

Source Link

Document

Creates a new axis.

Usage

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

/**
 * Creates a line chart.//  ww w  .jav  a 2  s  .  c  om
 *
 * @return A line chart.
 */
private static JFreeChart createLineChart() {
    GXYPlot plot = new GXYPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);
    JFreeChart chart = new JFreeChart(plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    renderer.setBasePaint(new Color(0xFF9900));
    renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelGenerator(new GXYPlot.LabelGenerator());
    renderer.setItemLabelPaint(new Color(0x333435));

    renderer.setPositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));

    GValueAxis xAxis = new GValueAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

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

/**
 * Creates a sparkline chart./*w w w .  java  2 s.  c  o m*/
 *
 * @return A sparkline chart.
 */
private static JFreeChart createSparklineChart() {
    GXYPlot plot = new GXYPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setBaseShapesVisible(false);
    plot.setRenderer(renderer);
    JFreeChart chart = new JFreeChart(plot);
    chart.setPadding(RectangleInsets.ZERO_INSETS);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);
    renderer.setBasePaint(new Color(0xFF9900));
    renderer.setBaseStroke(new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setVisible(false);
    plot.setRangeAxis(yAxis);
    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./*w w w  . j  a  v  a 2  s .  c  o  m*/
 *
 * @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 scatter chart.//from  w w  w. ja va 2s .  c  om
 *
 * @return A scatter chart.
 */
private static JFreeChart createScatterChart() {
    JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false,
            false, false);
    chart.setBackgroundPaint(Color.white);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(null);
    plot.setOutlinePaint(null);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBasePaint(new Color(0x76A4FB));
    renderer.setAutoPopulateSeriesPaint(false);

    GValueAxis xAxis = new GValueAxis();
    xAxis.setTickLabelsVisible(false);
    xAxis.setTickMarksVisible(false);
    plot.setDomainAxis(xAxis);
    GValueAxis yAxis = new GValueAxis();
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

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

/**
 * Processes a string that indicates the axes that should be visible on
 * the plot.//from   w  ww  .j a v a 2 s.c om
 *
 * @param plot  the plot.
 * @param axisStr  the axis specification.
 * @param axes  a list that will be populated with any axes added to the
 *              plot.
 */
private static void processAxisStr(XYPlot plot, String axisStr, List axes) {
    int xAxisCount = 0;
    int yAxisCount = 0;
    for (int i = 0; i < axisStr.length(); i++) {
        char c = axisStr.charAt(i);
        if (c == 'x') {
            if (xAxisCount == 0) {
                Axis xAxis = plot.getDomainAxis();
                xAxis.setTickMarksVisible(true);
                xAxis.setTickLabelsVisible(true);
                axes.add(xAxis);
                xAxisCount++;
            } else {
                GValueAxis axis = new GValueAxis();
                axis.setAxisLineVisible(false);
                plot.setDomainAxis(xAxisCount, axis);
                plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT);
                axes.add(axis);
                xAxisCount++;
            }
        } else if (c == 'y') {
            if (yAxisCount == 0) {
                Axis yAxis = plot.getRangeAxis();
                yAxis.setTickMarksVisible(true);
                yAxis.setTickLabelsVisible(true);
                axes.add(yAxis);
                yAxisCount++;
            } else {
                GValueAxis axis = new GValueAxis();
                axis.setAxisLineVisible(false);
                plot.setRangeAxis(yAxisCount, axis);
                plot.setRangeAxisLocation(yAxisCount, AxisLocation.BOTTOM_OR_LEFT);
                axes.add(axis);
                yAxisCount++;
            }
        } else if (c == 'r') {
            GValueAxis axis = new GValueAxis();
            plot.setRangeAxis(yAxisCount, axis);
            plot.setRangeAxisLocation(yAxisCount, AxisLocation.BOTTOM_OR_RIGHT);
            axes.add(axis);
            yAxisCount++;
        } else if (c == 't') {
            GValueAxis axis = new GValueAxis();
            plot.setDomainAxis(xAxisCount, axis);
            plot.setDomainAxisLocation(xAxisCount, AxisLocation.TOP_OR_LEFT);
            axes.add(axis);
            xAxisCount++;
        } else if (c == ',') {
            // nothing to do
        } else {
            throw new RuntimeException("Bad character " + c);
        }
    }

}

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

/**
 * Processes a string that indicates the axes that should be visible on
 * the plot.//  w  w  w  .  j  a  v a  2  s.c  o m
 *
 * @param plot  the plot.
 * @param axisStr  the axis specification.
 * @param axes  a list that will be populated with any axes added to the
 *              plot.
 */
private static void processAxisStrV(CategoryPlot plot, String axisStr, List axes) {
    int xAxisCount = 0;
    int yAxisCount = 0;
    for (int i = 0; i < axisStr.length(); i++) {
        char c = axisStr.charAt(i);
        if (c == 'x') {
            if (xAxisCount == 0) {
                CategoryAxis xAxis = plot.getDomainAxis();
                xAxis.setTickLabelsVisible(true);
                axes.add(xAxis);
                xAxisCount++;
            } else {
                GCategoryAxis axis = new GCategoryAxis();
                axis.setAxisLineVisible(false);
                plot.setDomainAxis(xAxisCount, axis);
                plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT);
                axes.add(axis);
                xAxisCount++;
            }
        } else if (c == 'y') {
            if (yAxisCount == 0) {
                Axis yAxis = plot.getRangeAxis();
                yAxis.setTickLabelsVisible(true);
                yAxis.setTickMarksVisible(true);
                axes.add(yAxis);
                yAxisCount++;
            } else {
                GValueAxis axis = new GValueAxis();
                axis.setAxisLineVisible(false);
                plot.setRangeAxis(yAxisCount, axis);
                plot.setRangeAxisLocation(yAxisCount, AxisLocation.BOTTOM_OR_LEFT);
                axes.add(axis);
                yAxisCount++;
            }
        } else if (c == 'r') {
            GValueAxis axis = new GValueAxis();
            plot.setRangeAxis(yAxisCount, axis);
            plot.setRangeAxisLocation(yAxisCount, AxisLocation.BOTTOM_OR_RIGHT);
            axes.add(axis);
            yAxisCount++;
        } else if (c == 't') {
            GCategoryAxis axis = new GCategoryAxis();
            axis.setAxisLineVisible(false);
            plot.setDomainAxis(xAxisCount, axis);
            plot.setDomainAxisLocation(xAxisCount, AxisLocation.TOP_OR_LEFT);
            axes.add(axis);
            xAxisCount++;
        } else if (c == ',') {
            // nothing to do
        } else {
            throw new RuntimeException("Bad character " + c);
        }
    }

}

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

/**
 * Processes a string that indicates the axes that should be visible on
 * the plot.//from w w w.  j  a  v a 2 s.c  o m
 *
 * @param plot  the plot.
 * @param axisStr  the axis specification.
 * @param axes  a list that will be populated with any axes added to the
 *              plot.
 */
private static void processAxisStrH(CategoryPlot plot, String axisStr, List axes) {
    int xAxisCount = 0;
    int yAxisCount = 0;
    for (int i = 0; i < axisStr.length(); i++) {
        char c = axisStr.charAt(i);
        if (c == 'y') {
            if (yAxisCount == 0) {
                CategoryAxis axis = plot.getDomainAxis();
                axis.setTickLabelsVisible(true);
                axes.add(axis);
                yAxisCount++;
            } else {
                GCategoryAxis axis = new GCategoryAxis();
                axis.setAxisLineVisible(false);
                plot.setDomainAxis(yAxisCount, axis);
                plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT);
                axes.add(axis);
                yAxisCount++;
            }
        } else if (c == 'x') {
            if (xAxisCount == 0) {
                Axis axis = plot.getRangeAxis();
                axis.setTickLabelsVisible(true);
                axis.setTickMarksVisible(true);
                axes.add(axis);
                xAxisCount++;
            } else {
                GValueAxis axis = new GValueAxis();
                axis.setAxisLineVisible(false);
                plot.setRangeAxis(xAxisCount, axis);
                plot.setRangeAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_LEFT);
                axes.add(axis);
                xAxisCount++;
            }
        } else if (c == 't') {
            GValueAxis axis = new GValueAxis();
            plot.setRangeAxis(xAxisCount, axis);
            plot.setRangeAxisLocation(yAxisCount, AxisLocation.TOP_OR_LEFT);
            axes.add(axis);
            xAxisCount++;
        } else if (c == 'r') {
            GCategoryAxis axis = new GCategoryAxis();
            plot.setDomainAxis(yAxisCount, axis);
            plot.setDomainAxisLocation(xAxisCount, AxisLocation.BOTTOM_OR_RIGHT);
            axes.add(axis);
            yAxisCount++;
        } else if (c == ',') {
            // nothing to do
        } else {
            throw new RuntimeException("Bad character " + c);
        }
    }

}