Java Code Examples for org.jfree.chart.JFreeChart#getXYPlot()

The following examples show how to use org.jfree.chart.JFreeChart#getXYPlot() . 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: Chart.java    From Neural-Network-Programming-with-Java-SecondEdition with MIT License 6 votes vote down vote up
/**
 * Performing line plot
 * @param xLabel
 * @param yLabel
 */
public JFreeChart linePlot(String xLabel, String yLabel){
    int numDatasets = dataset.size();
    JFreeChart result = ChartFactory.createXYLineChart(
chartTitle, // chart title
xLabel, // x axis label
yLabel, // y axis label
dataset.get(0), // data
PlotOrientation.VERTICAL, 
true, // include legend
true, // tooltips
false // urls
    );
    XYPlot plot = result.getXYPlot();
    plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
    plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
    for(int i=1;i<numDatasets;i++){
        plot.setDataset(i,dataset.get(i));
        //XYItemRenderer renderer = plot.getRenderer(i-0);
        //plot.setRenderer(i, new XYLineAndShapeRenderer(false, true));
        plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
        plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
    }

    return result;
}
 
Example 2
Source File: ScatterPlotChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
protected JFreeChart computeXYChart( final XYDataset xyDataset ) {
  final JFreeChart chart;
  if ( xyDataset instanceof TimeSeriesCollection ) {
    chart =
      ChartFactory.createTimeSeriesChart( computeTitle(), getDomainTitle(), getRangeTitle(), xyDataset,
        isShowLegend(), false, false );
    final XYPlot xyPlot = chart.getXYPlot();
    final XYLineAndShapeRenderer itemRenderer = (XYLineAndShapeRenderer) xyPlot.getRenderer();
    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer( false, true );
    renderer.setBaseToolTipGenerator( itemRenderer.getBaseToolTipGenerator() );
    renderer.setURLGenerator( itemRenderer.getURLGenerator() );
    xyPlot.setRenderer( renderer );

  } else {
    final PlotOrientation orientation = computePlotOrientation();
    chart = ChartFactory.createScatterPlot( computeTitle(), getDomainTitle(), getRangeTitle(),
      xyDataset, orientation, isShowLegend(), false, false );
  }

  chart.getXYPlot().setRenderer( new XYDotRenderer() );
  configureLogarithmicAxis( chart.getXYPlot() );
  return chart;
}
 
Example 3
Source File: TradeMonitorGui.java    From hazelcast-jet-training with Apache License 2.0 6 votes vote down vote up
private XYPlot createChartFrame(XYDataset dataset) {
    JFreeChart chart = ChartFactory.createTimeSeriesChart(
            "Average Stock Price over 1 minute", "Time", "Price in USD", dataset,
            true, true, false
    );
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(new Color(245, 245, 245));
    plot.setDomainGridlinePaint(Color.BLACK);
    plot.setRangeGridlinePaint(Color.BLACK);

    final JFrame frame = new JFrame();
    frame.setBackground(Color.WHITE);
    frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
    frame.setTitle("Trade Monitor");
    frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT);
    frame.setLayout(new BorderLayout());
    frame.add(new ChartPanel(chart));
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent windowEvent) {
            avgPrices.removeEntryListener(listenerId);
        }
    });
    frame.setVisible(true);
    return plot;
}
 
Example 4
Source File: PerformanceChart.java    From jFuzzyLogic with GNU Lesser General Public License v3.0 6 votes vote down vote up
void display(String windowTitle) {
	//		 Create plot and show it
	JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, "No. of Fuzzy Inference Cycles", "Time (ms)", xyDataset, PlotOrientation.VERTICAL, true, true, true);
	chart.setBackgroundPaint(Color.white);
	final XYPlot xyPlot = chart.getXYPlot();
	final XYItemRenderer renderer = xyPlot.getRenderer();

	if( renderer instanceof XYLineAndShapeRenderer ) {
		final XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer;
		//rr.setShapesVisible(true);
		// rr.setDefaultShapesFilled(false);
		rr.setSeriesStroke(1, new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6f, 3f }, 0.0f));
		rr.setSeriesStroke(2, new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10f, 6f }, 0.0f));
		rr.setSeriesStroke(3, new BasicStroke(1.2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 5f, 5f }, 0.0f));
		rr.setSeriesPaint(0, Color.BLACK);
		rr.setSeriesPaint(1, Color.GREEN);
		rr.setSeriesPaint(2, Color.RED);
		rr.setSeriesPaint(3, Color.BLUE);
		rr.setLinesVisible(true);
		//rr.setSeriesShape(0, ShapeUtilities.createDiamond(5));
	}

	PlotWindow.showIt(windowTitle, chart);
}
 
Example 5
Source File: DomLineChart.java    From DominionSim with MIT License 5 votes vote down vote up
private JFreeChart createChart(XYDataset dataset) {
        JFreeChart chart = ChartFactory.createXYLineChart(
            myType.equals("VP")? "Average Victory Points gained/turn" : "Average $ generated/turn",      // chart title
            "turns",                      // x axis label
            myType.equals("VP")? "VP gained" : "available money",                      // y axis label
            dataset,                  // data
            PlotOrientation.VERTICAL,
            true,                     // include legend
            true,                     // tooltips
            false                     // urls
        );
//        chart.setBackgroundPaint(Color.darkGray);
//        final StandardLegend legend = (StandardLegend) chart.getLegend();
  //      legend.setDisplaySeriesShapes(true);
        // get a reference to the plot for further customisation...
        final XYPlot plot = chart.getXYPlot();
        plot.setBackgroundPaint(Color.white);
//        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
        plot.setDomainGridlinePaint(Color.black);
        plot.setRangeGridlinePaint(Color.black);
        XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
        renderer.setSeriesPaint(0,Color.black);
        renderer.setSeriesPaint(1,Color.blue);
        renderer.setSeriesPaint(2,Color.red);
        renderer.setSeriesPaint(3,Color.cyan);
        renderer.setBaseShapesVisible(true);
        plot.setRenderer(renderer);
        // change the auto tick unit selection to integer units only...
        NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
        domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
//        domainAxis.setTickUnit( new NumberTickUnit( 1 ) );
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
//        rangeAxis.setTickUnit( new NumberTickUnit( 1 ) );
                
        return chart;
	}
 
Example 6
Source File: ScatterPlotChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
protected void configureChart( final JFreeChart chart ) {
  super.configureChart( chart );

  final XYPlot xypl = chart.getXYPlot();
  final XYItemRenderer renderer = xypl.getRenderer();
  if ( renderer instanceof XYDotRenderer ) {
    final XYDotRenderer renderer1 = (XYDotRenderer) renderer;
    renderer1.setDotHeight( getDotHeight() );
    renderer1.setDotWidth( getDotWidth() );
  }

}
 
Example 7
Source File: ForecastingChartDemo.java    From OpenForecast with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * A demonstration application showing a quarterly time series
 * along with the forecast values.
 * @param title the frame title.
 */
public ForecastingChartDemo(String title)
{
    super(title);
    
    // Create a title...
    String chartTitle = "OpenForecast Demo";
    XYDataset dataset = createDataset();
    
    JFreeChart chart
        = ChartFactory.createTimeSeriesChart(chartTitle,
                                             "Date",
                                             "Quarterly Sales (Units sold)",
                                             dataset,
                                             true,  // Legend
                                             true,  // Tooltips
                                             false);// URLs
    
    XYPlot plot = chart.getXYPlot();
    XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer)
        {
            StandardXYItemRenderer r = (StandardXYItemRenderer) renderer;
            r.setPlotShapes(true);
            r.setDefaultShapesFilled(Boolean.TRUE);
        }
    
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}
 
Example 8
Source File: ShollAnalysisDialog.java    From SNT with GNU General Public License v3.0 5 votes vote down vote up
protected synchronized void updateResults() {
	JFreeChart chart;

	if (numberOfAllPaths <= 0) {

		makePromptInteractive(false);
		if (graphFrame != null) {
			chart = graphFrame.chartPanel.getChart();
			if (chart != null) {
				chart.setNotify(false);
				final TextTitle currentitle = chart.getTitle();
				if (currentitle != null)
					currentitle.setText("");
				final XYPlot plot = chart.getXYPlot();
				if (plot != null)
					plot.setDataset(null);
				chart.setNotify(true);
			}
		}

	} else { // valid paths to be analyzed

		makePromptInteractive(true);
		final ShollResults results = getCurrentResults();
		resultsPanel.updateFromResults(results);
		chart = results.createGraph();
		if (chart == null)
			return;
		if (graphFrame == null)
			graphFrame = new GraphFrame(chart, results.getSuggestedSuffix());
		else
			graphFrame.updateWithNewChart(chart, results.getSuggestedSuffix());
	}

}
 
Example 9
Source File: RawSignalWindow.java    From ProtocolAnalyzer with GNU General Public License v3.0 5 votes vote down vote up
public static void configurePanelLooks(JFreeChart chart, int selectionSeries) {
    TextTitle title = chart.getTitle(); // fix title
    Font titleFont = title.getFont();
    titleFont = titleFont.deriveFont(Font.PLAIN, (float) 14.0);
    title.setFont(titleFont);
    title.setPaint(Color.darkGray);
    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    XYLineAndShapeRenderer signalRenderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
    signalRenderer.setSeriesStroke(selectionSeries, new BasicStroke(5f));
}
 
Example 10
Source File: XYChartBuilder.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
public XYChartBuilder(final JFreeChart chart)
{
  this.chart = chart;
  plot = chart.getXYPlot();
  plot.setBackgroundPaint(Color.white);
  plot.setDomainGridlinePaint(Color.lightGray);
  plot.setRangeGridlinePaint(Color.lightGray);
  plot.setOutlineVisible(false);
}
 
Example 11
Source File: MemInfo.java    From AndroidRobot with Apache License 2.0 5 votes vote down vote up
private JFreeChart createChart(XYDataset xydataset) {
    JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("", "", "", xydataset, true,
        true, false);
    Plot plot = (Plot) jfreechart.getPlot();
    xyplot = jfreechart.getXYPlot();
    // 纵坐标设定
    valueaxis = xyplot.getDomainAxis();
    valueaxis.setAutoRange(true);
    valueaxis.setFixedAutoRange(60000D);
    valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(0.0D, 1048576D);
    plot.setBackgroundPaint(Color.black);
    return jfreechart;
}
 
Example 12
Source File: GraphPanel.java    From swift-k with Apache License 2.0 5 votes vote down vote up
protected void removeSeries(JFreeChart chart, int seriesIndex) {
    Color color = (Color) chart.getPlot().getLegendItems().get(seriesIndex).getLinePaint();
    palette.release(color);
    String key = enabled.remove(seriesIndex);
    XYPlot plot = chart.getXYPlot();
    Series<?> series = sampler.getSeries(key);
    Unit unit = series.getUnit();
    
    Integer datasetIndex = datasetMapping.get(unit);
    TimeSeriesCollection col = (TimeSeriesCollection) plot.getDataset(datasetIndex);
    
    List<String> colIndices = seriesMapping.get(unit);
    int colIndex = colIndices.indexOf(key);
    colIndices.remove(key);
    
    col.removeSeries(colIndex);
    if (col.getSeriesCount() == 0) {
        plot.setDataset(datasetIndex, null);
        plot.setRangeAxis(datasetIndex, null);
        seriesMapping.remove(unit);
        datasetMapping.remove(unit);
    }
    
    rebuildLegend();
    repaint();
    gp.saveLayout();
}
 
Example 13
Source File: ExponentialSmoothingChartDemo.java    From OpenForecast with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * A demonstration application showing a quarterly time series
 * along with the forecast values.
 * @param title the frame title.
 */
public ExponentialSmoothingChartDemo(String title)
{
    super(title);
    
    // Create a title...
    String chartTitle = "OpenForecast Demo";
    XYDataset dataset = createDataset();
    
    JFreeChart chart
        = ChartFactory.createTimeSeriesChart(chartTitle,
                                             "Date",
                                             "Quarterly Sales (Units sold)",
                                             dataset,
                                             true,  // Legend
                                             true,  // Tooltips
                                             false);// URLs
    
    XYPlot plot = chart.getXYPlot();
    XYItemRenderer renderer = plot.getRenderer();
    if (renderer instanceof StandardXYItemRenderer)
        {
            StandardXYItemRenderer r = (StandardXYItemRenderer) renderer;
            r.setPlotShapes(true);
            r.setDefaultShapesFilled(Boolean.TRUE);
        }
    
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
}
 
Example 14
Source File: PlotUtil.java    From StockPrediction with MIT License 5 votes vote down vote up
public static void plot(double[] predicts, double[] actuals, String name) {
	double[] index = new double[predicts.length];
	for (int i = 0; i < predicts.length; i++)
		index[i] = i;
	int min = minValue(predicts, actuals);
	int max = maxValue(predicts, actuals);
	final XYSeriesCollection dataSet = new XYSeriesCollection();
	addSeries(dataSet, index, predicts, "Predicts");
	addSeries(dataSet, index, actuals, "Actuals");
	final JFreeChart chart = ChartFactory.createXYLineChart(
			"Prediction Result", // chart title
			"Index", // x axis label
			name, // y axis label
			dataSet, // data
			PlotOrientation.VERTICAL,
			true, // include legend
			true, // tooltips
			false // urls
	);
	XYPlot xyPlot = chart.getXYPlot();
	// X-axis
	final NumberAxis domainAxis = (NumberAxis) xyPlot.getDomainAxis();
	domainAxis.setRange((int) index[0], (int) (index[index.length - 1] + 2));
	domainAxis.setTickUnit(new NumberTickUnit(20));
	domainAxis.setVerticalTickLabels(true);
	// Y-axis
	final NumberAxis rangeAxis = (NumberAxis) xyPlot.getRangeAxis();
	rangeAxis.setRange(min, max);
	rangeAxis.setTickUnit(new NumberTickUnit(50));
	final ChartPanel panel = new ChartPanel(chart);
	final JFrame f = new JFrame();
	f.add(panel);
	f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
	f.pack();
	f.setVisible(true);
}
 
Example 15
Source File: GraphPlot.java    From NSGA-II with MIT License 5 votes vote down vote up
public void configure(String xAxisTitle, String yAxisTitle) {

		if(!GraphPlot.isCompatible(this.objectives)) return;

		JFreeChart xyLineChart = ChartFactory.createXYLineChart(
			this.key,
			xAxisTitle,
			yAxisTitle,
			this.dataset,
			PlotOrientation.VERTICAL,
			true,
			true,
			false
		);
		ChartPanel chartPanel = new ChartPanel(xyLineChart);

		chartPanel.setPreferredSize(
			new java.awt.Dimension(
				this.dimensionX,
				this.dimensionY
			)
		);

		XYPlot plot = xyLineChart.getXYPlot();
		XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

		renderer.setSeriesPaint(0, this.getRandomPaint());
		renderer.setSeriesStroke(0, new BasicStroke(2.0f));

		plot.setRenderer(renderer);
		setContentPane(chartPanel);
	}
 
Example 16
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 17
Source File: ChartGroup.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private boolean hasRangeAxis(JFreeChart c) {
  return c.getXYPlot() != null && c.getXYPlot().getRangeAxis() != null;
}
 
Example 18
Source File: SpectrumChartFactory.java    From mzmine3 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 19
Source File: ChartGroup.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
private boolean hasDomainAxis(JFreeChart c) {
  return c.getXYPlot() != null && c.getXYPlot().getDomainAxis() != null;
}
 
Example 20
Source File: MetadataPlotPanel.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void initComponents() {
    if (hasAlternativeView()) {
        getAlternativeView().initComponents();
    }
    JFreeChart chart = ChartFactory.createXYLineChart(
            CHART_TITLE,
            DEFAULT_X_AXIS_LABEL,
            DEFAULT_SAMPLE_DATASET_NAME,
            new DefaultXYDataset(),
            PlotOrientation.VERTICAL,
            true,
            true,
            false
    );

    xyPlot = chart.getXYPlot();

    xyPlot.setNoDataMessage(NO_DATA_MESSAGE);
    xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5));


    ChartPanel profilePlotDisplay = new ChartPanel(chart);
    profilePlotDisplay.setInitialDelay(200);
    profilePlotDisplay.setDismissDelay(1500);
    profilePlotDisplay.setReshowDelay(200);
    profilePlotDisplay.setZoomTriggerDistance(5);
    profilePlotDisplay.getPopupMenu().addSeparator();
    profilePlotDisplay.getPopupMenu().add(createCopyDataToClipboardMenuItem());


    plotSettings = new MetadataPlotSettings();
    final BindingContext bindingContext = plotSettings.getContext();

    JPanel settingsPanel = createSettingsPanel(bindingContext);
    createUI(profilePlotDisplay, settingsPanel, (RoiMaskSelector) null);

    bindingContext.setComponentsEnabled(PROP_NAME_RECORD_START_INDEX, false);
    bindingContext.setComponentsEnabled(PROP_NAME_RECORDS_PER_PLOT, false);

    isInitialized = true;

    updateComponents();
    updateChartData();

    bindingContext.addPropertyChangeListener(PROP_NAME_METADATA_ELEMENT, evt -> updateUiState());
    bindingContext.addPropertyChangeListener(evt -> updateChartData());

}