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

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

Introduction

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

Prototype

public void setRangeWithMargins(Range range) 

Source Link

Document

Sets the range for the axis (after first adding the current margins to the specified range) and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java

private XYPlot createPlot(final XYSeriesCollection problem, XYSeriesCollection shipments,
        XYSeriesCollection solution) {/*from   ww w.  j av  a 2 s .  c  o m*/
    XYPlot plot = new XYPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);

    XYLineAndShapeRenderer problemRenderer = getProblemRenderer(problem);
    plot.setDataset(0, problem);
    plot.setRenderer(0, problemRenderer);

    XYItemRenderer shipmentsRenderer = getShipmentRenderer(shipments);
    plot.setDataset(1, shipments);
    plot.setRenderer(1, shipmentsRenderer);

    if (solution != null) {
        XYItemRenderer solutionRenderer = getRouteRenderer(solution);
        plot.setDataset(2, solution);
        plot.setRenderer(2, solutionRenderer);
    }

    NumberAxis xAxis = new NumberAxis();
    NumberAxis yAxis = new NumberAxis();

    if (boundingBox == null) {
        xAxis.setRangeWithMargins(getDomainRange(problem));
        yAxis.setRangeWithMargins(getRange(problem));
    } else {
        xAxis.setRangeWithMargins(new Range(boundingBox.minX, boundingBox.maxX));
        yAxis.setRangeWithMargins(new Range(boundingBox.minY, boundingBox.maxY));
    }

    plot.setDomainAxis(xAxis);
    plot.setRangeAxis(yAxis);

    return plot;
}

From source file:org.jfree.chart.ChartFactory.java

public static <T extends Number> JFreeChart createScatterCategoryChart(Map<String, List<T>> dataset,
        String title, String xAxis, String yAxis, boolean showLegend) {
    // Make the PDB series and add it to the predicted strand locations
    CategoryDataset data = createMultiValueCategoryDataset(dataset);

    Range rangeBounds = DatasetUtilities.findRangeBounds(data);
    NumberAxis numberAxis = new NumberAxis(yAxis);
    numberAxis.setRangeWithMargins(rangeBounds);

    CategoryPlot plot = new CategoryPlot(data, new CategoryAxis(xAxis), numberAxis, new SR());

    JFreeChart chart = new JFreeChart(title, plot);

    if (!showLegend)
        chart.removeLegend();//from  ww w  .  ja  v a2  s. c  o m
    setCategoryStandardTooltips(chart);

    ((CategoryPlot) chart.getPlot()).setDomainGridlinesVisible(false);
    ((CategoryPlot) chart.getPlot()).setRangeGridlinesVisible(false);
    ;

    chart.setBackgroundPaint(Color.white);
    chart.getPlot().setBackgroundPaint(Color.white);
    return chart;
}

From source file:org.jfree.chart.ChartFactory.java

public static <T extends Number> JFreeChart create2DScatterCategoryChart(Map<String[], List<T>> dataset,
        String title, String xAxis, String yAxis, boolean showLegend) {
    // Make the PDB series and add it to the predicted strand locations
    CategoryDataset data = create2DMultiValueCategoryDataset(dataset);

    Range rangeBounds = DatasetUtilities.findRangeBounds(data);
    NumberAxis numberAxis = new NumberAxis(yAxis);
    numberAxis.setRangeWithMargins(rangeBounds);

    CategoryPlot plot = new CategoryPlot(data, new CategoryAxis(xAxis), numberAxis, new SR());

    JFreeChart chart = new JFreeChart(title, plot);

    if (!showLegend)
        chart.removeLegend();/*  ww w. jav  a2 s.  c om*/
    setCategoryStandardTooltips(chart);

    ((CategoryPlot) chart.getPlot()).setDomainGridlinesVisible(false);
    ((CategoryPlot) chart.getPlot()).setRangeGridlinesVisible(false);
    ;

    chart.setBackgroundPaint(Color.white);
    chart.getPlot().setBackgroundPaint(Color.white);
    return chart;
}