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

The following examples show how to use org.jfree.chart.axis.NumberAxis#setNumberFormatOverride() . 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: AlignmentRansacPlot.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public void printAlignmentChart(String axisTitleX, String axisTitleY) {
  try {
    toolTipGenerator = new AlignmentPreviewTooltipGenerator(axisTitleX, axisTitleY);
    plot.getRenderer().setDefaultToolTipGenerator(toolTipGenerator);
    NumberAxis xAxis = new NumberAxis(axisTitleX);
    xAxis.setNumberFormatOverride(rtFormat);
    xAxis.setAutoRangeIncludesZero(false);
    plot.setDomainAxis(xAxis);

    NumberAxis yAxis = new NumberAxis(axisTitleY);
    yAxis.setNumberFormatOverride(rtFormat);
    yAxis.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(yAxis);

  } catch (Exception e) {
  }
}
 
Example 2
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 3
Source File: AEChartComposite.java    From offspring with MIT License 6 votes vote down vote up
private JFreeChart createChart(Asset asset, String title) {
  XYDataset priceDataset = createPriceDataset();
  JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(title, // title
      "Date",       // x title
      "Price",      // y title
      priceDataset, // dataset
      false,        // legend
      true,         // tooltips
      false);

  XYPlot xyplot = (XYPlot) jfreechart.getPlot();

  NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis();
  numberaxis.setLowerMargin(0.40000000000000002D);

  DecimalFormat decimalformat = new DecimalFormat("#.##");
  numberaxis.setNumberFormatOverride(decimalformat);

  return jfreechart;
}
 
Example 4
Source File: AlignmentRansacPlot.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public void printAlignmentChart(String axisTitleX, String axisTitleY) {
  try {
    toolTipGenerator = new AlignmentPreviewTooltipGenerator(axisTitleX, axisTitleY);
    plot.getRenderer().setDefaultToolTipGenerator(toolTipGenerator);
    NumberAxis xAxis = new NumberAxis(axisTitleX);
    xAxis.setNumberFormatOverride(rtFormat);
    xAxis.setAutoRangeIncludesZero(false);
    plot.setDomainAxis(xAxis);

    NumberAxis yAxis = new NumberAxis(axisTitleY);
    yAxis.setNumberFormatOverride(rtFormat);
    yAxis.setAutoRangeIncludesZero(false);
    plot.setRangeAxis(yAxis);

  } catch (Exception e) {
  }
}
 
Example 5
Source File: DSWorkbenchStatsFrame.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
private void setupChart(String pInitialId, XYDataset pInitialDataset) {
    chart = ChartFactory.createTimeSeriesChart(
            "Spielerstatistiken", // title
            "Zeiten", // x-axis label
            pInitialId, // y-axis label
            pInitialDataset, // data
            jShowLegend.isSelected(), // create legend?
            true, // generate tooltips?
            false // generate URLs?
            );
    
    chart.setBackgroundPaint(Constants.DS_BACK);
    XYPlot plot = (XYPlot) chart.getPlot();
    setupPlotDrawing(plot);
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    for (int i = 0; i < plot.getSeriesCount(); i++) {
        renderer.setSeriesLinesVisible(i, jShowLines.isSelected());
        renderer.setSeriesShapesVisible(i, jShowDataPoints.isSelected());
        plot.setRenderer(i, renderer);
    }
    
    renderer.setDefaultItemLabelsVisible(jShowItemValues.isSelected());
    renderer.setDefaultItemLabelGenerator(new org.jfree.chart.labels.StandardXYItemLabelGenerator());
    renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), NumberFormat.getInstance()));
    int lastDataset = plot.getDatasetCount() - 1;
    if (lastDataset > 0) {
        plot.getRangeAxis().setAxisLinePaint(plot.getLegendItems().get(lastDataset).getLinePaint());
        plot.getRangeAxis().setLabelPaint(plot.getLegendItems().get(lastDataset).getLinePaint());
        plot.getRangeAxis().setTickLabelPaint(plot.getLegendItems().get(lastDataset).getLinePaint());
        plot.getRangeAxis().setTickMarkPaint(plot.getLegendItems().get(lastDataset).getLinePaint());
    }
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMinimumFractionDigits(0);
    nf.setMaximumFractionDigits(0);
    NumberAxis na = ((NumberAxis) plot.getRangeAxis());
    if (na != null) {
        na.setNumberFormatOverride(nf);
    }
}
 
Example 6
Source File: DSWorkbenchStatsFrame.java    From dsworkbench with Apache License 2.0 5 votes vote down vote up
private void addDataset(String pId, XYDataset pDataset) {
    if (chart == null) {
        setupChart(pId, pDataset);
    } else {
        XYPlot plot = (XYPlot) chart.getPlot();
        plot.setDataset(plot.getDatasetCount(), pDataset);
        NumberAxis axis = new NumberAxis(pId);
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMinimumFractionDigits(0);
        nf.setMaximumFractionDigits(0);
        axis.setNumberFormatOverride(nf);
        plot.setRangeAxis(plot.getDatasetCount() - 1, axis);
        plot.setRangeAxisLocation(plot.getDatasetCount() - 1, AxisLocation.TOP_OR_LEFT);
        plot.mapDatasetToRangeAxis(plot.getDatasetCount() - 1, plot.getDatasetCount() - 1);
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesLinesVisible(0, jShowLines.isSelected());
        renderer.setSeriesShapesVisible(0, jShowDataPoints.isSelected());
        plot.setRenderer(plot.getDatasetCount() - 1, renderer);
        renderer.setDefaultItemLabelsVisible(jShowItemValues.isSelected());
        renderer.setDefaultItemLabelGenerator(new org.jfree.chart.labels.StandardXYItemLabelGenerator());
        renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), NumberFormat.getInstance()));
        axis.setAxisLinePaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
        axis.setLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
        axis.setTickLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
        axis.setTickMarkPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint());
    }
}
 
Example 7
Source File: NumberAxisTests.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    
    NumberAxis a1 = new NumberAxis("Test");
    NumberAxis a2 = new NumberAxis("Test");
    assertTrue(a1.equals(a2));
    
    //private boolean autoRangeIncludesZero;
    a1.setAutoRangeIncludesZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeIncludesZero(false);
    assertTrue(a1.equals(a2));

    //private boolean autoRangeStickyZero;
    a1.setAutoRangeStickyZero(false);
    assertFalse(a1.equals(a2));
    a2.setAutoRangeStickyZero(false);
    assertTrue(a1.equals(a2));

    //private NumberTickUnit tickUnit;
    a1.setTickUnit(new NumberTickUnit(25.0));
    assertFalse(a1.equals(a2));
    a2.setTickUnit(new NumberTickUnit(25.0));
    assertTrue(a1.equals(a2));

    //private NumberFormat numberFormatOverride;
    a1.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertFalse(a1.equals(a2));
    a2.setNumberFormatOverride(new DecimalFormat("0.00"));
    assertTrue(a1.equals(a2));
    
    a1.setRangeType(RangeType.POSITIVE);
    assertFalse(a1.equals(a2));
    a2.setRangeType(RangeType.POSITIVE);
    assertTrue(a1.equals(a2));
    
}
 
Example 8
Source File: MsMsPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
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 9
Source File: TwoDPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
TwoDPlot(RawDataFile rawDataFile, TwoDVisualizerWindow visualizer, TwoDDataSet dataset,
    Range<Double> rtRange, Range<Double> mzRange, String whichPlotTypeStr) {

  super(null, true);

  this.rawDataFile = rawDataFile;
  this.rtRange = rtRange;
  this.mzRange = mzRange;

  setBackground(Color.white);
  setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR));

  // 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();

  JMenuItem plotTypeMenuItem = new JMenuItem("Toggle centroid/continuous mode");
  plotTypeMenuItem.addActionListener(visualizer);
  plotTypeMenuItem.setActionCommand("SWITCH_PLOTMODE");
  add(plotTypeMenuItem);

  JPopupMenu popupMenu = getPopupMenu();
  popupMenu.addSeparator();
  popupMenu.add(plotTypeMenuItem);

  // Add EMF and EPS options to the save as menu
  JMenuItem saveAsMenu = (JMenuItem) popupMenu.getComponent(3);
  GUIUtils.addMenuItem(saveAsMenu, "EMF...", this, "SAVE_EMF");
  GUIUtils.addMenuItem(saveAsMenu, "EPS...", this, "SAVE_EPS");


  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 10
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);
  });
}
 
Example 11
Source File: SpectrumChartFactory.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
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 12
Source File: ProjectionPlotPanel.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
    ParameterSet parameters) {
  super(null);

  boolean createLegend = false;
  if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20))
    createLegend = true;

  chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
      PlotOrientation.VERTICAL, createLegend, 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(false);
  plot.setRangeCrosshairVisible(false);

  plot.setForegroundAlpha(dataPointAlpha);

  NumberFormat numberFormat = NumberFormat.getNumberInstance();

  // set the X axis (component 1) properties
  NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
  xAxis.setNumberFormatOverride(numberFormat);

  // set the Y axis (component 2) properties
  NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
  yAxis.setNumberFormatOverride(numberFormat);

  plot.setDataset(dataset);

  spotRenderer = new ProjectionPlotRenderer(plot, dataset);
  itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters);
  spotRenderer.setDefaultItemLabelGenerator(itemLabelGenerator);
  spotRenderer.setDefaultItemLabelsVisible(true);
  spotRenderer.setDefaultToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters));
  plot.setRenderer(spotRenderer);

  // Setup legend
  if (createLegend) {
    LegendItemCollection legendItemsCollection = new LegendItemCollection();
    for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
      Object paramValue = dataset.getGroupParameterValue(groupNumber);
      if (paramValue == null) {
        // No parameter value available: search for raw data files
        // within this group, and use their names as group's name
        String fileNames = new String();
        for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
          String rawDataFile = dataset.getRawDataFile(itemNumber);
          if (dataset.getGroupNumber(itemNumber) == groupNumber)
            fileNames = fileNames.concat(rawDataFile);
        }
        if (fileNames.length() == 0)
          fileNames = "Empty group";

        paramValue = fileNames;
      }
      Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
      Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
          (int) Math.round(255 * dataPointAlpha));
      legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null,
          spotRenderer.getDataPointsShape(), groupColor));
    }
    plot.setFixedLegendItems(legendItemsCollection);
  }

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 13
Source File: ScatterPlot.java    From Benchmark with GNU General Public License v2.0 4 votes vote down vote up
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 14
Source File: BaseLineChart.java    From EdgeSim with MIT License 4 votes vote down vote up
protected void generateLineChart(String xAisTitle, String yAisTitle,
									 NumberTickUnit xAisSpace, NumberTickUnit yAisSpace, double yaisMinValue, double yAisMaxValue,
									 XYSeriesCollection collection) {
		this.chart = ChartFactory.createXYLineChart(null, xAisTitle, yAisTitle,
				collection, PlotOrientation.VERTICAL, true, true, false);

		this.chart.getPlot().setBackgroundPaint(SystemColor.white);

		LegendTitle legend = chart.getLegend();
		legend.setPosition(RectangleEdge.RIGHT);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

		XYPlot plot = (XYPlot) chart.getPlot();
		NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis();
		numberAxisX.setAutoRangeIncludesZero(false);

		numberAxisX.setTickUnit(xAisSpace);
		numberAxisX.setAxisLineVisible(false);
		numberAxisX.setTickMarkInsideLength(4f);
		numberAxisX.setTickMarkOutsideLength(0);

		NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis();
		numberAxisY.setTickUnit(yAisSpace);
		numberAxisY.setRangeWithMargins(yaisMinValue, yAisMaxValue);
		numberAxisY.setAutoRangeIncludesZero(true);
		numberAxisY.setAxisLineVisible(false);
		numberAxisY.setTickMarkInsideLength(4f);
		numberAxisY.setTickMarkOutsideLength(0);
		numberAxisY.setNumberFormatOverride(NumberFormat.getNumberInstance());

		XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot
				.getRenderer();
//		renderer.setBaseItemLabelsVisible(true);
		renderer.setDefaultItemLabelsVisible(true);
		renderer.setDefaultShapesVisible(true);
//		renderer.setBaseShapesVisible(true);
		renderer.setDrawOutlines(true);

		renderer.setSeriesOutlineStroke(0, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(1, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(2, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(3, new BasicStroke(5F));
		renderer.setSeriesOutlineStroke(4, new BasicStroke(5F));

		renderer.setSeriesPaint(0, Color.RED);
		renderer.setSeriesPaint(1, Color.BLUE);
		renderer.setSeriesPaint(2, new Color(255, 125, 11));
		renderer.setSeriesPaint(3, new Color(0, 161, 59));
		renderer.setSeriesPaint(4, new Color(148, 103, 189));

		renderer.setSeriesStroke(0, new BasicStroke(4.0F));
		renderer.setSeriesStroke(1, new BasicStroke(4.0F));
		renderer.setSeriesStroke(2, new BasicStroke(4.0F));
		renderer.setSeriesStroke(3, new BasicStroke(4.0F));
		renderer.setSeriesStroke(4, new BasicStroke(2.0F));
		renderer.setSeriesStroke(5, new BasicStroke(2.0F));

		// renderer.setUseFillPaint(true);

		this.chartFrame = new ChartFrame("Line Chart", chart);
		chartFrame.pack();
		chartFrame.setSize(800, 600);
		chartFrame.setLocation(300, 200);
		chartFrame.setVisible(true);
	}
 
Example 15
Source File: NumberLineChart.java    From EdgeSim with MIT License 4 votes vote down vote up
public NumberLineChart() {	
		this.collection = this.getCollection();
		initial();
		this.chart = ChartFactory.createXYLineChart(
				null, 
				"Request",
				"Hit Rate", 
				collection, 
				PlotOrientation.VERTICAL, 
				true, 
				true, 
				false
		);
		
		this.chart.getPlot().setBackgroundPaint(SystemColor.white);
		LegendTitle legend = chart.getLegend();
		legend.setPosition(RectangleEdge.RIGHT);
		legend.setHorizontalAlignment(HorizontalAlignment.LEFT);

		

		
		XYPlot plot = (XYPlot) chart.getPlot();		
		
		NumberAxis numberAxisX = (NumberAxis) chart.getXYPlot().getDomainAxis();
		numberAxisX.setTickUnit(new NumberTickUnit(500));
//		numberAxisX.setAutoRangeMinimumSize(0.1);
		numberAxisX.setAutoRangeIncludesZero(true);
		numberAxisX.setAxisLineVisible(false);
		numberAxisX.setTickMarkInsideLength(4f);
		numberAxisX.setTickMarkOutsideLength(0);

		
		
		NumberAxis numberAxisY = (NumberAxis) chart.getXYPlot().getRangeAxis();
		numberAxisY.setTickUnit(new NumberTickUnit(0.2));
		numberAxisY.setRangeWithMargins(0,1);
		numberAxisY.setAutoRangeIncludesZero(true);
		numberAxisY.setAxisLineVisible(false);
		numberAxisY.setTickMarkInsideLength(4f);
		numberAxisY.setTickMarkOutsideLength(0);
		// ����Y������Ϊ�ٷֱ�
		numberAxisY.setNumberFormatOverride(NumberFormat.getPercentInstance());
		
		
		
		XYItemRenderer xyitem = plot.getRenderer();   
        xyitem.setDefaultItemLabelsVisible(true);
//        ItemLabelsVisible(true);

		xyitem.setDefaultPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
//        xyitem.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
//        xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 12));
		xyitem.setDefaultItemLabelFont(new Font("Dialog", 1, 12));
        plot.setRenderer(xyitem);
		
		 	XYLineAndShapeRenderer renderer =  (XYLineAndShapeRenderer)plot.getRenderer();
			renderer.setDefaultItemLabelsVisible(true);
			renderer.setDefaultShapesVisible(true);
			renderer.setDrawOutlines(true);
			
			renderer.setSeriesOutlineStroke(0, new BasicStroke(5F));
			renderer.setSeriesOutlineStroke(1, new BasicStroke(5F));
			renderer.setSeriesOutlineStroke(2, new BasicStroke(5F));
			renderer.setSeriesOutlineStroke(3, new BasicStroke(5F));


			
			renderer.setSeriesPaint(0, Color.RED);
			renderer.setSeriesPaint(1, new Color(53,101,253));
			renderer.setSeriesPaint(2, new Color(0,161,59));//����ɫ
			renderer.setSeriesPaint(3, new Color(148,103,189));//��ɫ
			

			renderer.setSeriesStroke(0, new BasicStroke(4.0F));
			renderer.setSeriesStroke(1, new BasicStroke(4.0F));
			renderer.setSeriesStroke(2, new BasicStroke(4.0F));
			renderer.setSeriesStroke(3, new BasicStroke(4.0F));
			renderer.setSeriesStroke(4, new BasicStroke(2.0F));
			renderer.setSeriesStroke(5, new BasicStroke(2.0F));
		
			this.chartFrame = new ChartFrame("Line Chart", chart);
			chartFrame.pack();
			chartFrame.setSize(1600,1200);
			chartFrame.setLocation(300,200);
			chartFrame.setVisible(true);
	}
 
Example 16
Source File: ProjectionPlotPanel.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public ProjectionPlotPanel(ProjectionPlotWindow masterFrame, ProjectionPlotDataset dataset,
    ParameterSet parameters) {
  super(null);

  boolean createLegend = false;
  if ((dataset.getNumberOfGroups() > 1) && (dataset.getNumberOfGroups() < 20))
    createLegend = true;

  chart = ChartFactory.createXYAreaChart("", dataset.getXLabel(), dataset.getYLabel(), dataset,
      PlotOrientation.VERTICAL, createLegend, 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(false);
  plot.setRangeCrosshairVisible(false);

  plot.setForegroundAlpha(dataPointAlpha);

  NumberFormat numberFormat = NumberFormat.getNumberInstance();

  // set the X axis (component 1) properties
  NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
  xAxis.setNumberFormatOverride(numberFormat);

  // set the Y axis (component 2) properties
  NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
  yAxis.setNumberFormatOverride(numberFormat);

  plot.setDataset(dataset);

  spotRenderer = new ProjectionPlotRenderer(plot, dataset);
  itemLabelGenerator = new ProjectionPlotItemLabelGenerator(parameters);
  spotRenderer.setDefaultItemLabelGenerator(itemLabelGenerator);
  spotRenderer.setDefaultItemLabelsVisible(true);
  spotRenderer.setDefaultToolTipGenerator(new ProjectionPlotToolTipGenerator(parameters));
  plot.setRenderer(spotRenderer);

  // Setup legend
  if (createLegend) {
    LegendItemCollection legendItemsCollection = new LegendItemCollection();
    for (int groupNumber = 0; groupNumber < dataset.getNumberOfGroups(); groupNumber++) {
      Object paramValue = dataset.getGroupParameterValue(groupNumber);
      if (paramValue == null) {
        // No parameter value available: search for raw data files
        // within this group, and use their names as group's name
        String fileNames = new String();
        for (int itemNumber = 0; itemNumber < dataset.getItemCount(0); itemNumber++) {
          String rawDataFile = dataset.getRawDataFile(itemNumber);
          if (dataset.getGroupNumber(itemNumber) == groupNumber)
            fileNames = fileNames.concat(rawDataFile);
        }
        if (fileNames.length() == 0)
          fileNames = "Empty group";

        paramValue = fileNames;
      }
      Color nextColor = (Color) spotRenderer.getGroupPaint(groupNumber);
      Color groupColor = new Color(nextColor.getRed(), nextColor.getGreen(), nextColor.getBlue(),
          Math.round(255 * dataPointAlpha));
      legendItemsCollection.add(new LegendItem(paramValue.toString(), "-", null, null,
          spotRenderer.getDataPointsShape(), groupColor));
    }
    plot.setFixedLegendItems(legendItemsCollection);
  }

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 17
Source File: TwoDPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
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 18
Source File: MsMsPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
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 19
Source File: PseudoSpectrum.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
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 20
Source File: RTMZPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
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();
}