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

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

Introduction

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

Prototype

public void setDomainZeroBaselinePaint(Paint paint) 

Source Link

Document

Sets the paint for the zero baseline plotted against the domain 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  ww  w  .  j ava2s  .  c  o 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:org.operamasks.faces.render.graph.ChartRenderer.java

protected void setChartAxes(JFreeChart chart, UIChart comp) {
    UIAxis xAxis = comp.getxAxis();/* w  w  w.  j a va  2  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);
    }
}