Java Code Examples for org.jfree.chart.JFreeChart#DEFAULT_TITLE_FONT

The following examples show how to use org.jfree.chart.JFreeChart#DEFAULT_TITLE_FONT . 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: FXCombinedChartGestureDemo.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
private JFreeChart createCombinedChart() {
      // create subplot 1...
      final XYDataset data1 = createDataset();
      final XYItemRenderer renderer1 = new StandardXYItemRenderer();
      final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
      final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);
      
      // create subplot 2...
      final XYDataset data2 = createDataset();
      final XYItemRenderer renderer2 = new StandardXYItemRenderer();
      final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
      final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);

      // parent plot...
      final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
      plot.setGap(10.0);
      
      // add the subplots...
      plot.add(subplot1, 1);
      plot.add(subplot2, 1);
      plot.setOrientation(PlotOrientation.VERTICAL);

      // return a new chart containing the overlaid plot...
      return new JFreeChart("CombinedDomainXYPlot Demo",
                            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}
 
Example 2
Source File: SwingCombinedChartGestureDemo.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
private JFreeChart createCombinedChart() {
  // create subplot 1...
  final XYDataset data1 = createDataset();
  final XYItemRenderer renderer1 = new StandardXYItemRenderer();
  final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
  final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);

  // create subplot 2...
  final XYDataset data2 = createDataset();
  final XYItemRenderer renderer2 = new StandardXYItemRenderer();
  final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
  final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
  plot.setGap(10.0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);

  // return a new chart containing the overlaid plot...
  return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}
 
Example 3
Source File: FXCombinedChartGestureDemo.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
private JFreeChart createCombinedChart() {
  // create subplot 1...
  final XYDataset data1 = createDataset();
  final XYItemRenderer renderer1 = new StandardXYItemRenderer();
  final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
  final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);

  // create subplot 2...
  final XYDataset data2 = createDataset();
  final XYItemRenderer renderer2 = new StandardXYItemRenderer();
  final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
  final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
  plot.setGap(10.0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);

  // return a new chart containing the overlaid plot...
  return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}
 
Example 4
Source File: ExpressionProfile.java    From chipster with MIT License 6 votes vote down vote up
public JFreeChart createProfileChart(CategoryDataset categoryDataset, List<ProfileRow> rows, String name) throws MicroarrayException {
					
	// draw plot
       CategoryAxis categoryAxis = new CategoryAxis("sample");
       categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
       categoryAxis.setUpperMargin(0.0);
       categoryAxis.setLowerMargin(0.0);
       ValueAxis valueAxis = new NumberAxis("expression");
       plot = new CategoryPlot(categoryDataset, categoryAxis, valueAxis, createRenderer(rows));
       plot.setOrientation(PlotOrientation.VERTICAL);
       
       JFreeChart chart = new JFreeChart("Expression profile for " + name, 
       		JFreeChart.DEFAULT_TITLE_FONT, plot, false);
       
	return chart;
}
 
Example 5
Source File: SwingCombinedChartGestureDemo.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
private JFreeChart createCombinedChart() {
  // create subplot 1...
  final XYDataset data1 = createDataset();
  final XYItemRenderer renderer1 = new StandardXYItemRenderer();
  final NumberAxis rangeAxis1 = new NumberAxis("Range 1");
  final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1);

  // create subplot 2...
  final XYDataset data2 = createDataset();
  final XYItemRenderer renderer2 = new StandardXYItemRenderer();
  final NumberAxis rangeAxis2 = new NumberAxis("Range 2");
  final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
  plot.setGap(10.0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);

  // return a new chart containing the overlaid plot...
  return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}
 
Example 6
Source File: JThermometer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example 7
Source File: AreaChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates a stacked area chart with default settings.  The chart object returned by this method uses a {@link
 * CategoryPlot} instance as the plot, with a {@link org.jfree.chart.axis.CategoryAxis} for the domain axis, a {@link
 * org.jfree.chart.axis.NumberAxis} as the range axis, and a {@link org.jfree.chart.renderer.category
 * .StackedAreaRenderer}
 * as the renderer.
 *
 * @param title             the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel the label for the category axis (<code>null</code> permitted).
 * @param valueAxisLabel    the label for the value axis (<code>null</code> permitted).
 * @param dataset           the dataset for the chart (<code>null</code> permitted).
 * @param orientation       the plot orientation (horizontal or vertical) (<code>null</code> not permitted).
 * @param legend            a flag specifying whether or not a legend is required.
 * @param tooltips          configure chart to generate tool tips?
 * @param urls              configure chart to generate URLs?
 * @return A stacked area chart.
 */
private JFreeChart createStackedAreaChart( final String title,
                                           final String categoryAxisLabel, final String valueAxisLabel,
                                           final CategoryDataset dataset, final PlotOrientation orientation,
                                           final boolean legend, final boolean tooltips, final boolean urls ) {

  if ( orientation == null ) {
    throw new IllegalArgumentException( "Null 'orientation' argument." );
  }
  final CategoryAxis categoryAxis = new FormattedCategoryAxis( categoryAxisLabel,
    getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale() );
  categoryAxis.setCategoryMargin( 0.0 );
  final ValueAxis valueAxis = new NumberAxis( valueAxisLabel );

  final StackedAreaRenderer renderer = new StackedAreaRenderer();
  if ( tooltips ) {
    renderer.setBaseToolTipGenerator(
      new StandardCategoryToolTipGenerator() );
  }
  if ( urls ) {
    renderer.setBaseItemURLGenerator(
      new StandardCategoryURLGenerator() );
  }

  final CategoryPlot plot = new CategoryPlot( dataset, categoryAxis, valueAxis,
    renderer );
  plot.setOrientation( orientation );
  return new JFreeChart( title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend );
}
 
Example 8
Source File: JThermometer.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, 
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example 9
Source File: JThermometer.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, 
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example 10
Source File: Histogram.java    From chipster with MIT License 5 votes vote down vote up
private void updateHistogram() throws MicroarrayException, IOException {

		updateChipBox();

		int barCount = ((SpinnerNumberModel) barCountSpinner.getModel()).getNumber().intValue();
		String expression = ((Variable) chipBox.getSelectedItem()).getExpression();
		FloatArrayList histogram = getHistogram(barCount, expression);

		if (histogram != null) {
			CategoryDataset dataset = toCategoryDataset(histogram);

			CategoryAxis categoryAxis = new CategoryAxis("value");
			ValueAxis valueAxis = new NumberAxis("count");

			BarRenderer renderer = new BarRenderer();
			ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
			renderer.setBasePositiveItemLabelPosition(position1);
			ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
			renderer.setBaseNegativeItemLabelPosition(position2);

			CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
			plot.setOrientation(PlotOrientation.VERTICAL);
			JFreeChart chart = new JFreeChart(data.getName(), JFreeChart.DEFAULT_TITLE_FONT, plot, false);

			visualisationPanel.removeAll();
			visualisationPanel.add(makePanel(chart), BorderLayout.CENTER);
			visualisationPanel.validate();

		} else {
			throw new IllegalArgumentException("histogram not supported for " + data.getName());
		}

	}
 
Example 11
Source File: JThermometer.java    From ccu-historian with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example 12
Source File: JThermometer.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Default constructor.
 */
public JThermometer() {
    super(new CardLayout());
    this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    this.data = new DefaultValueDataset();
    this.plot.setDataset(this.data);
    this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT,
            this.plot, false);
    this.panel = new ChartPanel(this.chart);
    add(this.panel, "Panel");
    setBackground(getBackground());
}
 
Example 13
Source File: CombinedXYPlotDemo1.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Creates an overlaid chart.
 *
 * @return The chart.
 */
private static JFreeChart createCombinedChart() {

    // create plot ...
    IntervalXYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
            BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);

    DateAxis domainAxis = new DateAxis("Year");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.02);
    ValueAxis rangeAxis = new NumberAxis("$billion");
    XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    IntervalXYDataset data2 = createDataset2();
    XYBarRenderer renderer2 = new XYBarRenderer() {
        public Paint getItemPaint(int series, int item) {
            XYDataset dataset = getPlot().getDataset();
            if (dataset.getYValue(series, item) >= 0.0) {
                return Color.red;
            }
            else {
                return Color.green;
            }
        }
    };
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setDrawBarOutline(false);
    renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));

    XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
            renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
            JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    chart.setBackgroundPaint(Color.white);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);
    return chart;
}
 
Example 14
Source File: StlPlotter.java    From stl-java with Apache License 2.0 4 votes vote down vote up
private JFreeChart createChart() {

      final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
      final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
      final ClusteredXYBarRenderer barRenderer = new ClusteredXYBarRenderer();
      final GradientPaint black = new GradientPaint(0.0f, 0.0f, Color.black, 0.0f, 0.0f, Color.black);

      final TimeSeries seriests = new TimeSeries("Series");
      final TimeSeries seasonalts = new TimeSeries("Seasonal");
      final TimeSeries trendts = new TimeSeries("Trend");
      final TimeSeries remainderts = new TimeSeries("Remainder");

      final TimeSeries[] tsArray = new TimeSeries[]{seriests, seasonalts, trendts};
      final String[] labels = new String[]{"Series", "Seasonal", "Trend"};

      for (int i = 0; i < series.length; i++) {
        final Date d = new Date((long) times[i]);
        RegularTimePeriod rtp = RegularTimePeriod.createInstance(this.timePeriod, d, TimeZone.getDefault());
        seriests.addOrUpdate(rtp, series[i]);
        seasonalts.addOrUpdate(rtp, seasonal[i]);
        trendts.addOrUpdate(rtp, trend[i]);
        remainderts.addOrUpdate(rtp, remainder[i]);
      }

      plot.setGap(10.0);
      renderer.setSeriesPaint(0, black);
      barRenderer.setSeriesPaint(0, black);
      plot.setOrientation(PlotOrientation.VERTICAL);

      for (int i = 0; i < tsArray.length; i++) {
        final XYDataset ts = new TimeSeriesCollection(tsArray[i]);
        final XYPlot p = new XYPlot(ts, new DateAxis(labels[i]), new NumberAxis(labels[i]), renderer);
        plot.add(p);
      }

      final XYDataset rts = new TimeSeriesCollection(remainderts);
      final XYDataset sts = new TimeSeriesCollection(seriests);
      final XYDataset tts = new TimeSeriesCollection(trendts);
      final XYPlot rplot = new XYPlot(rts, new DateAxis(), new NumberAxis("Remainder"), barRenderer);
      final XYPlot seriesAndTrend = new XYPlot(sts, new DateAxis(), new NumberAxis("S & T"), renderer);

      seriesAndTrend.setDataset(1, tts);
      seriesAndTrend.setRenderer(1, renderer);

      plot.add(rplot);
      plot.add(seriesAndTrend);

      return new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    }
 
Example 15
Source File: CombinedXYPlotDemo1.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates an overlaid chart.
 *
 * @return The chart.
 */
private static JFreeChart createCombinedChart() {

    // create plot ...
    IntervalXYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
            BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);

    DateAxis domainAxis = new DateAxis("Year");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.02);
    ValueAxis rangeAxis = new NumberAxis("$billion");
    XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    IntervalXYDataset data2 = createDataset2();
    XYBarRenderer renderer2 = new XYBarRenderer() {
        public Paint getItemPaint(int series, int item) {
            XYDataset dataset = getPlot().getDataset();
            if (dataset.getYValue(series, item) >= 0.0) {
                return Color.red;
            }
            else {
                return Color.green;
            }
        }
    };
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setDrawBarOutline(false);
    renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));

    XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
            renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
            JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    chart.setBackgroundPaint(Color.white);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);
    return chart;
}
 
Example 16
Source File: Meter.java    From Knowage-Server with GNU Affero General Public License v3.0 4 votes vote down vote up
/**
 * Creates the chart .
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart .
 */

public JFreeChart createChart(DatasetMap datasets) {

	Dataset dataset=(Dataset)datasets.getDatasets().get("1");

	MeterPlot plot = new MeterPlot((ValueDataset)dataset);
	plot.setRange(new Range(lower, upper));


	for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
		KpiInterval interval = (KpiInterval) iterator.next();

		plot.addInterval(new MeterInterval(interval.getLabel(), new Range(interval.getMin(), interval.getMax()), 
				Color.lightGray, new BasicStroke(2.0f), 
				interval.getColor()));
	}

	plot.setNeedlePaint(Color.darkGray);
	plot.setDialBackgroundPaint(Color.white);
	plot.setDialOutlinePaint(Color.gray);
	plot.setDialShape(DialShape.CHORD);
	plot.setMeterAngle(260);
	plot.setTickLabelsVisible(true);
	//set tick label style
	Font tickLabelsFont = new Font(labelsTickStyle.getFontName(), Font.PLAIN, labelsTickStyle.getSize());
	plot.setTickLabelFont(tickLabelsFont);
	plot.setTickLabelPaint(labelsTickStyle.getColor());
	plot.setTickSize(5.0);
	plot.setTickPaint(Color.lightGray);
	if(units!=null){
		plot.setUnits(units);
	}

	plot.setValuePaint(labelsValueStyle.getColor());
	plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));

	JFreeChart chart = new JFreeChart(name, 
			JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
	chart.setBackgroundPaint(color);
	
	TextTitle title = setStyleTitle(name, styleTitle);
	chart.setTitle(title);
	if(subName!= null && !subName.equals("")){
		TextTitle subTitle =setStyleTitle(subName, styleSubTitle);
		chart.addSubtitle(subTitle);
	}

	return chart;
}
 
Example 17
Source File: SpectrumChartFactory.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public static EChartPanel createMirrorChartPanel(String labelA, double precursorMZA, double rtA,
    DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB,
    boolean showTitle, boolean showLegend) {
  PseudoSpectrumDataSet data =
      dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA);
  PseudoSpectrumDataSet dataMirror =
      dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB);

  NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat();
  NumberFormat intensityFormat = new DecimalFormat("0.#");

  // set the X axis (retention time) properties
  NumberAxis xAxis = new NumberAxis("m/z");
  xAxis.setNumberFormatOverride(mzForm);
  xAxis.setUpperMargin(0.08);
  xAxis.setLowerMargin(0.00);
  xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
  xAxis.setAutoRangeIncludesZero(false);
  xAxis.setMinorTickCount(5);

  PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false);
  PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false);

  // create subplot 1...
  final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]");
  final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1);
  subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
  rangeAxis1.setNumberFormatOverride(intensityFormat);
  rangeAxis1.setAutoRangeIncludesZero(true);
  rangeAxis1.setAutoRangeStickyZero(true);

  // create subplot 2...
  final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]");
  rangeAxis2.setNumberFormatOverride(intensityFormat);
  rangeAxis2.setAutoRangeIncludesZero(true);
  rangeAxis2.setAutoRangeStickyZero(true);
  rangeAxis2.setInverted(true);
  final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2);
  subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain"));
  plot.setGap(0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);


  // set the plot properties
  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);

  // return a new chart containing the overlaid plot...
  JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  chart.setBackgroundPaint(Color.white);
  chart.getTitle().setVisible(false);

  // chart.getXYPlot().setRangeZeroBaselineVisible(true);
  chart.getTitle().setVisible(showTitle);
  chart.getLegend().setVisible(showLegend);

  return new EChartPanel(chart);
}
 
Example 18
Source File: MirrorChartFactory.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private static JFreeChart createMirrorChart(String labelA, double precursorMZA, double rtA,
    DataPoint[] dpsA, String labelB, double precursorMZB, double rtB, DataPoint[] dpsB,
    boolean showTitle, boolean showLegend) {
  PseudoSpectrumDataSet data =
      dpsA == null ? null : createMSMSDataSet(precursorMZA, rtA, dpsA, labelA);
  PseudoSpectrumDataSet dataMirror =
      dpsB == null ? null : createMSMSDataSet(precursorMZB, rtB, dpsB, labelB);

  NumberFormat mzForm = MZmineCore.getConfiguration().getMZFormat();
  NumberFormat intensityFormat = new DecimalFormat("0.#");

  // set the X axis (retention time) properties
  NumberAxis xAxis = new NumberAxis("m/z");
  xAxis.setNumberFormatOverride(mzForm);
  xAxis.setUpperMargin(0.08);
  xAxis.setLowerMargin(0.00);
  xAxis.setTickLabelInsets(new RectangleInsets(0, 0, 20, 20));
  xAxis.setAutoRangeIncludesZero(false);
  xAxis.setMinorTickCount(5);

  PseudoSpectraRenderer renderer1 = new PseudoSpectraRenderer(Color.BLACK, false);
  PseudoSpectraRenderer renderer2 = new PseudoSpectraRenderer(Color.BLACK, false);

  // create subplot 1...
  final NumberAxis rangeAxis1 = new NumberAxis("rel. intensity [%]");
  final XYPlot subplot1 = new XYPlot(data, null, rangeAxis1, renderer1);
  subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
  rangeAxis1.setNumberFormatOverride(intensityFormat);
  rangeAxis1.setAutoRangeIncludesZero(true);
  rangeAxis1.setAutoRangeStickyZero(true);

  // create subplot 2...
  final NumberAxis rangeAxis2 = new NumberAxis("rel. intensity [%]");
  rangeAxis2.setNumberFormatOverride(intensityFormat);
  rangeAxis2.setAutoRangeIncludesZero(true);
  rangeAxis2.setAutoRangeStickyZero(true);
  rangeAxis2.setInverted(true);
  final XYPlot subplot2 = new XYPlot(dataMirror, null, rangeAxis2, renderer2);
  subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

  // parent plot...
  final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(xAxis);
  plot.setGap(0);

  // add the subplots...
  plot.add(subplot1, 1);
  plot.add(subplot2, 1);
  plot.setOrientation(PlotOrientation.VERTICAL);

  // set the plot properties
  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);

  // return a new chart containing the overlaid plot...
  JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
  chart.setBackgroundPaint(Color.white);
  chart.getTitle().setVisible(false);

  chart.getXYPlot().setRangeZeroBaselineVisible(true);
  chart.getTitle().setVisible(showTitle);
  chart.getLegend().setVisible(showLegend);

  return chart;
}
 
Example 19
Source File: CombinedXYPlotDemo1.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates an overlaid chart.
 *
 * @return The chart.
 */
private static JFreeChart createCombinedChart() {

    // create plot ...
    IntervalXYDataset data1 = createDataset1();
    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    renderer1.setSeriesStroke(0, new BasicStroke(4.0f,
            BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL));
    renderer1.setSeriesPaint(0, Color.blue);

    DateAxis domainAxis = new DateAxis("Year");
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.02);
    ValueAxis rangeAxis = new NumberAxis("$billion");
    XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1);
    plot1.setBackgroundPaint(Color.lightGray);
    plot1.setDomainGridlinePaint(Color.white);
    plot1.setRangeGridlinePaint(Color.white);

    // add a second dataset and renderer...
    IntervalXYDataset data2 = createDataset2();
    XYBarRenderer renderer2 = new XYBarRenderer() {
        public Paint getItemPaint(int series, int item) {
            XYDataset dataset = getPlot().getDataset();
            if (dataset.getYValue(series, item) >= 0.0) {
                return Color.red;
            }
            else {
                return Color.green;
            }
        }
    };
    renderer2.setSeriesPaint(0, Color.red);
    renderer2.setDrawBarOutline(false);
    renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator(
            StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
            new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));

    XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"),
            renderer2);
    plot2.setBackgroundPaint(Color.lightGray);
    plot2.setDomainGridlinePaint(Color.white);
    plot2.setRangeGridlinePaint(Color.white);

    CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis);
    cplot.add(plot1, 3);
    cplot.add(plot2, 2);
    cplot.setGap(8.0);
    cplot.setDomainGridlinePaint(Color.white);
    cplot.setDomainGridlinesVisible(true);

    // return a new chart containing the overlaid plot...
    JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1",
            JFreeChart.DEFAULT_TITLE_FONT, cplot, false);
    chart.setBackgroundPaint(Color.white);
    LegendTitle legend = new LegendTitle(cplot);
    chart.addSubtitle(legend);
    return chart;
}
 
Example 20
Source File: GrammarvizChartPanel.java    From grammarviz2_src with GNU General Public License v2.0 4 votes vote down vote up
/**
 * create the chart for the original time series
 * 
 * @param tsData the data to plot.
 * 
 * @return a JFreeChart object of the chart
 */
private void paintTheChart(double[] tsData) {

  // making the data
  //
  XYSeries dataset = new XYSeries("Series");
  for (int i = 0; i < tsData.length; i++) {
    dataset.add(i, (float) tsData[i]);
  }
  chartXYSeriesCollection = new XYSeriesCollection(dataset);

  // set the renderer
  //
  XYLineAndShapeRenderer xyRenderer = new XYLineAndShapeRenderer(true, false);
  xyRenderer.setSeriesPaint(0, new Color(0, 0, 0));
  xyRenderer.setBaseStroke(new BasicStroke(3));

  // X - the time axis
  //
  NumberAxis timeAxis = new NumberAxis("Time. (zoom: select with mouse; panning: Ctrl+mouse)");

  // Y axis
  //
  NumberAxis valueAxis = new NumberAxis("Values");
  valueAxis.setAutoRangeIncludesZero(false);

  // put these into collection of dots
  //
  this.timeseriesPlot = new XYPlot(chartXYSeriesCollection, timeAxis, valueAxis, xyRenderer);

  // enabling panning
  //
  this.timeseriesPlot.setDomainPannable(true);
  this.timeseriesPlot.setRangePannable(true);

  // finally, create the chart
  this.chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, timeseriesPlot, false);

  // set the progress listener to react to mouse clicks in the chart
  this.chart.addProgressListener(this);
  this.chart.setNotify(true);

}