Java Code Examples for org.jfree.chart.plot.CombinedDomainXYPlot#setDomainCrosshairVisible()
The following examples show how to use
org.jfree.chart.plot.CombinedDomainXYPlot#setDomainCrosshairVisible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MirrorChartFactory.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
private static JFreeChart createMirrorChart(String labelA, double precursorMZA, double rtA, DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB, boolean showTitle, boolean showLegend) { PseudoSpectrumDataSet data = dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA); PseudoSpectrumDataSet dataMirror = dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB); NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat(); NumberFormat intensityFormat = new DecimalFormat("0.#"); // set the X axis (retention time) properties NumberAxis xAxis = new NumberAxis("m/z"); xAxis.setNumberFormatOverride(mzForm); xAxis.setUpperMargin(0.08); xAxis.setLowerMargin(0.00); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); xAxis.setAutoRangeIncludesZero(false); xAxis.setMinorTickCount(5); PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false); PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false); // create subplot 1... final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]"); final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); rangeAxis1.setNumberFormatOverride(intensityFormat); rangeAxis1.setAutoRangeIncludesZero(true); rangeAxis1.setAutoRangeStickyZero(true); // create subplot 2... final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]"); rangeAxis2.setNumberFormatOverride(intensityFormat); rangeAxis2.setAutoRangeIncludesZero(true); rangeAxis2.setAutoRangeStickyZero(true); rangeAxis2.setInverted(true); final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(xAxis); plot.setGap(0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // set the plot properties plot.setBackgroundPaint(Color.white); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); chart.getTitle().setVisible(false); chart.getXYPlot().setRangeZeroBaselineVisible(true); chart.getTitle().setVisible(showTitle); chart.getLegend().setVisible(showLegend); return chart; }
Example 2
Source File: SpectrumChartFactory.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public static EChartPanel createMirrorChartPanel(String labelA, double precursorMZA, double rtA, DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB, boolean showTitle, boolean showLegend) { PseudoSpectrumDataSet data = dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA); PseudoSpectrumDataSet dataMirror = dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB); NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat(); NumberFormat intensityFormat = new DecimalFormat("0.#"); // set the X axis (retention time) properties NumberAxis xAxis = new NumberAxis("m/z"); xAxis.setNumberFormatOverride(mzForm); xAxis.setUpperMargin(0.08); xAxis.setLowerMargin(0.00); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); xAxis.setAutoRangeIncludesZero(false); xAxis.setMinorTickCount(5); PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false); PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false); // create subplot 1... final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]"); final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); rangeAxis1.setNumberFormatOverride(intensityFormat); rangeAxis1.setAutoRangeIncludesZero(true); rangeAxis1.setAutoRangeStickyZero(true); // create subplot 2... final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]"); rangeAxis2.setNumberFormatOverride(intensityFormat); rangeAxis2.setAutoRangeIncludesZero(true); rangeAxis2.setAutoRangeStickyZero(true); rangeAxis2.setInverted(true); final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // set the plot properties plot.setBackgroundPaint(Color.white); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set crosshair (selection) properties plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); chart.getTitle().setVisible(false); // chart.getXYPlot().setRangeZeroBaselineVisible(true); chart.getTitle().setVisible(showTitle); chart.getLegend().setVisible(showLegend); return new EChartPanel(chart); }