Search in sources :

Example 6 with XYBlockPixelSizeRenderer

use of net.sf.mzmine.chartbasics.chartutils.XYBlockPixelSizeRenderer in project mzmine2 by mzmine.

the class KendrickMassPlotTask method create2DKendrickMassPlot.

/**
 * create 2D Kendrick mass plot
 */
private JFreeChart create2DKendrickMassPlot() {
    if (zAxisLabel.equals("none")) {
        logger.info("Creating new 2D chart instance");
        appliedSteps++;
        // load dataset
        dataset2D = new KendrickMassPlotXYDataset(parameterSet);
        // create chart
        chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, dataset2D, PlotOrientation.VERTICAL, true, true, true);
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setBackgroundPaint(Color.WHITE);
        plot.setDomainCrosshairPaint(Color.GRAY);
        plot.setRangeCrosshairPaint(Color.GRAY);
        plot.setDomainCrosshairVisible(true);
        plot.setRangeCrosshairVisible(true);
        appliedSteps++;
        // set axis
        NumberAxis domain = (NumberAxis) plot.getDomainAxis();
        NumberAxis range = (NumberAxis) plot.getRangeAxis();
        range.setRange(0, 1);
        if (xAxisLabel.contains("KMD")) {
            domain.setRange(0, 1);
        }
        // set renderer
        XYBlockPixelSizeRenderer renderer = new XYBlockPixelSizeRenderer();
        // set tooltip generator
        ScatterPlotToolTipGenerator tooltipGenerator = new ScatterPlotToolTipGenerator(xAxisLabel, yAxisLabel, zAxisLabel, rows);
        renderer.setSeriesToolTipGenerator(0, tooltipGenerator);
        plot.setRenderer(renderer);
        // set item label generator
        NameItemLabelGenerator generator = new NameItemLabelGenerator(rows);
        renderer.setDefaultItemLabelGenerator(generator);
        renderer.setDefaultItemLabelsVisible(false);
        renderer.setDefaultItemLabelFont(legendFont);
        renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -45), true);
    }
    return chart;
}
Also used : XYBlockPixelSizeRenderer(net.sf.mzmine.chartbasics.chartutils.XYBlockPixelSizeRenderer) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) ScatterPlotToolTipGenerator(net.sf.mzmine.chartbasics.chartutils.ScatterPlotToolTipGenerator) NameItemLabelGenerator(net.sf.mzmine.chartbasics.chartutils.NameItemLabelGenerator)

Aggregations

XYBlockPixelSizeRenderer (net.sf.mzmine.chartbasics.chartutils.XYBlockPixelSizeRenderer)6 XYPlot (org.jfree.chart.plot.XYPlot)6 NameItemLabelGenerator (net.sf.mzmine.chartbasics.chartutils.NameItemLabelGenerator)4 ScatterPlotToolTipGenerator (net.sf.mzmine.chartbasics.chartutils.ScatterPlotToolTipGenerator)4 ItemLabelPosition (org.jfree.chart.labels.ItemLabelPosition)4 NumberAxis (org.jfree.chart.axis.NumberAxis)3 PaintScaleLegend (org.jfree.chart.title.PaintScaleLegend)3 Color (java.awt.Color)2 Paint (java.awt.Paint)2 BlockBorder (org.jfree.chart.block.BlockBorder)2 LookupPaintScale (org.jfree.chart.renderer.LookupPaintScale)2 RectangleInsets (org.jfree.chart.ui.RectangleInsets)2