Java Code Examples for org.jfree.chart.axis.NumberAxis#setLowerMargin()
The following examples show how to use
org.jfree.chart.axis.NumberAxis#setLowerMargin() .
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: DensityPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private void createUI() { plot = new XYImagePlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); domainAxis.setAutoRangeIncludesZero(false); rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.getRenderer().setBaseToolTipGenerator(new XYPlotToolTipGenerator()); JFreeChart chart = new JFreeChart(CHART_TITLE, plot); ChartFactory.getChartTheme().apply(chart); chart.removeLegend(); createUI(createChartPanel(chart), createOptionsPanel(), bindingContext); updateUIState(); }
Example 2
Source File: AbstractChartsPanel.java From computational-economy with GNU General Public License v3.0 | 6 votes |
protected void configureChart(final JFreeChart chart) { chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); final DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); final NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM")); valueAxis.setAutoRangeIncludesZero(true); valueAxis.setUpperMargin(0.15); valueAxis.setLowerMargin(0.15); }
Example 3
Source File: ChartFactory.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a stacked XY area plot. The chart object returned by this * method uses an {@link XYPlot} instance as the plot, with a * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. * * @param title the chart title (<code>null</code> permitted). * @param xAxisLabel a label for the X-axis (<code>null</code> permitted). * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted). * @param dataset the dataset for the chart (<code>null</code> permitted). * @param legend a flag specifying whether or not a legend is required. * * @return A stacked XY area chart. */ public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset, boolean legend) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); NumberAxis yAxis = new NumberAxis(yAxisLabel); StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setOutline(true); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setRangeAxis(yAxis); // forces recalculation of the axis range JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); currentTheme.apply(chart); return chart; }
Example 4
Source File: ProductIonFilterPlot.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public void setAxisTypes(Object xAxisType) { NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties final NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis(); if (xAxisType.equals(ProductIonFilterParameters.xAxisPrecursor)) { xAxis.setLabel("Precursor ion m/z"); xAxis.setNumberFormatOverride(mzFormat); } else { xAxis.setLabel("Retention time"); xAxis.setNumberFormatOverride(rtFormat); } xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); xAxis.setAutoRangeIncludesZero(false); // set the Y axis (intensity) properties final NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis(); yAxis.setLabel("Product ion m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); }
Example 5
Source File: NeutralLossPlot.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public void setAxisTypes(Object xAxisType) { NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties final NumberAxis xAxis = (NumberAxis) this.plot.getDomainAxis(); if (xAxisType.equals(NeutralLossParameters.xAxisPrecursor)) { xAxis.setLabel("Precursor m/z"); xAxis.setNumberFormatOverride(mzFormat); } else { xAxis.setLabel("Retention time"); xAxis.setNumberFormatOverride(rtFormat); } xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); xAxis.setAutoRangeIncludesZero(false); // set the Y axis (intensity) properties final NumberAxis yAxis = (NumberAxis) this.plot.getRangeAxis(); yAxis.setLabel("Neutral loss (Da)"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); }
Example 6
Source File: MsSpectrumPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
public void initialize() { final JFreeChart chart = chartNode.getChart(); final XYPlot plot = chart.getXYPlot(); // Do not set colors and strokes dynamically. They are instead provided // by the dataset and configured in configureRenderer() plot.setDrawingSupplier(null); plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (m/z) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("m/z"); xAxis.setUpperMargin(0.03); xAxis.setLowerMargin(0.03); xAxis.setRangeType(RangeType.POSITIVE); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel("Intensity"); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setAutoRangeIncludesZero(true); // set the fixed number formats, because otherwise JFreeChart sometimes // shows exponent, sometimes it doesn't DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); xAxis.setNumberFormatOverride(mzFormat); DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); yAxis.setNumberFormatOverride(intensityFormat); chartTitle = chartNode.getChart().getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends MsSpectrumDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (MsSpectrumDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (MsSpectrumDataSet dataset : datasets) { int datasetIndex = plot.indexOf(dataset); XYItemRenderer renderer = plot.getRenderer(datasetIndex); renderer.setBaseItemLabelsVisible(newVal); } }); legendVisible.addListener((prop, oldVal, newVal) -> { legend.setVisible(newVal); }); }
Example 7
Source File: ScatterPlot.java From Benchmark with GNU General Public License v2.0 | 4 votes |
public void initializePlot( XYPlot xyplot ) { NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); rangeAxis.setRange(-9.99, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); domainAxis.setRange(-5, 175); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); xyplot.setOutlineVisible(true); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); Point2D legendLocation = new Point2D.Double( 101, -10 ); makeRect(xyplot, legendLocation, 120, 74, Color.WHITE ); Point2D triangleLocation = new Point2D.Double( 101, -10 ); Color grey = new Color(0.1f,0.1f,0.1f,0.1f); makeTriangle(xyplot, triangleLocation, grey ); makeGuessingLine( xyplot ); }
Example 8
Source File: PseudoSpectrum.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public static JFreeChart createChart(PseudoSpectrumDataSet dataset, RawDataFile raw, boolean sum, String title) { // JFreeChart chart = ChartFactory.createXYLineChart(title, // title "m/z", // x-axis label "Intensity", // y-axis label dataset, // data set PlotOrientation.VERTICAL, // orientation true, // isotopeFlag, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); chart.getTitle().setVisible(false); // set the plot properties XYPlot plot = chart.getXYPlot(); 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); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(mzFormat); xAxis.setUpperMargin(0.08); xAxis.setLowerMargin(0.00); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); xAxis.setAutoRangeIncludesZero(true); xAxis.setMinorTickCount(5); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(intensityFormat); yAxis.setUpperMargin(0.20); PseudoSpectraRenderer renderer = new PseudoSpectraRenderer(Color.BLACK, false); plot.setRenderer(0, renderer); plot.setRenderer(1, renderer); plot.setRenderer(2, renderer); renderer.setSeriesVisibleInLegend(1, false); renderer.setSeriesPaint(2, Color.ORANGE); // return chart; }
Example 9
Source File: SpectrumChartFactory.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public static JFreeChart createChart(PseudoSpectrumDataSet dataset, boolean showTitle, boolean showLegend, double rt, double precursorMZ) { // if (dataset == null) return null; // NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat(); NumberFormat rtForm = MZmineCore.getConfiguration().getRTFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); String title = ""; if (precursorMZ == 0) title = "RT=" + mzForm.format(precursorMZ); else title = MessageFormat.format("MSMS for m/z={0} RT={1}", mzForm.format(precursorMZ), rtForm.format(rt)); JFreeChart chart = ChartFactory.createXYLineChart(title, // title "m/z", // x-axis label "Intensity", // y-axis label dataset, // data set PlotOrientation.VERTICAL, // orientation true, // isotopeFlag, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); chart.getTitle().setVisible(false); // set the plot properties XYPlot plot = chart.getXYPlot(); 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); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(mzForm); xAxis.setUpperMargin(0.08); xAxis.setLowerMargin(0.00); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); xAxis.setAutoRangeIncludesZero(true); xAxis.setMinorTickCount(5); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(intensityFormat); yAxis.setUpperMargin(0.20); PseudoSpectraRenderer renderer = new PseudoSpectraRenderer(Color.BLACK, false); plot.setRenderer(0, renderer); plot.setRenderer(1, renderer); plot.setRenderer(2, renderer); renderer.setSeriesVisibleInLegend(1, false); renderer.setSeriesPaint(2, Color.ORANGE); // chart.getTitle().setVisible(showTitle); chart.getLegend().setVisible(showLegend); // if (precursorMZ != 0) addPrecursorMarker(chart, precursorMZ); return chart; }
Example 10
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); }
Example 11
Source File: MsMsPlot.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
MsMsPlot(final ActionListener listener, RawDataFile rawDataFile, MsMsVisualizerWindow visualizer, MsMsDataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(null, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = ChartFactory.createXYLineChart("", // title "", // x-axis label "", // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend false, // generate tooltips false // generate URLs ); chart.setBackgroundPaint(Color.white); setChart(chart); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new MsMsPlotRenderer(); plot.setRenderer(0, mainRenderer); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // Add EMF and EPS options to the save as menu JPopupMenu popupMenu = getPopupMenu(); JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3); GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF"); GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS"); // Register for mouse-wheel events addMouseWheelListener(this); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 12
Source File: SimpleScatterPlot.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel, String yLabel) { super(null, true); setBackground(Color.white); setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); xAxis = new NumberAxis(xLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); yAxis = new NumberAxis(yLabel); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new DefaultXYZDataset(); int length = Math.min(xValues.length, yValues.length); double[][] data = new double[3][length]; System.arraycopy(xValues, 0, data[0], 0, length); System.arraycopy(yValues, 0, data[1], 0, length); System.arraycopy(colors, 0, data[2], 0, length); xyDataset.addSeries(SERIES_ID, data); XYDotRenderer renderer = new XYDotRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = xyDataset.getZ(row, col).doubleValue(); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDotHeight(3); renderer.setDotWidth(3); plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 13
Source File: RTMZPlot.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
public RTMZPlot(RTMZAnalyzerWindow masterFrame, AbstractXYZDataset dataset, InterpolatingLookupPaintScale paintScale) { super(null); this.paintScale = paintScale; chart = ChartFactory.createXYAreaChart("", "Retention time", "m/z", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.001); xAxis.setLowerMargin(0.001); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); plot.setDataset(dataset); spotRenderer = new RTMZRenderer(dataset, paintScale); plot.setRenderer(spotRenderer); spotRenderer.setDefaultToolTipGenerator(new RTMZToolTipGenerator()); // Add a paintScaleLegend to chart paintScaleAxis = new NumberAxis("Logratio"); paintScaleAxis.setRange(paintScale.getLowerBound(), paintScale.getUpperBound()); paintScaleLegend = new PaintScaleLegend(paintScale, paintScaleAxis); paintScaleLegend.setPosition(plot.getDomainAxisEdge()); paintScaleLegend.setMargin(5, 25, 5, 25); chart.addSubtitle(paintScaleLegend); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 14
Source File: ChromatogramPlotWindowController.java From old-mzmine3 with GNU General Public License v2.0 | 4 votes |
@FXML public void initialize() { final JFreeChart chart = chartNode.getChart(); final XYPlot plot = chart.getXYPlot(); // Do not set colors and strokes dynamically. They are instead provided // by the dataset and configured in configureRenderer() plot.setDrawingSupplier(null); plot.setDomainGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setRangeGridlinePaint(JavaFXUtil.convertColorToAWT(gridColor)); plot.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setDomainCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor)); plot.setRangeCrosshairPaint(JavaFXUtil.convertColorToAWT(crossHairColor)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // chart properties chart.setBackgroundPaint(JavaFXUtil.convertColorToAWT(backgroundColor)); // legend properties LegendTitle legend = chart.getLegend(); // legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setLabel("Retention time (min)"); xAxis.setUpperMargin(0.03); xAxis.setLowerMargin(0.03); xAxis.setRangeType(RangeType.POSITIVE); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLabel("Intensity"); yAxis.setRangeType(RangeType.POSITIVE); yAxis.setAutoRangeIncludesZero(true); // set the fixed number formats, because otherwise JFreeChart sometimes // shows exponent, sometimes it doesn't DecimalFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); xAxis.setNumberFormatOverride(mzFormat); DecimalFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); yAxis.setNumberFormatOverride(intensityFormat); chartTitle = chartNode.getChart().getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartTitle.setText("Chromatogram"); chartNode.setCursor(Cursor.CROSSHAIR); // Remove the dataset if it is removed from the list datasets.addListener((Change<? extends ChromatogramPlotDataSet> c) -> { while (c.next()) { if (c.wasRemoved()) { for (ChromatogramPlotDataSet ds : c.getRemoved()) { int index = plot.indexOf(ds); plot.setDataset(index, null); } } } }); itemLabelsVisible.addListener((prop, oldVal, newVal) -> { for (ChromatogramPlotDataSet dataset : datasets) { int datasetIndex = plot.indexOf(dataset); XYItemRenderer renderer = plot.getRenderer(datasetIndex); renderer.setBaseItemLabelsVisible(newVal); } }); legendVisible.addListener((prop, oldVal, newVal) -> { legend.setVisible(newVal); }); }
Example 15
Source File: SimpleScatterPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public SimpleScatterPlot(double[] xValues, double[] yValues, double[] colors, String xLabel, String yLabel) { super(null); // setBackground(Color.white); setCursor(Cursor.CROSSHAIR); xAxis = new NumberAxis(xLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); yAxis = new NumberAxis(yLabel); yAxis.setAutoRangeIncludesZero(false); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); xyDataset = new DefaultXYZDataset(); int length = Math.min(xValues.length, yValues.length); double[][] data = new double[3][length]; System.arraycopy(xValues, 0, data[0], 0, length); System.arraycopy(yValues, 0, data[1], 0, length); System.arraycopy(colors, 0, data[2], 0, length); xyDataset.addSeries(SERIES_ID, data); XYDotRenderer renderer = new XYDotRenderer() { @Override public Paint getItemPaint(int row, int col) { double c = xyDataset.getZ(row, col).doubleValue(); return Color.getHSBColor((float) c, 1.0f, 1.0f); } }; renderer.setDotHeight(3); renderer.setDotWidth(3); plot = new XYPlot(xyDataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinesVisible(true); chart = new JFreeChart("", new Font("SansSerif", Font.BOLD, 12), plot, false); chart.setBackgroundPaint(Color.white); super.setChart(chart); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 16
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 17
Source File: RTMZPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public RTMZPlot(RTMZAnalyzerWindow masterFrame, AbstractXYZDataset dataset, InterpolatingLookupPaintScale paintScale) { super(null); this.paintScale = paintScale; chart = ChartFactory.createXYAreaChart("", "Retention time", "m/z", dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title TextTitle chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chart.removeSubtitle(chartTitle); // disable maximum size (we don't want scaling) // setMaximumDrawWidth(Integer.MAX_VALUE); // setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); NumberFormat rtFormat = MZmineCore.getConfiguration().getRTFormat(); NumberFormat mzFormat = MZmineCore.getConfiguration().getMZFormat(); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.001); xAxis.setLowerMargin(0.001); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); plot.setDataset(dataset); spotRenderer = new RTMZRenderer(dataset, paintScale); plot.setRenderer(spotRenderer); spotRenderer.setDefaultToolTipGenerator(new RTMZToolTipGenerator()); // Add a paintScaleLegend to chart paintScaleAxis = new NumberAxis("Logratio"); paintScaleAxis.setRange(paintScale.getLowerBound(), paintScale.getUpperBound()); paintScaleLegend = new PaintScaleLegend(paintScale, paintScaleAxis); paintScaleLegend.setPosition(plot.getDomainAxisEdge()); paintScaleLegend.setMargin(5, 25, 5, 25); chart.addSubtitle(paintScaleLegend); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 18
Source File: TwoDPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
TwoDPlot(RawDataFile rawDataFile, TwoDVisualizerWindow visualizer, TwoDDataSet dataset, Range<Double> rtRange, Range<Double> mzRange, String whichPlotTypeStr) { super(null); this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // setBackground(Color.white); setCursor(Cursor.CROSSHAIR); // set the X axis (retention time) properties xAxis = new NumberAxis("Retention time"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0); xAxis.setLowerMargin(0); // set the Y axis (intensity) properties yAxis = new NumberAxis("m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0); yAxis.setLowerMargin(0); // set the plot properties if (whichPlotTypeStr == "default") { plot = new TwoDXYPlot(dataset, rtRange, mzRange, xAxis, yAxis); } else if (whichPlotTypeStr == "point2D") { plot = new PointTwoDXYPlot(dataset, rtRange, mzRange, xAxis, yAxis); } plot.setBackgroundPaint(Color.white); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // chart properties chart = new JFreeChart("", titleFont, plot, false); chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // disable maximum size (we don't want scaling) // setMaximumDrawWidth(Integer.MAX_VALUE); // setMaximumDrawHeight(Integer.MAX_VALUE); // set crosshair (selection) properties plot.setRangeCrosshairVisible(false); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 19
Source File: MsMsPlot.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
MsMsPlot(RawDataFile rawDataFile, MsMsVisualizerWindow visualizer, MsMsDataSet dataset, Range<Double> rtRange, Range<Double> mzRange) { super(ChartFactory.createXYLineChart("", "", "", null, PlotOrientation.VERTICAL, true, true, false), true, true, false, false, true); this.visualizer = visualizer; this.rawDataFile = rawDataFile; this.rtRange = rtRange; this.mzRange = mzRange; // initialize the chart by default time series chart from factory chart = getChart(); chart.setBackgroundPaint(Color.white); // disable maximum size (we don't want scaling) // setMaximumDrawWidth(Integer.MAX_VALUE); // setMaximumDrawHeight(Integer.MAX_VALUE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // Set the domain log axis xAxis = new NumberAxis("Retention time (min)"); xAxis.setAutoRangeIncludesZero(false); xAxis.setNumberFormatOverride(rtFormat); xAxis.setUpperMargin(0.01); xAxis.setLowerMargin(0.01); plot.setDomainAxis(xAxis); // Set the range log axis yAxis = new NumberAxis("Precursor m/z"); yAxis.setAutoRangeIncludesZero(false); yAxis.setNumberFormatOverride(mzFormat); yAxis.setUpperMargin(0.1); yAxis.setLowerMargin(0.1); plot.setRangeAxis(yAxis); // Set crosshair properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // Create renderers mainRenderer = new MsMsPlotRenderer(); plot.setRenderer(0, mainRenderer); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); chartSubTitle = new TextTitle(); chartSubTitle.setFont(subTitleFont); chartSubTitle.setMargin(5, 0, 0, 0); chart.addSubtitle(chartSubTitle); // Add data sets; plot.setDataset(0, dataset); // set rendering order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); peakDataRenderer = new PeakDataRenderer(); // reset zoom history ZoomHistory history = getZoomHistory(); if (history != null) history.clear(); }
Example 20
Source File: SpectrumChartFactory.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
public static JFreeChart createChart(PseudoSpectrumDataSet dataset, boolean showTitle, boolean showLegend, double rt, double precursorMZ) { // if (dataset == null) return null; // NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat(); NumberFormat rtForm = MZmineCore.getConfiguration().getRTFormat(); NumberFormat intensityFormat = MZmineCore.getConfiguration().getIntensityFormat(); String title = ""; if (precursorMZ == 0) title = "RT=" + mzForm.format(precursorMZ); else title = MessageFormat.format("MSMS for m/z={0} RT={1}", mzForm.format(precursorMZ), rtForm.format(rt)); JFreeChart chart = ChartFactory.createXYLineChart(title, // title "m/z", // x-axis label "Intensity", // y-axis label dataset, // data set PlotOrientation.VERTICAL, // orientation true, // isotopeFlag, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); chart.getTitle().setVisible(false); // set the plot properties XYPlot plot = chart.getXYPlot(); 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); // set the X axis (retention time) properties NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(mzForm); xAxis.setUpperMargin(0.08); xAxis.setLowerMargin(0.00); xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20)); xAxis.setAutoRangeIncludesZero(true); xAxis.setMinorTickCount(5); // set the Y axis (intensity) properties NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(intensityFormat); yAxis.setUpperMargin(0.20); PseudoSpectraRenderer renderer = new PseudoSpectraRenderer(Color.BLACK, false); plot.setRenderer(0, renderer); plot.setRenderer(1, renderer); plot.setRenderer(2, renderer); renderer.setSeriesVisibleInLegend(1, false); renderer.setSeriesPaint(2, Color.ORANGE); // chart.getTitle().setVisible(showTitle); chart.getLegend().setVisible(showLegend); // if (precursorMZ != 0) addPrecursorMarker(chart, precursorMZ); return chart; }