Java Code Examples for org.jfree.chart.axis.NumberAxis#setLabel()

The following examples show how to use org.jfree.chart.axis.NumberAxis#setLabel() . 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: SpectralMatchPanel.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void setChartFont(Font chartFont) {
  this.chartFont = chartFont;
  if (mirrorChart != null) {

    // add datasets and renderer
    // set up renderer
    CombinedDomainXYPlot domainPlot = (CombinedDomainXYPlot) mirrorChart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) domainPlot.getDomainAxis();
    axis.setLabel("m/z");
    XYPlot queryPlot = (XYPlot) domainPlot.getSubplots().get(0);
    XYPlot libraryPlot = (XYPlot) domainPlot.getSubplots().get(1);
    domainPlot.getDomainAxis().setLabelFont(chartFont);
    domainPlot.getDomainAxis().setTickLabelFont(chartFont);
    queryPlot.getRangeAxis().setLabelFont(chartFont);
    queryPlot.getRangeAxis().setTickLabelFont(chartFont);
    libraryPlot.getRangeAxis().setLabelFont(chartFont);
    libraryPlot.getRangeAxis().setTickLabelFont(chartFont);
  }
}
 
Example 2
Source File: ProductIonFilterPlot.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
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 3
Source File: NeutralLossPlot.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
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 4
Source File: SpectralMatchPanel.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public void setChartFont(Font chartFont) {
  this.chartFont = chartFont;
  if (mirrorChart != null) {

    // add datasets and renderer
    // set up renderer
    CombinedDomainXYPlot domainPlot = (CombinedDomainXYPlot) mirrorChart.getChart().getXYPlot();
    NumberAxis axis = (NumberAxis) domainPlot.getDomainAxis();
    axis.setLabel("m/z");
    XYPlot queryPlot = (XYPlot) domainPlot.getSubplots().get(0);
    XYPlot libraryPlot = (XYPlot) domainPlot.getSubplots().get(1);
    domainPlot.getDomainAxis().setLabelFont(chartFont);
    domainPlot.getDomainAxis().setTickLabelFont(chartFont);
    queryPlot.getRangeAxis().setLabelFont(chartFont);
    queryPlot.getRangeAxis().setTickLabelFont(chartFont);
    libraryPlot.getRangeAxis().setLabelFont(chartFont);
    libraryPlot.getRangeAxis().setTickLabelFont(chartFont);
  }
}
 
Example 5
Source File: CombinedModulePlot.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void setAxes(NumberAxis axis, AxisType axisType, NumberFormat format) {
  axis.setLabel(axisType.toString());
  axis.setAutoRangeIncludesZero(false);
  axis.setNumberFormatOverride(format);
  axis.setUpperMargin(0);
  axis.setLowerMargin(0);
}
 
Example 6
Source File: MsSpectrumPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
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: ChromatogramPlotWindowController.java    From old-mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
@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);
  });
}