Example usage for org.jfree.chart.plot XYPlot setRangeZeroBaselinePaint

List of usage examples for org.jfree.chart.plot XYPlot setRangeZeroBaselinePaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setRangeZeroBaselinePaint.

Prototype

public void setRangeZeroBaselinePaint(Paint paint) 

Source Link

Document

Sets the paint for the zero baseline plotted against the range axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:net.nosleep.superanalyzer.analysis.views.LikesView.java

private void createChart() {
    _chart = ChartFactory.createScatterPlot(Misc.getString("LIKES_VS_PLAYS"),
            Misc.getString("ALBUM_PLAY_COUNT"), Misc.getString("ALBUM_RATING"), _dataset,
            PlotOrientation.VERTICAL, false, true, false);

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LIKES_VS_PLAYS_SUBTITLE")));

    XYPlot plot = (XYPlot) _chart.getPlot();

    ChartUtilities.applyCurrentTheme(_chart);

    plot.setDomainPannable(true);/*from  www  . ja  v a 2 s.co m*/
    plot.setRangePannable(true);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // get rid of the little line above/next to the axis
    plot.setDomainZeroBaselinePaint(Color.white);
    plot.setRangeZeroBaselinePaint(Color.white);

    /*
     * NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
     * domainAxis.setAutoRangeIncludesZero(false);
     * 
     * domainAxis.setTickMarkInsideLength(2.0f);
     * domainAxis.setTickMarkOutsideLength(2.0f);
     * 
     * domainAxis.setMinorTickCount(2);
     * domainAxis.setMinorTickMarksVisible(true);
     */
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    /*
     * rangeAxis.setTickMarkInsideLength(2.0f);
     * rangeAxis.setTickMarkOutsideLength(2.0f);
     * rangeAxis.setMinorTickCount(2);
     * rangeAxis.setMinorTickMarksVisible(true);
     */
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // format the line renderer after applying the theme
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

protected JFreeChart createScatterChart() throws JRException {
    JFreeChart jfreeChart = super.createScatterChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();

    xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setDomainGridlinesVisible(true);
    xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134);

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    lineRenderer.setUseFillPaint(true);/*w ww  .  ja  v  a  2 s .co m*/
    JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
    boolean isShowLines = scatterPlot.getShowLines() == null ? false
            : scatterPlot.getShowLines().booleanValue();
    lineRenderer.setBaseLinesVisible(isShowLines);
    XYDataset xyDataset = xyPlot.getDataset();
    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            lineRenderer.setSeriesFillPaint(i,
                    (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
            lineRenderer.setSeriesPaint(i, (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            //lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
        }
    }
    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.java

@Override
protected JFreeChart createScatterChart() throws JRException {
    JFreeChart jfreeChart = super.createScatterChart();
    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();

    xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setDomainGridlinesVisible(true);
    xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR);
    xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f));
    xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134);

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    lineRenderer.setUseFillPaint(true);//  w w w  .j ava  2s.c o m
    JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
    boolean isShowLines = scatterPlot.getShowLines() == null ? false : scatterPlot.getShowLines();
    lineRenderer.setBaseLinesVisible(isShowLines);
    XYDataset xyDataset = xyPlot.getDataset();
    if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
            lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
            lineRenderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
            lineRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i));
            //lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6));
        }
    }
    return jfreeChart;
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartAxes(JFreeChart chart, UIChart comp) {
    UIAxis xAxis = comp.getxAxis();//w  w  w. j av a2  s. c  o m
    UIAxis yAxis = comp.getyAxis();
    String xAxisLabel = comp.getxAxisLabel();
    String yAxisLabel = comp.getyAxisLabel();

    Plot plot = chart.getPlot();
    Axis domainAxis = null;
    Axis rangeAxis = null;

    if (plot instanceof CategoryPlot) {
        CategoryPlot categoryPlot = (CategoryPlot) plot;
        if (yAxis != null && yAxis.isLogarithmic())
            categoryPlot.setRangeAxis(new LogarithmicAxis(null));

        domainAxis = categoryPlot.getDomainAxis();
        rangeAxis = categoryPlot.getRangeAxis();

        if (xAxis != null) {
            Boolean drawGridLine = xAxis.getDrawGridLine();
            if (drawGridLine != null) {
                categoryPlot.setDomainGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = xAxis.getGridLineColor();
            if (gridLineColor != null) {
                categoryPlot.setDomainGridlinePaint(gridLineColor);
            }
        }

        if (yAxis != null) {
            Boolean drawGridLine = yAxis.getDrawGridLine();
            if (drawGridLine != null) {
                categoryPlot.setRangeGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = yAxis.getGridLineColor();
            if (gridLineColor != null) {
                categoryPlot.setRangeGridlinePaint(gridLineColor);
            }
        }
    } else if (plot instanceof XYPlot) {
        XYPlot xyPlot = (XYPlot) plot;
        if (xAxis != null && xAxis.isLogarithmic())
            xyPlot.setDomainAxis(new LogarithmicAxis(null));
        if (yAxis != null && yAxis.isLogarithmic())
            xyPlot.setRangeAxis(new LogarithmicAxis(null));

        domainAxis = xyPlot.getDomainAxis();
        rangeAxis = xyPlot.getRangeAxis();

        if (xAxis != null) {
            Boolean drawGridLine = xAxis.getDrawGridLine();
            if (drawGridLine != null) {
                xyPlot.setDomainGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = xAxis.getGridLineColor();
            if (gridLineColor != null) {
                xyPlot.setDomainGridlinePaint(gridLineColor);
            }
            Boolean drawBaseLine = xAxis.getDrawBaseLine();
            if (drawBaseLine != null) {
                xyPlot.setDomainZeroBaselineVisible(drawBaseLine);
            }
            Paint baseLineColor = xAxis.getBaseLineColor();
            if (baseLineColor != null) {
                xyPlot.setDomainZeroBaselinePaint(baseLineColor);
            }
        }

        if (yAxis != null) {
            Boolean drawGridLine = yAxis.getDrawGridLine();
            if (drawGridLine != null) {
                xyPlot.setRangeGridlinesVisible(drawGridLine);
            }
            Paint gridLineColor = yAxis.getGridLineColor();
            if (gridLineColor != null) {
                xyPlot.setRangeGridlinePaint(gridLineColor);
            }
            Boolean drawBaseLine = yAxis.getDrawBaseLine();
            if (drawBaseLine != null) {
                xyPlot.setRangeZeroBaselineVisible(drawBaseLine);
            }
            Paint baseLineColor = yAxis.getBaseLineColor();
            if (baseLineColor != null) {
                xyPlot.setRangeZeroBaselinePaint(baseLineColor);
            }
        }
    }

    if (domainAxis != null) {
        if (xAxisLabel != null)
            domainAxis.setLabel(xAxisLabel);
        if (xAxis != null)
            setAxisStyles(domainAxis, xAxis);
    }
    if (rangeAxis != null) {
        if (yAxisLabel != null)
            rangeAxis.setLabel(yAxisLabel);
        if (yAxis != null)
            setAxisStyles(rangeAxis, yAxis);
    }
}