Search in sources :

Example 1 with XYBlockPixelSizeRenderer

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

the class KendrickMassPlotTask method create3DKendrickMassPlot.

/**
 * create 3D Kendrick mass plot
 */
private JFreeChart create3DKendrickMassPlot() {
    logger.info("Creating new 3D chart instance");
    appliedSteps++;
    // load dataseta
    dataset3D = new KendrickMassPlotXYZDataset(parameterSet);
    // copy and sort z-Values for min and max of the paint scale
    double[] copyZValues = new double[dataset3D.getItemCount(0)];
    for (int i = 0; i < dataset3D.getItemCount(0); i++) {
        copyZValues[i] = dataset3D.getZValue(0, i);
    }
    Arrays.sort(copyZValues);
    // get index in accordance to percentile windows
    int minScaleIndex = 0;
    int maxScaleIndex = copyZValues.length - 1;
    double min = 0;
    double max = 0;
    if (zAxisScaleType.equals("percentile")) {
        minScaleIndex = (int) Math.ceil(copyZValues.length * (zScaleRange.lowerEndpoint() / 100));
        maxScaleIndex = copyZValues.length - (int) (Math.ceil(copyZValues.length * ((100 - zScaleRange.upperEndpoint()) / 100)));
        if (zScaleRange.upperEndpoint() == 100) {
            maxScaleIndex = copyZValues.length - 1;
        }
        if (zScaleRange.lowerEndpoint() == 0) {
            minScaleIndex = 0;
        }
        min = copyZValues[minScaleIndex];
        max = copyZValues[maxScaleIndex];
    }
    if (zAxisScaleType.equals("custom")) {
        min = zScaleRange.lowerEndpoint();
        max = zScaleRange.upperEndpoint();
    }
    Paint[] contourColors = XYBlockPixelSizePaintScales.getPaintColors(zAxisScaleType, zScaleRange, paintScaleStyle);
    LookupPaintScale scale = null;
    scale = new LookupPaintScale(copyZValues[0], copyZValues[copyZValues.length - 1], new Color(0, 0, 0));
    double[] scaleValues = new double[contourColors.length];
    double delta = (max - min) / (contourColors.length - 1);
    double value = min;
    for (int i = 0; i < contourColors.length; i++) {
        scale.add(value, contourColors[i]);
        scaleValues[i] = value;
        value = value + delta;
    }
    // create chart
    chart = ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, dataset3D, PlotOrientation.VERTICAL, true, true, true);
    XYPlot plot = chart.getXYPlot();
    // 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();
    appliedSteps++;
    // Set paint scale
    renderer.setPaintScale(scale);
    ScatterPlotToolTipGenerator tooltipGenerator = new ScatterPlotToolTipGenerator(xAxisLabel, yAxisLabel, zAxisLabel, rows);
    renderer.setSeriesToolTipGenerator(0, tooltipGenerator);
    // 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);
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setOutlinePaint(Color.black);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainCrosshairPaint(Color.GRAY);
    plot.setRangeCrosshairPaint(Color.GRAY);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    // Legend
    NumberAxis scaleAxis = new NumberAxis(zAxisLabel);
    scaleAxis.setRange(min, max);
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    PaintScaleLegend legend = new PaintScaleLegend(scale, scaleAxis);
    legend.setStripOutlineVisible(false);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5.0);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setFrame(new BlockBorder(Color.white));
    legend.setPadding(new RectangleInsets(10, 10, 10, 10));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.LEFT);
    legend.getAxis().setLabelFont(legendFont);
    legend.getAxis().setTickLabelFont(legendFont);
    chart.addSubtitle(legend);
    return chart;
}
Also used : XYBlockPixelSizeRenderer(net.sf.mzmine.chartbasics.chartutils.XYBlockPixelSizeRenderer) PaintScaleLegend(org.jfree.chart.title.PaintScaleLegend) NumberAxis(org.jfree.chart.axis.NumberAxis) Color(java.awt.Color) BlockBorder(org.jfree.chart.block.BlockBorder) Paint(java.awt.Paint) Paint(java.awt.Paint) XYPlot(org.jfree.chart.plot.XYPlot) RectangleInsets(org.jfree.chart.ui.RectangleInsets) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) LookupPaintScale(org.jfree.chart.renderer.LookupPaintScale) ScatterPlotToolTipGenerator(net.sf.mzmine.chartbasics.chartutils.ScatterPlotToolTipGenerator) NameItemLabelGenerator(net.sf.mzmine.chartbasics.chartutils.NameItemLabelGenerator)

Example 2 with XYBlockPixelSizeRenderer

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

the class KendrickMassPlotWindow method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    if (command.equals("TOGGLE_BLOCK_SIZE")) {
        XYPlot plot = chart.getXYPlot();
        XYBlockPixelSizeRenderer renderer = (XYBlockPixelSizeRenderer) plot.getRenderer();
        int height = (int) renderer.getBlockHeightPixel();
        if (height == 1) {
            height++;
        } else if (height == 5) {
            height = 1;
        } else if (height < 5 && height != 1) {
            height++;
        }
        renderer.setBlockHeightPixel(height);
        renderer.setBlockWidthPixel(height);
    }
    if (command.equals("TOGGLE_BACK_COLOR")) {
        XYPlot plot = chart.getXYPlot();
        if (plot.getBackgroundPaint() == Color.WHITE) {
            plot.setBackgroundPaint(Color.BLACK);
        } else {
            plot.setBackgroundPaint(Color.WHITE);
        }
    }
    if (command.equals("TOGGLE_GRID")) {
        XYPlot plot = chart.getXYPlot();
        if (plot.getDomainGridlinePaint() == Color.BLACK) {
            plot.setDomainGridlinePaint(Color.WHITE);
            plot.setRangeGridlinePaint(Color.WHITE);
        } else {
            plot.setDomainGridlinePaint(Color.BLACK);
            plot.setRangeGridlinePaint(Color.BLACK);
        }
    }
    if (command.equals("TOGGLE_ANNOTATIONS")) {
        XYPlot plot = chart.getXYPlot();
        XYBlockPixelSizeRenderer renderer = (XYBlockPixelSizeRenderer) plot.getRenderer();
        Boolean itemNameVisible = renderer.getDefaultItemLabelsVisible();
        if (itemNameVisible == false) {
            renderer.setDefaultItemLabelsVisible(true);
        } else {
            renderer.setDefaultItemLabelsVisible(false);
        }
        if (plot.getBackgroundPaint() == Color.BLACK) {
            renderer.setDefaultItemLabelPaint(Color.WHITE);
        } else {
            renderer.setDefaultItemLabelPaint(Color.BLACK);
        }
    }
    // y axis commands
    if (command.equals("SHIFT_KMD_UP_Y")) {
        Double shiftValue = 0.01;
        yAxisShift = yAxisShift + shiftValue;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("SHIFT_KMD_DOWN_Y")) {
        Double shiftValue = -0.01;
        yAxisShift = yAxisShift + shiftValue;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_CHARGE_UP_Y")) {
        yAxisCharge = yAxisCharge + 1;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_CHARGE_DOWN_Y")) {
        if (yAxisCharge > 1) {
            yAxisCharge = yAxisCharge - 1;
        } else
            yAxisCharge = 1;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_DIVISOR_UP_Y")) {
        int minDivisor = getMinimumRecommendedDivisor(customYAxisKMBase);
        int maxDivisor = getMaximumRecommendedDivisor(customYAxisKMBase);
        if (yAxisDivisor >= minDivisor && yAxisDivisor < maxDivisor) {
            yAxisDivisor++;
            yAxisDivisor = checkDivisor(yAxisDivisor, useRKM_Y, customYAxisKMBase, true);
        }
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_DIVISOR_DOWN_Y")) {
        int minDivisor = getMinimumRecommendedDivisor(customYAxisKMBase);
        int maxDivisor = getMaximumRecommendedDivisor(customYAxisKMBase);
        if (yAxisDivisor > minDivisor && yAxisDivisor <= maxDivisor) {
            yAxisDivisor--;
            yAxisDivisor = checkDivisor(yAxisDivisor, useRKM_Y, customYAxisKMBase, false);
        }
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("TOGGLE_RKM_KMD_Y")) {
        XYPlot plot = chart.getXYPlot();
        if (useRKM_Y) {
            useRKM_Y = false;
            plot.getRangeAxis().setLabel("KMD(" + customYAxisKMBase + ")");
        } else {
            useRKM_Y = true;
            // if the divisor is round(R) switch to round(R)-1 for RKM plot
            yAxisDivisor = checkDivisor(yAxisDivisor, useRKM_Y, customYAxisKMBase, false);
            plot.getRangeAxis().setLabel("RKM(" + customYAxisKMBase + ")");
        }
        kendrickVariableChanged(plot);
    }
    // x axis commands
    if (command.equals("SHIFT_KMD_UP_X")) {
        Double shiftValue = 0.01;
        xAxisShift = xAxisShift + shiftValue;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("SHIFT_KMD_DOWN_X")) {
        Double shiftValue = -0.01;
        xAxisShift = xAxisShift + shiftValue;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_CHARGE_UP_X")) {
        xAxisCharge = xAxisCharge + 1;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_CHARGE_DOWN_X")) {
        if (xAxisCharge > 1) {
            xAxisCharge = xAxisCharge - 1;
        } else
            xAxisCharge = 1;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_DIVISOR_UP_X")) {
        int minDivisor = getMinimumRecommendedDivisor(customXAxisKMBase);
        int maxDivisor = getMaximumRecommendedDivisor(customXAxisKMBase);
        if (xAxisDivisor >= minDivisor && xAxisDivisor < maxDivisor) {
            xAxisDivisor++;
            xAxisDivisor = checkDivisor(xAxisDivisor, useRKM_X, customXAxisKMBase, true);
        }
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_DIVISOR_DOWN_X")) {
        int minDivisor = getMinimumRecommendedDivisor(customXAxisKMBase);
        int maxDivisor = getMaximumRecommendedDivisor(customXAxisKMBase);
        if (xAxisDivisor > minDivisor && xAxisDivisor <= maxDivisor) {
            xAxisDivisor--;
            xAxisDivisor = checkDivisor(xAxisDivisor, useRKM_X, customXAxisKMBase, false);
        }
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("TOGGLE_RKM_KMD_X")) {
        XYPlot plot = chart.getXYPlot();
        if (useRKM_X) {
            useRKM_X = false;
            plot.getDomainAxis().setLabel("KMD(" + customXAxisKMBase + ")");
        } else {
            useRKM_X = true;
            // if the divisor is round(R) switch to round(R)-1 for RKM plot
            xAxisDivisor = checkDivisor(xAxisDivisor, useRKM_X, customXAxisKMBase, false);
            plot.getDomainAxis().setLabel("RKM(" + customXAxisKMBase + ")");
        }
        kendrickVariableChanged(plot);
    }
    // z axis commands
    if (command.equals("SHIFT_KMD_UP_Z")) {
        Double shiftValue = 0.01;
        zAxisShift = zAxisShift + shiftValue;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("SHIFT_KMD_DOWN_Z")) {
        Double shiftValue = -0.01;
        zAxisShift = zAxisShift + shiftValue;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_CHARGE_UP_Z")) {
        zAxisCharge = zAxisCharge + 1;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_CHARGE_DOWN_Z")) {
        if (zAxisCharge > 1) {
            zAxisCharge = zAxisCharge - 1;
        } else
            zAxisCharge = 1;
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_DIVISOR_UP_Z")) {
        int minDivisor = getMinimumRecommendedDivisor(customZAxisKMBase);
        int maxDivisor = getMaximumRecommendedDivisor(customZAxisKMBase);
        if (zAxisDivisor >= minDivisor && zAxisDivisor < maxDivisor) {
            zAxisDivisor++;
            zAxisDivisor = checkDivisor(zAxisDivisor, useRKM_Z, customZAxisKMBase, true);
        }
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("CHANGE_DIVISOR_DOWN_Z")) {
        int minDivisor = getMinimumRecommendedDivisor(customZAxisKMBase);
        int maxDivisor = getMaximumRecommendedDivisor(customZAxisKMBase);
        if (zAxisDivisor > minDivisor && zAxisDivisor <= maxDivisor) {
            zAxisDivisor--;
            zAxisDivisor = checkDivisor(zAxisDivisor, useRKM_Z, customZAxisKMBase, false);
        }
        XYPlot plot = chart.getXYPlot();
        kendrickVariableChanged(plot);
    }
    if (command.equals("TOGGLE_RKM_KMD_Z")) {
        XYPlot plot = chart.getXYPlot();
        if (plot.getDataset() instanceof KendrickMassPlotXYZDataset) {
            if (useRKM_Z) {
                useRKM_Z = false;
                PaintScaleLegend legend = (PaintScaleLegend) chart.getSubtitle(1);
                legend.getAxis().setLabel("KMD(" + customZAxisKMBase + ")");
            } else {
                useRKM_Z = true;
                // if the divisor is round(R) switch to round(R)-1 for RKM plot
                zAxisDivisor = checkDivisor(zAxisDivisor, useRKM_Z, customZAxisKMBase, false);
                PaintScaleLegend legend = (PaintScaleLegend) chart.getSubtitle(1);
                legend.getAxis().setLabel("RKM(" + customZAxisKMBase + ")");
            }
            kendrickVariableChanged(plot);
        }
    }
}
Also used : XYBlockPixelSizeRenderer(net.sf.mzmine.chartbasics.chartutils.XYBlockPixelSizeRenderer) PaintScaleLegend(org.jfree.chart.title.PaintScaleLegend) XYPlot(org.jfree.chart.plot.XYPlot)

Example 3 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)

Example 4 with XYBlockPixelSizeRenderer

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

the class VanKrevelenDiagramTask method create3DVanKrevelenDiagram.

/**
 * create 3D Van Krevelen Diagram chart
 */
private JFreeChart create3DVanKrevelenDiagram() {
    logger.info("Creating new 3D chart instance");
    appliedSteps++;
    // load data set
    VanKrevelenDiagramXYZDataset dataset3D = new VanKrevelenDiagramXYZDataset(zAxisLabel, filteredRows);
    // copy and sort z-Values for min and max of the paint scale
    double[] copyZValues = new double[dataset3D.getItemCount(0)];
    for (int i = 0; i < dataset3D.getItemCount(0); i++) {
        copyZValues[i] = dataset3D.getZValue(0, i);
    }
    Arrays.sort(copyZValues);
    // get index in accordance to percentile windows
    int minScaleIndex = 0;
    int maxScaleIndex = copyZValues.length - 1;
    double min = 0;
    double max = 0;
    if (zAxisScaleType.equals("percentile")) {
        minScaleIndex = (int) Math.floor(copyZValues.length * (zScaleRange.lowerEndpoint() / 100));
        maxScaleIndex = copyZValues.length - (int) (Math.ceil(copyZValues.length * ((100 - zScaleRange.upperEndpoint()) / 100)));
        if (zScaleRange.upperEndpoint() == 100) {
            maxScaleIndex = copyZValues.length - 1;
        }
        if (zScaleRange.lowerEndpoint() == 0) {
            minScaleIndex = 0;
        }
        min = copyZValues[minScaleIndex];
        max = copyZValues[maxScaleIndex];
    }
    if (zAxisScaleType.equals("custom")) {
        min = zScaleRange.lowerEndpoint();
        max = zScaleRange.upperEndpoint();
    }
    // create paint scale for third dimension
    Paint[] contourColors = XYBlockPixelSizePaintScales.getPaintColors(zAxisScaleType, zScaleRange, paintScaleStyle);
    LookupPaintScale scale = null;
    scale = new LookupPaintScale(copyZValues[0], copyZValues[copyZValues.length - 1], new Color(0, 0, 0));
    double[] scaleValues = new double[contourColors.length];
    double delta = (max - min) / (contourColors.length - 1);
    double value = min;
    for (int i = 0; i < contourColors.length; i++) {
        scale.add(value, contourColors[i]);
        scaleValues[i] = value;
        value = value + delta;
    }
    // create chart
    chart = ChartFactory.createScatterPlot(title, "O/C", "H/C", dataset3D, PlotOrientation.VERTICAL, true, true, false);
    // set renderer
    XYBlockPixelSizeRenderer renderer = new XYBlockPixelSizeRenderer();
    XYPlot plot = chart.getXYPlot();
    appliedSteps++;
    renderer.setPaintScale(scale);
    double maxX = plot.getDomainAxis().getRange().getUpperBound();
    double maxY = plot.getRangeAxis().getRange().getUpperBound();
    renderer.setBlockWidth(0.001);
    renderer.setBlockHeight(renderer.getBlockWidth() / (maxX / maxY));
    // set tooltip generator
    ScatterPlotToolTipGenerator tooltipGenerator = new ScatterPlotToolTipGenerator("O/C", "H/C", zAxisLabel, filteredRows);
    renderer.setSeriesToolTipGenerator(0, tooltipGenerator);
    renderer.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -45), true);
    // set item label generator
    NameItemLabelGenerator generator = new NameItemLabelGenerator(filteredRows);
    renderer.setDefaultItemLabelGenerator(generator);
    renderer.setDefaultItemLabelsVisible(false);
    renderer.setDefaultItemLabelFont(legendFont);
    plot.setRenderer(renderer);
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));
    plot.setOutlinePaint(Color.black);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainCrosshairPaint(Color.GRAY);
    plot.setRangeCrosshairPaint(Color.GRAY);
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);
    // Legend
    NumberAxis scaleAxis = new NumberAxis(zAxisLabel);
    scaleAxis.setRange(min, max);
    scaleAxis.setAxisLinePaint(Color.white);
    scaleAxis.setTickMarkPaint(Color.white);
    PaintScaleLegend legend = new PaintScaleLegend(scale, scaleAxis);
    legend.setStripOutlineVisible(false);
    legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    legend.setAxisOffset(5.0);
    legend.setMargin(new RectangleInsets(5, 5, 5, 5));
    legend.setFrame(new BlockBorder(Color.white));
    legend.setPadding(new RectangleInsets(10, 10, 10, 10));
    legend.setStripWidth(10);
    legend.setPosition(RectangleEdge.LEFT);
    legend.getAxis().setLabelFont(legendFont);
    legend.getAxis().setTickLabelFont(legendFont);
    chart.addSubtitle(legend);
    appliedSteps++;
    return chart;
}
Also used : XYBlockPixelSizeRenderer(net.sf.mzmine.chartbasics.chartutils.XYBlockPixelSizeRenderer) PaintScaleLegend(org.jfree.chart.title.PaintScaleLegend) NumberAxis(org.jfree.chart.axis.NumberAxis) Color(java.awt.Color) BlockBorder(org.jfree.chart.block.BlockBorder) Paint(java.awt.Paint) Paint(java.awt.Paint) XYPlot(org.jfree.chart.plot.XYPlot) RectangleInsets(org.jfree.chart.ui.RectangleInsets) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition) LookupPaintScale(org.jfree.chart.renderer.LookupPaintScale) ScatterPlotToolTipGenerator(net.sf.mzmine.chartbasics.chartutils.ScatterPlotToolTipGenerator) NameItemLabelGenerator(net.sf.mzmine.chartbasics.chartutils.NameItemLabelGenerator)

Example 5 with XYBlockPixelSizeRenderer

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

the class VanKrevelenDiagramTask method create2DVanKrevelenDiagram.

/**
 * create 2D Van Krevelen Diagram chart
 */
private JFreeChart create2DVanKrevelenDiagram() {
    logger.info("Creating new 2D chart instance");
    appliedSteps++;
    // load dataset
    VanKrevelenDiagramXYDataset dataset2D = new VanKrevelenDiagramXYDataset(filteredRows);
    // create chart
    chart = ChartFactory.createScatterPlot(title, "O/C", "H/C", dataset2D, PlotOrientation.VERTICAL, true, true, false);
    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 renderer
    XYBlockPixelSizeRenderer renderer = new XYBlockPixelSizeRenderer();
    // calc block sizes
    double maxX = plot.getDomainAxis().getRange().getUpperBound();
    double maxY = plot.getRangeAxis().getRange().getUpperBound();
    renderer.setBlockWidth(0.001);
    renderer.setBlockHeight(renderer.getBlockWidth() / (maxX / maxY));
    // set tooltip generator
    ScatterPlotToolTipGenerator tooltipGenerator = new ScatterPlotToolTipGenerator("O/C", "H/C", zAxisLabel, filteredRows);
    renderer.setSeriesToolTipGenerator(0, tooltipGenerator);
    plot.setRenderer(renderer);
    // set item label generator
    NameItemLabelGenerator generator = new NameItemLabelGenerator(filteredRows);
    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) 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