Java Code Examples for org.jfree.chart.renderer.xy.XYItemRenderer#setDefaultItemLabelsVisible()

The following examples show how to use org.jfree.chart.renderer.xy.XYItemRenderer#setDefaultItemLabelsVisible() . 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: PseudoSpectrum.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static EChartPanel createChartPanel(PeakListRow[] group, RawDataFile raw, boolean sum,
    String title) {
  PseudoSpectrumDataSet data = createDataSet(group, raw, sum);
  if (data == null)
    return null;
  JFreeChart chart = createChart(data, raw, sum, title);
  if (chart != null) {
    EChartPanel pn = new EChartPanel(chart);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    PseudoSpectraItemLabelGenerator labelGenerator = new PseudoSpectraItemLabelGenerator(pn);
    renderer.setDefaultItemLabelsVisible(true);
    renderer.setDefaultItemLabelPaint(Color.BLACK);
    renderer.setSeriesItemLabelGenerator(0, labelGenerator);
    return pn;
  }

  return null;
}
 
Example 2
Source File: SpectraPlot.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This will set either centroid or continuous renderer to the first data set, assuming that
 * dataset with index 0 contains the raw data.
 */
public void setPlotMode(MassSpectrumType plotMode) {

  this.plotMode = plotMode;

  XYDataset dataSet = plot.getDataset(0);
  if (!(dataSet instanceof ScanDataSet))
    return;

  XYItemRenderer newRenderer;
  if (plotMode == MassSpectrumType.CENTROIDED) {
    newRenderer = new PeakRenderer(SpectraVisualizerWindow.scanColor, false);
  } else {
    newRenderer = new ContinuousRenderer(SpectraVisualizerWindow.scanColor, false);
    ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
  }

  // Add label generator for the dataset
  SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
  newRenderer.setDefaultItemLabelGenerator(labelGenerator);
  newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
  newRenderer.setDefaultItemLabelPaint(theme.getItemLabelPaint());

  plot.setRenderer(0, newRenderer);

}
 
Example 3
Source File: PseudoSpectrum.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public static EChartPanel createChartPanel(PeakListRow[] group, RawDataFile raw, boolean sum,
    String title) {
  PseudoSpectrumDataSet data = createDataSet(group, raw, sum);
  if (data == null)
    return null;
  JFreeChart chart = createChart(data, raw, sum, title);
  if (chart != null) {
    EChartPanel pn = new EChartPanel(chart);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    PseudoSpectraItemLabelGenerator labelGenerator = new PseudoSpectraItemLabelGenerator(pn);
    renderer.setDefaultItemLabelsVisible(true);
    renderer.setDefaultItemLabelPaint(Color.BLACK);
    renderer.setSeriesItemLabelGenerator(0, labelGenerator);
    return pn;
  }

  return null;
}
 
Example 4
Source File: SpectraPlot.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This will set either centroid or continuous renderer to the first data set, assuming that
 * dataset with index 0 contains the raw data.
 */
public void setPlotMode(MassSpectrumType plotMode) {

  this.plotMode = plotMode;

  XYDataset dataSet = plot.getDataset(0);
  if (!(dataSet instanceof ScanDataSet))
    return;

  XYItemRenderer newRenderer;
  if (plotMode == MassSpectrumType.CENTROIDED) {
    newRenderer = new PeakRenderer(SpectraVisualizerWindow.scanColor, false);
  } else {
    newRenderer = new ContinuousRenderer(SpectraVisualizerWindow.scanColor, false);
    ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
  }

  // Add label generator for the dataset
  SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
  newRenderer.setDefaultItemLabelGenerator(labelGenerator);
  newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
  newRenderer.setDefaultItemLabelPaint(labelsColor);

  plot.setRenderer(0, newRenderer);

}
 
Example 5
Source File: SpectrumChartFactory.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public static EChartPanel createChartPanel(JFreeChart chart) {
  if (chart == null)
    return null;
  //
  EChartPanel pn = new EChartPanel(chart);
  XYItemRenderer renderer = chart.getXYPlot().getRenderer();
  PseudoSpectraItemLabelGenerator labelGenerator = new PseudoSpectraItemLabelGenerator(pn);
  renderer.setDefaultItemLabelsVisible(true);
  renderer.setDefaultItemLabelPaint(Color.BLACK);
  renderer.setSeriesItemLabelGenerator(0, labelGenerator);
  return pn;
}
 
Example 6
Source File: SpectraPlot.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
void switchItemLabelsVisible() {
  itemLabelsVisible = !itemLabelsVisible;
  for (int i = 0; i < plot.getDatasetCount(); i++) {
    XYItemRenderer renderer = plot.getRenderer(i);
    renderer.setDefaultItemLabelsVisible(itemLabelsVisible);
  }
}
 
Example 7
Source File: SpectraPlot.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency) {

    XYItemRenderer newRenderer;

    if (dataSet instanceof ScanDataSet) {
      ScanDataSet scanDataSet = (ScanDataSet) dataSet;
      Scan scan = scanDataSet.getScan();
      if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
        newRenderer = new PeakRenderer(color, transparency);
      else {
        newRenderer = new ContinuousRenderer(color, transparency);
        ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
      }

      // Add label generator for the dataset
      SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
      newRenderer.setDefaultItemLabelGenerator(labelGenerator);
      newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
      newRenderer.setDefaultItemLabelPaint(theme.getItemLabelPaint());

    } else {
      newRenderer = new PeakRenderer(color, transparency);
    }

    plot.setDataset(numOfDataSets, dataSet);
    plot.setRenderer(numOfDataSets, newRenderer);
    numOfDataSets++;

    if (dataSet instanceof ScanDataSet)
      checkAndRunController();
  }
 
Example 8
Source File: SpectraPlot.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency,
    XYItemLabelGenerator labelGenerator) {

  XYItemRenderer newRenderer;

  if (dataSet instanceof ScanDataSet) {
    ScanDataSet scanDataSet = (ScanDataSet) dataSet;
    Scan scan = scanDataSet.getScan();
    if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
      newRenderer = new PeakRenderer(color, transparency);
    else {
      newRenderer = new ContinuousRenderer(color, transparency);
      ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
    }

    // Add label generator for the dataset
    newRenderer.setDefaultItemLabelGenerator(labelGenerator);
    newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
    newRenderer.setDefaultItemLabelPaint(theme.getItemLabelPaint());

  } else {
    newRenderer = new PeakRenderer(color, transparency);
    // Add label generator for the dataset
    newRenderer.setDefaultItemLabelGenerator(labelGenerator);
    newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
    newRenderer.setDefaultItemLabelPaint(theme.getItemLabelPaint());
  }

  plot.setDataset(numOfDataSets, dataSet);
  plot.setRenderer(numOfDataSets, newRenderer);
  numOfDataSets++;

  if (dataSet instanceof ScanDataSet)
    checkAndRunController();
}
 
Example 9
Source File: SpectrumChartFactory.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public static EChartPanel createChartPanel(JFreeChart chart) {
  if (chart == null)
    return null;
  //
  EChartPanel pn = new EChartPanel(chart);
  XYItemRenderer renderer = chart.getXYPlot().getRenderer();
  PseudoSpectraItemLabelGenerator labelGenerator = new PseudoSpectraItemLabelGenerator(pn);
  renderer.setDefaultItemLabelsVisible(true);
  renderer.setDefaultItemLabelPaint(Color.BLACK);
  renderer.setSeriesItemLabelGenerator(0, labelGenerator);
  return pn;
}
 
Example 10
Source File: SpectraPlot.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
void switchItemLabelsVisible() {
  itemLabelsVisible = !itemLabelsVisible;
  for (int i = 0; i < plot.getDatasetCount(); i++) {
    XYItemRenderer renderer = plot.getRenderer(i);
    renderer.setDefaultItemLabelsVisible(itemLabelsVisible);
  }
}
 
Example 11
Source File: SpectraPlot.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency) {

    XYItemRenderer newRenderer;

    if (dataSet instanceof ScanDataSet) {
      ScanDataSet scanDataSet = (ScanDataSet) dataSet;
      Scan scan = scanDataSet.getScan();
      if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
        newRenderer = new PeakRenderer(color, transparency);
      else {
        newRenderer = new ContinuousRenderer(color, transparency);
        ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
      }

      // Add label generator for the dataset
      SpectraItemLabelGenerator labelGenerator = new SpectraItemLabelGenerator(this);
      newRenderer.setDefaultItemLabelGenerator(labelGenerator);
      newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
      newRenderer.setDefaultItemLabelPaint(labelsColor);

    } else {
      newRenderer = new PeakRenderer(color, transparency);
    }

    plot.setDataset(numOfDataSets, dataSet);
    plot.setRenderer(numOfDataSets, newRenderer);
    numOfDataSets++;

    if (dataSet instanceof ScanDataSet)
      checkAndRunController();
  }
 
Example 12
Source File: SpectraPlot.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
public synchronized void addDataSet(XYDataset dataSet, Color color, boolean transparency,
    XYItemLabelGenerator labelGenerator) {

  XYItemRenderer newRenderer;

  if (dataSet instanceof ScanDataSet) {
    ScanDataSet scanDataSet = (ScanDataSet) dataSet;
    Scan scan = scanDataSet.getScan();
    if (scan.getSpectrumType() == MassSpectrumType.CENTROIDED)
      newRenderer = new PeakRenderer(color, transparency);
    else {
      newRenderer = new ContinuousRenderer(color, transparency);
      ((ContinuousRenderer) newRenderer).setDefaultShapesVisible(dataPointsVisible);
    }

    // Add label generator for the dataset
    newRenderer.setDefaultItemLabelGenerator(labelGenerator);
    newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
    newRenderer.setDefaultItemLabelPaint(labelsColor);

  } else {
    newRenderer = new PeakRenderer(color, transparency);
    // Add label generator for the dataset
    newRenderer.setDefaultItemLabelGenerator(labelGenerator);
    newRenderer.setDefaultItemLabelsVisible(itemLabelsVisible);
    newRenderer.setDefaultItemLabelPaint(labelsColor);
  }

  plot.setDataset(numOfDataSets, dataSet);
  plot.setRenderer(numOfDataSets, newRenderer);
  numOfDataSets++;

  if (dataSet instanceof ScanDataSet)
    checkAndRunController();
}
 
Example 13
Source File: TICPlot.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public void switchItemLabelsVisible() {

    // Switch to next mode. Include peaks mode only if peak labels are
    // present.
    labelsVisible = (labelsVisible + 1) % (havePeakLabels ? 3 : 2);

    final int dataSetCount = plot.getDatasetCount();
    for (int i = 0; i < dataSetCount; i++) {

      final XYDataset dataSet = plot.getDataset(i);
      final XYItemRenderer renderer = plot.getRenderer(i);
      if (dataSet instanceof TICDataSet) {

        renderer.setDefaultItemLabelsVisible(labelsVisible == 1);

      } else if (dataSet instanceof PeakDataSet) {

        renderer.setDefaultItemLabelsVisible(labelsVisible == 2);

      } else {

        renderer.setDefaultItemLabelsVisible(false);

      }
    }
  }
 
Example 14
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 15
Source File: TICPlot.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public void switchItemLabelsVisible() {

    // Switch to next mode. Include peaks mode only if peak labels are
    // present.
    labelsVisible = (labelsVisible + 1) % (havePeakLabels ? 3 : 2);

    final int dataSetCount = plot.getDatasetCount();
    for (int i = 0; i < dataSetCount; i++) {

      final XYDataset dataSet = plot.getDataset(i);
      final XYItemRenderer renderer = plot.getRenderer(i);
      if (dataSet instanceof TICDataSet) {

        renderer.setDefaultItemLabelsVisible(labelsVisible == 1);

      } else if (dataSet instanceof PeakDataSet) {

        renderer.setDefaultItemLabelsVisible(labelsVisible == 2);

      } else {

        renderer.setDefaultItemLabelsVisible(false);

      }
    }
  }