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

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

Introduction

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

Prototype

public void setAutoRange(boolean auto) 

Source Link

Document

Sets a flag that determines whether or not the axis range is automatically adjusted to fit the data, and notifies registered listeners that the axis has been modified.

Usage

From source file:uk.co.petertribble.jangle.SnmpChart.java

private void setAxes() {
    XYPlot xyplot = chart.getXYPlot();//  w w  w . j a v a  2 s.  c o m

    String ylabel = showdelta ? SnmpResources.getString("CHART.RATE") : SnmpResources.getString("CHART.VALUE");
    NumberAxis loadaxis = new NumberAxis(ylabel);
    loadaxis.setAutoRange(true);
    loadaxis.setAutoRangeIncludesZero(true);
    xyplot.setRangeAxis(loadaxis);

    DateAxis daxis = new DateAxis(SnmpResources.getString("CHART.TIME"));
    daxis.setAutoRange(true);
    daxis.setFixedAutoRange(maxage);
    xyplot.setDomainAxis(daxis);
}

From source file:netplot.GenericPlotPanel.java

void genericConfig(JFreeChart chart, XYPlot plot, int plotIndex) {
    if (!enableLegend) {
        chart.removeLegend();//ww  w .j  a  v  a 2  s .co m
    }

    XYItemRenderer xyItemRenderer = plot.getRenderer();
    //May also be XYBarRenderer
    if (xyItemRenderer instanceof XYLineAndShapeRenderer) {
        XYToolTipGenerator xyToolTipGenerator = xyItemRenderer.getBaseToolTipGenerator();
        //If currently an XYLineAndShapeRenderer replace it so that we inc the colour for every plotIndex
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(linesEnabled, shapesEnabled);
        //Ensure we don't loose the tool tips on the new renderer
        renderer.setBaseToolTipGenerator(xyToolTipGenerator);
        renderer.setBasePaint(getPlotColour(plotIndex));
        renderer.setSeriesStroke(0, new BasicStroke(lineWidth, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL),
                true);
        plot.setRenderer(plotIndex, renderer);
    }

    //If we have a new y axis then we need a new data set
    if (yAxisName != null && yAxisName.length() > 0) {
        if (logYAxis) {
            LogAxis yAxis = new LogAxis(yAxisName);
            yAxis.setAutoRange(false);
            yAxis.setNumberFormatOverride(new LogFormat(10, "10", true));
            yAxis.setRange(minScaleValue, maxScaleValue);
            yAxis.setLowerBound(minScaleValue);
            yAxis.setUpperBound(maxScaleValue);
            plot.setRangeAxis(yAxisIndex, yAxis);
            plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT);
        } else {
            NumberAxis axis = new NumberAxis(yAxisName);
            axis.setAutoRangeIncludesZero(zeroOnYScale);
            if (autoScaleEnabled) {
                axis.setAutoRange(true);
            } else {
                Range range = new Range(minScaleValue, maxScaleValue);
                axis.setRangeWithMargins(range, true, true);
            }
            if (yAxisTickCount > 0) {
                NumberTickUnit tick = new NumberTickUnit(yAxisTickCount);
                axis.setTickUnit(tick);
            }
            plot.setRangeAxis(yAxisIndex, axis);
            plot.setRangeAxisLocation(yAxisIndex, AxisLocation.BOTTOM_OR_LEFT);
        }
        yAxisIndex++;
    }
    plot.mapDatasetToRangeAxis(plotIndex, yAxisIndex - 1);
    ValueAxis a = plot.getDomainAxis();
    if (xAxisName.length() > 0) {
        a.setLabel(xAxisName);
    }
    //We can enable/disable zero on the axis if we have a NumberAxis
    if (a instanceof NumberAxis) {
        ((NumberAxis) a).setAutoRangeIncludesZero(zeroOnXScale);
    }
}

From source file:org.mwc.asset.netasset2.sensor2.VSensor.java

/**
 * Create the composite./*from w  w w . j  a  va 2s .  co m*/
 * 
 * @param parent
 * @param style
 */
public VSensor(final Composite parent, final int style) {
    super(parent, style);
    setLayout(new BorderLayout(0, 0));

    final ToolBar toolBar = new ToolBar(this, SWT.FLAT | SWT.RIGHT);
    toolBar.setLayoutData(BorderLayout.NORTH);

    // ToolItem testBtn = new ToolItem(toolBar, SWT.NONE);
    // testBtn.setText("Test 1");
    // testBtn.addSelectionListener(new SelectionAdapter()
    // {
    //
    // @Override
    // public void widgetSelected(SelectionEvent e)
    // {
    // doTest();
    // }
    // });

    final ToolItem tltmDropdownItem = new ToolItem(toolBar, SWT.DROP_DOWN);
    tltmDropdownItem.setText("Visible period");
    final DropdownSelectionListener drops = new DropdownSelectionListener(tltmDropdownItem);
    drops.add("5 Mins", 5 * 60);
    drops.add("15 Mins", 15 * 60);
    drops.add("60 Mins", 60 * 60);
    drops.add("All data", 0);
    tltmDropdownItem.addSelectionListener(drops);

    final Composite sashForm = new Composite(this, SWT.EMBEDDED);

    // now we need a Swing object to put our chart into
    final Frame _plotControl = SWT_AWT.new_Frame(sashForm);

    // the y axis is common to hi & lo res. Format it here
    final NumberAxis yAxis = new NumberAxis("Degs");
    //   yAxis.setRange(0, 360);
    yAxis.setAutoRange(true);
    yAxis.setTickUnit(new NumberTickUnit(45));

    // create a date-formatting axis
    _dateAxis = new RelativeDateAxis();
    _dateAxis.setStandardTickUnits(DateAxisEditor.createStandardDateTickUnitsAsTickUnits());
    _dateAxis.setAutoRange(true);

    final XYItemRenderer theRenderer = new XYShapeRenderer();

    _thePlot = new XYPlot(null, _dateAxis, yAxis, theRenderer);
    _thePlot.setOrientation(PlotOrientation.HORIZONTAL);
    _thePlot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    _thePlot.setBackgroundPaint(Color.BLACK);
    theRenderer.setPlot(_thePlot);

    _dateAxis.setLabelPaint(Color.GREEN);
    _dateAxis.setTickLabelPaint(Color.GREEN);
    _dateAxis.setAxisLinePaint(Color.GREEN);

    yAxis.setLabelPaint(Color.GREEN);
    yAxis.setTickLabelPaint(Color.GREEN);

    _thePlotArea = new JFreeChart(null, _thePlot);
    _thePlotArea.setBackgroundPaint(Color.BLACK);
    _thePlotArea.setBorderPaint(Color.BLACK);

    // set the color of the area surrounding the plot
    // - naah, don't bother. leave it in the application background color.

    // ////////////////////////////////////////////////
    // put the holder into one of our special items
    // ////////////////////////////////////////////////
    _chartInPanel = new ChartPanel(_thePlotArea, true);

    _plotControl.add(_chartInPanel);

}

From source file:iDynoOptimizer.MOEAFramework26.src.org.moeaframework.analysis.diagnostics.LinePlot.java

@Override
protected void update() {
    XYDataset dataset = null;//from  w ww .j  av a  2 s .co m

    //generate the plot data
    if (controller.getShowIndividualTraces()) {
        dataset = new DefaultTableXYDataset();

        for (ResultKey key : frame.getSelectedResults()) {
            generateIndividualSeries(key, (DefaultTableXYDataset) dataset);
        }
    } else {
        dataset = new YIntervalSeriesCollection();

        for (ResultKey key : frame.getSelectedResults()) {
            generateQuantileSeries(key, (YIntervalSeriesCollection) dataset);
        }
    }

    //create the chart
    JFreeChart chart = ChartFactory.createXYLineChart(metric, localization.getString("text.NFE"),
            localization.getString("text.value"), dataset, PlotOrientation.VERTICAL, false, true, false);
    final XYPlot plot = chart.getXYPlot();

    //setup the series renderer
    if (controller.getShowIndividualTraces()) {
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i));

            renderer.setSeriesStroke(i, new BasicStroke(1f, 1, 1));
            renderer.setSeriesPaint(i, paint);
        }

        plot.setRenderer(renderer);
    } else {
        DeviationRenderer renderer = new DeviationRenderer(true, false);

        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            Paint paint = frame.getPaintHelper().get(dataset.getSeriesKey(i));

            renderer.setSeriesStroke(i, new BasicStroke(3f, 1, 1));
            renderer.setSeriesPaint(i, paint);
            renderer.setSeriesFillPaint(i, paint);
        }

        plot.setRenderer(renderer);
    }

    //create the legend
    final LegendItemCollection items = plot.getLegendItems();
    Iterator<?> iterator = items.iterator();
    Set<ResultKey> uniqueKeys = new HashSet<ResultKey>();

    while (iterator.hasNext()) {
        LegendItem item = (LegendItem) iterator.next();

        if (uniqueKeys.contains(item.getSeriesKey())) {
            iterator.remove();
        } else {
            uniqueKeys.add((ResultKey) item.getSeriesKey());
        }
    }

    LegendItemSource source = new LegendItemSource() {

        @Override
        public LegendItemCollection getLegendItems() {
            return items;
        }

    };

    LegendTitle legend = new LegendTitle(source);
    legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0));
    legend.setFrame(new LineBorder());
    legend.setBackgroundPaint(Color.WHITE);
    legend.setPosition(RectangleEdge.BOTTOM);
    chart.addLegend(legend);

    //scale the axes
    final NumberAxis domainAxis = new NumberAxis();
    domainAxis.setAutoRange(true);
    plot.setDomainAxis(domainAxis);

    //add overlay
    if (controller.getShowLastTrace() && !controller.getShowIndividualTraces()
            && (controller.getLastAccumulator() != null)
            && controller.getLastAccumulator().keySet().contains(metric)) {
        DefaultTableXYDataset dataset2 = new DefaultTableXYDataset();
        XYSeries series = new XYSeries(localization.getString("text.last"), false, false);

        for (int i = 0; i < controller.getLastAccumulator().size(metric); i++) {
            series.add((Number) controller.getLastAccumulator().get("NFE", i),
                    (Number) controller.getLastAccumulator().get(metric, i));
        }

        dataset2.addSeries(series);

        XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false);
        renderer2.setSeriesStroke(0, new BasicStroke(1f, 1, 1));
        renderer2.setSeriesPaint(0, Color.BLACK);

        plot.setDataset(1, dataset2);
        plot.setRenderer(1, renderer2);
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    }

    //update the chart in the GUI
    removeAll();
    add(new ChartPanel(chart), BorderLayout.CENTER);
    revalidate();
    repaint();
}

From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java

private XYPlot createPlot(ADataset2D<IChromatogram1D, IScan> ds) {
    XYBlockRenderer xybr = new XYBlockRenderer();
    IPaintScaleProvider ips = Lookup.getDefault().lookup(IPaintScaleProvider.class);
    ips.setMin(ds.getMinZ());//  w  w w  . j  a v  a2s .  c o  m
    ips.setMax(ds.getMaxZ());
    PaintScale ps = ips.getPaintScales().get(0);
    xybr.setPaintScale(ps);
    xybr.setDefaultEntityRadius(5);
    xybr.setBlockWidth(0.1);
    xybr.setBlockAnchor(RectangleAnchor.CENTER);
    xybr.setBlockHeight(1.0);
    RTUnit rtUnit = RTUnit.SECONDS;
    xybr.setToolTipGenerator(
            new StandardXYZToolTipGenerator("{0}: @({1}, {2}) = {3}", DecimalFormat.getNumberInstance(),
                    DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance()));
    NumberAxis rt1 = new NumberAxis("Retention Time [" + rtUnit.name().toLowerCase() + "]");
    NumberAxis rt2 = new NumberAxis("M/Z");
    rt1.setAutoRange(false);
    rt1.setLowerBound(ds.getMinX());
    rt1.setUpperBound(ds.getMaxX());
    rt1.setRangeWithMargins(ds.getMinX(), ds.getMaxX());
    rt2.setFixedAutoRange(ds.getMaxX() - ds.getMinX());
    rt2.setAutoRange(false);
    rt2.setLowerBound(ds.getMinY());
    rt2.setUpperBound(ds.getMaxY());
    rt2.setFixedAutoRange(ds.getMaxY() - ds.getMinY());
    rt2.setRangeWithMargins(ds.getMinY(), ds.getMaxY());
    XYPlot heatmapPlot = new XYPlot(ds, rt1, rt2, xybr);
    heatmapPlot.setDomainPannable(true);
    heatmapPlot.setRangePannable(true);
    return heatmapPlot;
}

From source file:OAT.ui.BarChartFrame.java

public void addDataset(ChartDataset dataset) {
    if (dataset == null || dataset.getSeriesCount() == 0) {
        return;//from w w w.j  a va2 s.c  om
    }

    XYPlot plot = getChart().getXYPlot();
    int i = plot.getDatasetCount();

    for (int j = 0; j < i; j++) {
        if (plot.getDataset(j).equals(dataset)) {
            //                System.out.println("eq " + i
            //                        + " " + ((ChartDataset) plot.getDataset(j)).getTitle()
            //                        + " " + dataset.getTitle());
            return;
        }
    }

    plot.setDataset(i, dataset);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    Double[] range = dataset.getAxisRange();

    //axis
    int axisId = 0;

    if (range != null) {
        //        if (range == null || range.length < 2) {
        //            plot.mapDatasetToRangeAxis(i, 0);
        //        } else {

        //scan for equal axis range, reuse if found
        boolean hasSameRange = false;

        if (range.length > 1) {
            for (int j = 1; j < plot.getRangeAxisCount(); j++) {
                Range otherRange = plot.getRangeAxis(j).getRange();

                if (otherRange != null && otherRange.getLowerBound() == range[0]
                        && otherRange.getUpperBound() == range[1]) {
                    axisId = j;
                    hasSameRange = true;
                    break;
                }
            }
        }

        if (!hasSameRange) {
            NumberAxis newAxis = new NumberAxis();

            if (range.length > 1) {
                newAxis.setAutoRange(false);
                newAxis.setRange(range[0], range[1]);
            }

            if (range.length > 2) {
                newAxis.setAutoTickUnitSelection(false, false);
                newAxis.setTickUnit(new NumberTickUnit(range[2]));
            }

            newAxis.setNumberFormatOverride(TextUtil.SIMPLE_FORMATTER);
            //                    newAxis.setAxisLinePaint(new Color(100, 0, 0));
            //                    newAxis.setLabelPaint(paints[i][0]);
            //                    newAxis.setTickLabelPaint(paints[i][0]);
            //                    newAxis.setTickMarkPaint(paints[i][0]);
            //                    newAxis.setTickLabelsVisible(true);

            axisId = plot.getRangeAxisCount();
            plot.setRangeAxis(axisId, newAxis, false);
            plot.setRangeAxisLocation(axisId, AxisLocation.BOTTOM_OR_LEFT, false);
        }
        //            plot.mapDatasetToRangeAxis(i, newAxisId);
    }
    plot.mapDatasetToRangeAxis(i, axisId);
    //

    //renderer
    XYLineAndShapeRenderer renderer;

    if (dataset instanceof TradeDataset) {
        renderer = new TradeRenderer();

        for (int j = 0; j < dataset.getSeriesCount(); j++) {
            renderer.setSeriesLinesVisible(j, false);
        }
    } else {

        Shape shape = Main.defaultShape;
        Paint[][] seriesPaints;
        Stroke stroke;

        if (dataset.getSource() instanceof Stopper && !(dataset.getSource() instanceof Calculator)) {
            seriesPaints = Main.greyPaints;
            stroke = Main.dottedStoke;
        } else {
            seriesPaints = Main.defaultPaints;
            stroke = Main.defaultStoke;
        }

        renderer = new IndicatorRenderer(seriesPaints[(i - 1) % seriesPaints.length], shape, stroke);
    }

    plot.setRenderer(i, renderer, false);
}

From source file:hudson.plugins.labeledgroupedtests.TrendGraph.java

protected JFreeChart createGraph() {
    final CategoryDataset dataset = createDataSet().build();

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart
            // title
            null, // unused
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );/* www . j  a  va2  s.c om*/

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    // plot.setDomainGridlinesVisible(true);
    // plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    ChartUtil.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    StackedAreaRenderer ar = new StackedAreaRenderer2() {
        @Override
        public Paint getItemPaint(int row, int column) {
            ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
            if (key.getColor() != null)
                return key.getColor();
            return super.getItemPaint(row, column);
        }

        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getURL() + relativeUrl;
        }

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getToolTipText();
        }
    };
    plot.setRenderer(ar);

    ar.setSeriesPaint(0, ColorPalette.RED); // Skips.
    ar.setSeriesPaint(1, ColorPalette.YELLOW); // Failures.
    ar.setSeriesPaint(2, ColorPalette.BLUE); // Total.

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:hudson.plugins.robot.graph.RobotGraph.java

/**
 * Creates a Robot trend graph//from www . j  a  v a  2 s. co  m
 * @return the JFreeChart graph object
 */
protected JFreeChart createGraph() {

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, null, yLabel, categoryDataset,
            PlotOrientation.VERTICAL, true, true, false);

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(0.7f);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.darkGray);

    final CategoryAxis domainAxis = new ShiftedCategoryAxis(xLabel);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);
    plot.setDomainAxis(domainAxis);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    if (binaryData) {
        rangeAxis.setUpperBound(1);
    } else if (upperBound != 0) {
        rangeAxis.setUpperBound(upperBound);
    } else {
        rangeAxis.setAutoRange(true);
    }
    rangeAxis.setLowerBound(lowerBound);
    Font font = new Font("Dialog", Font.PLAIN, fontSize);
    plot.getDomainAxis().setLabelFont(font);
    plot.getDomainAxis().setTickLabelFont(font);
    plot.getRangeAxis().setLabelFont(font);
    plot.getRangeAxis().setTickLabelFont(font);
    legend.setItemFont(font);
    final CategoryItemRenderer renderer = plot.getRenderer();

    for (int i = 0; i < colors.length; i++) {
        renderer.setSeriesPaint(i, colors[i]);
    }

    plot.setInsets(new RectangleInsets(15.0, 0, 0, 5.0));

    return chart;
}

From source file:com.cwctravel.hudson.plugins.suitegroupedtests.TrendGraph.java

@Override
protected JFreeChart createGraph() {
    final CategoryDataset dataset = createDataSet().build();

    final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart
            // title
            null, // unused
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );//from  w w w .  j ava  2  s .c  o m

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();

    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    // plot.setDomainGridlinesVisible(true);
    // plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    ChartUtil.adjustChebyshev(dataset, rangeAxis);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRange(true);

    StackedAreaRenderer ar = new StackedAreaRenderer2() {
        private static final long serialVersionUID = 7962375662395944968L;

        @Override
        public Paint getItemPaint(int row, int column) {
            ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
            if (key.getColor() != null)
                return key.getColor();
            return super.getItemPaint(row, column);
        }

        @Override
        public String generateURL(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getURL() + relativeUrl;
        }

        @Override
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
            return label.getToolTipText();
        }
    };
    plot.setRenderer(ar);

    ar.setSeriesPaint(0, ColorPalette.RED); // Skips.
    ar.setSeriesPaint(1, ColorPalette.YELLOW); // Failures.
    ar.setSeriesPaint(2, ColorPalette.BLUE); // Total.

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

    return chart;
}

From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.Chromatogram2DViewTopComponent.java

private XYPlot createPlot(IChromatogramDescriptor chromatogram, ADataset2D<IChromatogram2D, IScan2D> ds,
        PaintScale ps) {/*from w  w  w .j  a  v a  2 s.  com*/
    XYNoBlockRenderer xybr = new XYNoBlockRenderer();
    xybr.setPaintScale(ps);
    try {
        double modulationTime = chromatogram.getChromatogram().getParent().getChild("modulation_time")
                .getArray().getDouble(0);
        double scanRate = chromatogram.getChromatogram().getParent().getChild("scan_rate").getArray()
                .getDouble(0);
        xybr.setDefaultEntityRadius(10);//Math.max(1, (int)(modulationTime / scanRate)));
        xybr.setEntityThreshold(ds.getMinZ());
        xybr.setBlockWidth(modulationTime);
        xybr.setBlockAnchor(RectangleAnchor.CENTER);
        double spm = modulationTime * scanRate;
        double scanDuration = modulationTime / spm;
        xybr.setBlockHeight(scanDuration);
    } catch (ResourceNotAvailableException rnae) {
    }
    RTUnit rtUnit = RTUnit.SECONDS;
    xybr.setToolTipGenerator(
            new StandardXYZToolTipGenerator("{0}: @({1}, {2}) = {3}", DecimalFormat.getNumberInstance(),
                    DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance()));
    NumberAxis rt1 = new NumberAxis("RT1 [" + rtUnit.name().toLowerCase() + "]");
    NumberAxis rt2 = new NumberAxis("RT2 [" + rtUnit.name().toLowerCase() + "]");
    rt1.setAutoRange(false);
    rt1.setLowerBound(ds.getMinX());
    rt1.setUpperBound(ds.getMaxX());
    rt1.setRangeWithMargins(ds.getMinX(), ds.getMaxX());
    rt2.setFixedAutoRange(ds.getMaxX() - ds.getMinX());
    rt2.setAutoRange(false);
    rt2.setLowerBound(ds.getMinY());
    rt2.setUpperBound(ds.getMaxY());
    rt2.setFixedAutoRange(ds.getMaxY() - ds.getMinY());
    rt2.setRangeWithMargins(ds.getMinY(), ds.getMaxY());
    XYPlot heatmapPlot = new XYPlot(ds, rt1, rt2, xybr);
    heatmapPlot.setDomainPannable(true);
    heatmapPlot.setRangePannable(true);
    return heatmapPlot;
}