Example usage for org.jfree.chart.axis NumberAxis getAutoRangeIncludesZero

List of usage examples for org.jfree.chart.axis NumberAxis getAutoRangeIncludesZero

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis getAutoRangeIncludesZero.

Prototype

public boolean getAutoRangeIncludesZero() 

Source Link

Document

Returns the flag that indicates whether or not the automatic axis range (if indeed it is determined automatically) is forced to include zero.

Usage

From source file:web.diva.server.unused.PCAGenerator.java

public PCAImageResult generateChart(String path, PCAResults pcaResults, int[] subSelectionData, int[] selection,
        boolean zoom, boolean selectAll, String imgName, double w, double h, DivaDataset divaDataset) {
    XYDataset dataset = this.createDataset(pcaResults.getPoints(), subSelectionData, selection, zoom,
            divaDataset);/*from ww  w. j  av  a2 s  .c o  m*/
    final JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            "Principal Component" + (pcaResults.getPcai() + 1), // x axis label
            "Principal Component " + (pcaResults.getPcaii() + 1), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    XYDotRenderer renderer = new XYDotRenderer();
    renderer.setDotHeight(5);
    renderer.setDotWidth(5);

    if (selectAll) {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }

    } else if (selection == null) {
        renderer.setPaint(Color.LIGHT_GRAY);
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }
    } else {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                renderer.setSeriesPaint(i, Color.LIGHT_GRAY);
            } else {
                renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));

            }
            i++;
        }
    }
    plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);
    NumberAxis xAxis = new NumberAxis("Principal Component" + (pcaResults.getPcai() + 1));
    xAxis.setVerticalTickLabels(true);
    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    NumberAxis yAxis = new NumberAxis("Principal Component" + (pcaResults.getPcaii() + 1));
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setTickUnit(new NumberTickUnit(1));
    plot.setDomainAxis(0, xAxis);
    plot.setRangeAxis(0, yAxis);

    double MaxX = xAxis.getRange().getUpperBound();
    double MinX = xAxis.getRange().getLowerBound();
    double MaxY = yAxis.getRange().getUpperBound();
    double MinY = yAxis.getRange().getLowerBound();

    chartRenderingInfo.clear();
    String imgUrl = imgGenerator.saveToFile(chart, w, h, chartRenderingInfo);
    PCAImageResult imgUtilRes = new PCAImageResult();
    imgUtilRes.setImgString(imgUrl);
    imgUtilRes.setDataAreaMaxX(chartRenderingInfo.getPlotInfo().getDataArea().getMaxX());
    imgUtilRes.setDataAreaMaxY(chartRenderingInfo.getPlotInfo().getDataArea().getMaxY());
    imgUtilRes.setDataAreaMinY(chartRenderingInfo.getPlotInfo().getDataArea().getMinY());
    imgUtilRes.setDataAreaMinX(chartRenderingInfo.getPlotInfo().getDataArea().getMinX());
    imgUtilRes.setMaxX(MaxX);
    imgUtilRes.setMaxY(MaxY);
    imgUtilRes.setMinX(MinX);
    imgUtilRes.setMinY(MinY);
    return imgUtilRes;
}

From source file:web.diva.server.model.PCAGenerator.java

public PCAImageResult generateChart(String path, PCAResults pcaResults, int[] subSelectionData, int[] selection,
        boolean zoom, boolean selectAll, String imgName, double w, double h, DivaDataset divaDataset) {
    XYDataset dataset = this.createDataset(pcaResults.getPoints(), subSelectionData, selection, zoom,
            divaDataset);//ww w.  j av a  2s.  c  om
    final JFreeChart chart = ChartFactory.createScatterPlot("", // chart title
            "Principal Component" + (pcaResults.getPcai() + 1), // x axis label
            "Principal Component " + (pcaResults.getPcaii() + 1), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    XYDotRenderer renderer = new XYDotRenderer();
    renderer.setDotHeight(5);
    renderer.setDotWidth(5);

    if (selectAll) {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }

    } else if (selection == null) {
        renderer.setPaint(Color.LIGHT_GRAY);
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                col = "#000000";
            }
            renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));
            i++;
        }
    } else {
        int i = 0;
        for (String col : seriesList.keySet()) {
            if (col.equalsIgnoreCase("unGrouped")) {
                renderer.setSeriesPaint(i, Color.LIGHT_GRAY);
            } else {
                renderer.setSeriesPaint(i, imgGenerator.hex2Rgb(col));

            }
            i++;
        }
    }
    plot.setRenderer(renderer);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);
    NumberAxis xAxis = new NumberAxis("Principal Component" + (pcaResults.getPcai() + 1));
    xAxis.setVerticalTickLabels(true);
    boolean auto = xAxis.getAutoRangeIncludesZero();
    xAxis.setAutoRangeIncludesZero(true ^ auto);
    NumberAxis yAxis = new NumberAxis("Principal Component" + (pcaResults.getPcaii() + 1));
    yAxis.setAutoRangeIncludesZero(true ^ auto);
    yAxis.setTickUnit(new NumberTickUnit(1));
    plot.setDomainAxis(0, xAxis);
    plot.setRangeAxis(0, yAxis);

    double MaxX = xAxis.getRange().getUpperBound();
    double MinX = xAxis.getRange().getLowerBound();
    double MaxY = yAxis.getRange().getUpperBound();
    double MinY = yAxis.getRange().getLowerBound();

    chartRenderingInfo.clear();
    String imgUrl = imgGenerator.saveToFile(chart, w, h, path, chartRenderingInfo, imgName);
    PCAImageResult imgUtilRes = new PCAImageResult();
    imgUtilRes.setImgString(imgUrl);
    imgUtilRes.setDataAreaMaxX(chartRenderingInfo.getPlotInfo().getDataArea().getMaxX());
    imgUtilRes.setDataAreaMaxY(chartRenderingInfo.getPlotInfo().getDataArea().getMaxY());
    imgUtilRes.setDataAreaMinY(chartRenderingInfo.getPlotInfo().getDataArea().getMinY());
    imgUtilRes.setDataAreaMinX(chartRenderingInfo.getPlotInfo().getDataArea().getMinX());
    imgUtilRes.setMaxX(MaxX);
    imgUtilRes.setMaxY(MaxY);
    imgUtilRes.setMinX(MinX);
    imgUtilRes.setMinY(MinY);
    return imgUtilRes;
}