Java Code Examples for org.jfree.chart.title.TextTitle#setMargin()

The following examples show how to use org.jfree.chart.title.TextTitle#setMargin() . 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: 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 2
Source File: HistogramChart.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public HistogramChart() {
  super(ChartFactory.createHistogram("", // title
      "", // x-axis label
      "", // y-axis label
      null, // data set
      PlotOrientation.VERTICAL, // orientation
      true, // create legend
      false, // generate tooltips
      false // generate URLs
  ));

  // initialize the chart by default time series chart from factory
  chart = getChart();

  // title
  chartTitle = chart.getTitle();
  chartTitle.setFont(titleFont);
  chartTitle.setMargin(5, 0, 0, 0);

  chartSubTitle = new TextTitle();
  chartSubTitle.setFont(subTitleFont);
  chartSubTitle.setMargin(5, 0, 0, 0);
  chart.addSubtitle(chartSubTitle);

  // legend constructed by ChartFactory
  LegendTitle legend = chart.getLegend();
  legend.setItemFont(legendFont);
  legend.setFrame(BlockBorder.NONE);

  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.REVERSE);
  plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

  // set grid properties
  plot.setDomainGridlinePaint(gridColor);
  plot.setRangeGridlinePaint(gridColor);

  // set crosshair (selection) properties
  plot.setDomainCrosshairVisible(false);
  plot.setRangeCrosshairVisible(true);

  // set the logarithmic axis
  NumberAxis axisDomain = new HistogramDomainAxis();
  axisDomain.setMinorTickCount(1);
  axisDomain.setAutoRange(true);

  NumberAxis axisRange = new NumberAxis();
  axisRange.setMinorTickCount(1);
  axisRange.setAutoRange(true);

  plot.setDomainAxis(axisDomain);
  plot.setRangeAxis(axisRange);

  ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
  renderer.setMargin(marginSize);
  renderer.setShadowVisible(false);
  plot.setRenderer(renderer);

  // this.setMinimumSize(new Dimension(400, 400));
  // this.setDismissDelay(Integer.MAX_VALUE);
  // this.setInitialDelay(0);

  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 3
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 4
Source File: RTMZPlot.java    From mzmine3 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();
}
 
Example 5
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 6
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();
}
 
Example 7
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 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: HistogramChart.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public HistogramChart() {
  super(null, true);

  // initialize the chart by default time series chart from factory
  chart = ChartFactory.createHistogram("", // title
      "", // x-axis label
      "", // y-axis label
      null, // data set
      PlotOrientation.VERTICAL, // orientation
      true, // create legend
      false, // generate tooltips
      false // generate URLs
  );

  // title
  chartTitle = chart.getTitle();
  chartTitle.setFont(titleFont);
  chartTitle.setMargin(5, 0, 0, 0);

  chartSubTitle = new TextTitle();
  chartSubTitle.setFont(subTitleFont);
  chartSubTitle.setMargin(5, 0, 0, 0);
  chart.addSubtitle(chartSubTitle);

  // legend constructed by ChartFactory
  LegendTitle legend = chart.getLegend();
  legend.setItemFont(legendFont);
  legend.setFrame(BlockBorder.NONE);

  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.REVERSE);
  plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);

  // set grid properties
  plot.setDomainGridlinePaint(gridColor);
  plot.setRangeGridlinePaint(gridColor);

  // set crosshair (selection) properties
  plot.setDomainCrosshairVisible(false);
  plot.setRangeCrosshairVisible(true);

  // set the logarithmic axis
  NumberAxis axisDomain = new HistogramDomainAxis();
  axisDomain.setMinorTickCount(1);
  axisDomain.setAutoRange(true);

  NumberAxis axisRange = new NumberAxis();
  axisRange.setMinorTickCount(1);
  axisRange.setAutoRange(true);

  plot.setDomainAxis(axisDomain);
  plot.setRangeAxis(axisRange);

  ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer();
  renderer.setMargin(marginSize);
  renderer.setShadowVisible(false);
  plot.setRenderer(renderer);

  this.setMinimumSize(new Dimension(400, 400));
  this.setDismissDelay(Integer.MAX_VALUE);
  this.setInitialDelay(0);


  // reset zoom history
  ZoomHistory history = getZoomHistory();
  if (history != null)
    history.clear();
}
 
Example 10
Source File: KendrickMassPlotTask.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
  setStatus(TaskStatus.PROCESSING);
  logger.info("Create Kendrick mass plot of " + peakList);
  // Task canceled?
  if (isCanceled())
    return;

  JFreeChart chart = null;
  // 2D, if no third dimension was selected
  if (zAxisLabel.equals("none")) {
    chart = create2DKendrickMassPlot();
  }
  // 3D, if a third dimension was selected
  else {
    chart = create3DKendrickMassPlot();
  }
  chart.setBackgroundPaint(Color.white);

  // create chart JPanel
  EChartPanel chartPanel = new EChartPanel(chart, true, true, true, true, false);

  // Create Kendrick mass plot Window
  KendrickMassPlotWindow frame = new KendrickMassPlotWindow(chart, parameters, chartPanel);
  frame.add(chartPanel, BorderLayout.CENTER);

  // set title properties
  TextTitle chartTitle = chart.getTitle();
  chartTitle.setMargin(5, 0, 0, 0);
  chartTitle.setFont(titleFont);
  LegendTitle legend = chart.getLegend();
  legend.setVisible(false);
  frame.setTitle(title);
  frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  frame.setBackground(Color.white);
  frame.setVisible(true);
  frame.pack();

  setStatus(TaskStatus.FINISHED);
  logger.info("Finished creating Kendrick mass plot of " + peakList);
}
 
Example 11
Source File: VanKrevelenDiagramTask.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void run() {
  try {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Create Van Krevelen diagram of " + peakList);
    // Task canceled?
    if (isCanceled())
      return;
    JFreeChart chart = null;
    // 2D, if no third dimension was selected
    if (zAxisLabel.equals("none")) {
      chart = create2DVanKrevelenDiagram();
    }
    // 3D, if a third dimension was selected
    else {
      chart = create3DVanKrevelenDiagram();
    }

    chart.setBackgroundPaint(Color.white);

    // create chart JPanel
    EChartPanel chartPanel = new EChartPanel(chart, true, true, true, true, false);

    // Create Van Krevelen Diagram window
    VanKrevelenDiagramWindow frame =
        new VanKrevelenDiagramWindow(chart, chartPanel, filteredRows);

    // create chart JPanel
    frame.add(chartPanel, BorderLayout.CENTER);

    // set title properties
    TextTitle chartTitle = chart.getTitle();
    chartTitle.setMargin(5, 0, 0, 0);
    chartTitle.setFont(titleFont);
    LegendTitle legend = chart.getLegend();
    legend.setVisible(false);
    frame.setTitle(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.setBackground(Color.white);
    frame.setVisible(true);
    frame.pack();
    logger.info("Finished creating van Krevelen diagram of " + peakList);
    JOptionPane.showMessageDialog(frame, "Results summary:\n" + displayedFeatures
        + " feature list rows are displayed in the Van Krevelen diagram.\n"
        + featuresWithFormulasWithoutCHO
        + " feature list rows are not displayed, because the annotated molecular formula does not contain the elements C, H, and O.\n"
        + featuresWithoutFormula
        + " feature list rows are not displayed, because no molecular formula was assigned.");
    setStatus(TaskStatus.FINISHED);
  } catch (Throwable t) {
    setErrorMessage(
        "Nothing to plot here or some peaks have other identities than molecular formulas.\n"
            + "Have you annotated your features with molecular formulas?\n"
            + "You can use the feature list method \"Formula prediction\" to handle the task.");
    setStatus(TaskStatus.ERROR);
  }
}
 
Example 12
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();
}