Java Code Examples for org.jfree.chart.ChartFactory#createXYBarChart()

The following examples show how to use org.jfree.chart.ChartFactory#createXYBarChart() . 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: HistogramChartFactory.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) {
  XYSeriesCollection xydata = new XYSeriesCollection(series);
  XYBarDataset dataset = new XYBarDataset(xydata, barwidth);
  JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset,
      PlotOrientation.VERTICAL, true, true, false);

  XYPlot xyplot = chart.getXYPlot();
  chart.setBackgroundPaint(new Color(230, 230, 230));
  chart.getLegend().setVisible(false);
  xyplot.setForegroundAlpha(0.7F);
  xyplot.setBackgroundPaint(Color.WHITE);
  xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
  xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
  xyplot.getDomainAxis().setVisible(true);
  xyplot.getRangeAxis().setVisible(yAxisLabel != null);
  XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
  xybarrenderer.setShadowVisible(false);
  xybarrenderer.setBarPainter(new StandardXYBarPainter());
  xybarrenderer.setDrawBarOutline(false);
  return chart;
}
 
Example 2
Source File: XYBarChartTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createChart() {

    // create a dataset...
    XYSeries series1 = new XYSeries("Series 1");
    series1.add(1.0, 1.0);
    series1.add(2.0, 2.0);
    series1.add(3.0, 3.0);
    IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection(
            series1), 1.0);
 
    // create the chart...
    return ChartFactory.createXYBarChart(
        "XY Bar Chart",  // chart title
        "Domain", false,
        "Range",
        dataset,         // data
        PlotOrientation.VERTICAL,
        true,            // include legend
        true,            // tooltips
        true             // urls
    );

}
 
Example 3
Source File: Histogram.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected JFreeChart createChart( final IntervalXYDataset dataset, final String title, final String units )
{
	final JFreeChart chart = ChartFactory.createXYBarChart(
		title,
		"Distance [" + units + "]",
		false,
		"Count",
		dataset,
		PlotOrientation.VERTICAL,
		false, // legend
		false,
		false );

	final NumberAxis range = (NumberAxis) chart.getXYPlot().getDomainAxis();
	range.setRange( getMin(), getMax() );

	final XYPlot plot = chart.getXYPlot();
	final XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();

	renderer.setSeriesPaint( 0, Color.red );
	renderer.setDrawBarOutline( true );
	renderer.setSeriesOutlinePaint( 0, Color.black );
	renderer.setBarPainter( new StandardXYBarPainter() );

	return chart;
}
 
Example 4
Source File: XYBarRendererTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    XYSeriesCollection dataset
            = RendererXYPackageUtils.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X",
            false, "Y", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 5
Source File: HistogramChartFactory.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) {
  XYSeriesCollection xydata = new XYSeriesCollection(series);
  XYBarDataset dataset = new XYBarDataset(xydata, barwidth);
  JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset,
      PlotOrientation.VERTICAL, true, true, false);

  XYPlot xyplot = chart.getXYPlot();
  chart.setBackgroundPaint(new Color(230, 230, 230));
  chart.getLegend().setVisible(false);
  xyplot.setForegroundAlpha(0.7F);
  xyplot.setBackgroundPaint(Color.WHITE);
  xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
  xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
  xyplot.getDomainAxis().setVisible(true);
  xyplot.getRangeAxis().setVisible(yAxisLabel != null);
  XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
  xybarrenderer.setShadowVisible(false);
  xybarrenderer.setBarPainter(new StandardXYBarPainter());
  xybarrenderer.setDrawBarOutline(false);
  return chart;
}
 
Example 6
Source File: XYBarRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
public void testFindDomainBounds() {
    XYSeriesCollection dataset 
            = RendererXYPackageTests.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X", 
            false, "Y", dataset, PlotOrientation.VERTICAL, false, false, 
            false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 7
Source File: XYBarRendererTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    XYSeriesCollection dataset
            = RendererXYPackageUtils.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X",
            false, "Y", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 8
Source File: XYBarRendererTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    XYSeriesCollection dataset
            = RendererXYPackageUtils.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X",
            false, "Y", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 9
Source File: HistogramChartFactory.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) {
  XYSeriesCollection xydata = new XYSeriesCollection(series);
  XYBarDataset dataset = new XYBarDataset(xydata, barwidth);
  JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset,
      PlotOrientation.VERTICAL, true, true, false);

  XYPlot xyplot = chart.getXYPlot();
  chart.setBackgroundPaint(new Color(230, 230, 230));
  chart.getLegend().setVisible(false);
  xyplot.setForegroundAlpha(0.7F);
  xyplot.setBackgroundPaint(Color.WHITE);
  xyplot.setDomainGridlinePaint(new Color(150, 150, 150));
  xyplot.setRangeGridlinePaint(new Color(150, 150, 150));
  xyplot.getDomainAxis().setVisible(true);
  xyplot.getRangeAxis().setVisible(yAxisLabel != null);
  XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
  xybarrenderer.setShadowVisible(false);
  xybarrenderer.setBarPainter(new StandardXYBarPainter());
  xybarrenderer.setDrawBarOutline(false);
  return chart;
}
 
Example 10
Source File: XYBarRendererTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Check that the renderer is calculating the domain bounds correctly.
 */
@Test
public void testFindDomainBounds() {
    XYSeriesCollection dataset
            = RendererXYPackageUtils.createTestXYSeriesCollection();
    JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X",
            false, "Y", dataset, PlotOrientation.VERTICAL, false, false,
            false);
    XYPlot plot = (XYPlot) chart.getPlot();
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setAutoRangeIncludesZero(false);
    Range bounds = domainAxis.getRange();
    assertFalse(bounds.contains(0.3));
    assertTrue(bounds.contains(0.5));
    assertTrue(bounds.contains(2.5));
    assertFalse(bounds.contains(2.8));
}
 
Example 11
Source File: IsotopePeakScannerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
private void updateChart(ExtendedIsotopePattern pattern) {
  dataset = new ExtendedIsotopePatternDataSet(pattern, minIntensity, mergeWidth);
  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      dataset);
  formatChart();
  pnlChart.setChart(chart);
}
 
Example 12
Source File: IsotopePatternPreviewDialog.java    From mzmine2 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * this is being called by the calculation task to update the pattern
 * @param pattern
 */
protected void updateChart(ExtendedIsotopePattern pattern) {
  dataset = new ExtendedIsotopePatternDataSet(pattern, minIntensity, mergeWidth);
  if (pol == PolarityType.NEUTRAL)
    chart = ChartFactory.createXYBarChart("Isotope pattern preview", "Exact mass / Da", false,
        "Abundance", dataset);
  else
    chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
        dataset);

  formatChart();

  pnlChart.setChart(chart);
}
 
Example 13
Source File: IsotopePeakScannerSetupDialog.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void updateChart(ExtendedIsotopePattern pattern) {
  dataset = new ExtendedIsotopePatternDataSet(pattern, minIntensity, mergeWidth);
  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      dataset);
  formatChart();
  pnlChart.setChart(chart);
}
 
Example 14
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET ){
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart, getPlot());

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator());
		itemRenderer.setShadowVisible(false);

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getOwnCategoryAxisLineColor(), false,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getOwnValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

		return jfreeChart;
	}
 
Example 15
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET ){
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart, getPlot());

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator());
		itemRenderer.setShadowVisible(false);

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), DateTickUnitType.DAY,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression())
				);


		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), DateTickUnitType.DAY,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression())
				);

		return jfreeChart;
	}
 
Example 16
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
	 *
	 */
	protected JFreeChart createXYBarChart() throws JRException
	{
		IntervalXYDataset tmpDataset = (IntervalXYDataset)getDataset();

		boolean isDate = true;
		if ( getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET )
		{
			isDate = false;
		}

		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createXYBarChart(
				evaluateTextExpression(getChart().getTitleExpression()),
				evaluateTextExpression(((JRBarPlot)getPlot()).getCategoryAxisLabelExpression()),
				isDate,
				evaluateTextExpression(((JRBarPlot)getPlot()).getValueAxisLabelExpression()),
				tmpDataset,
				getPlot().getOrientationValue().getOrientation(),
				isShowLegend(),
				true,
				false
				);

		configureChart(jfreeChart);

		XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
		//plot.setNoDataMessage("No data to display");
//		((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
//			((JRFillBarPlot)getPlot()).isShowTickMarks()
//			);
//		((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
//				((JRFillBarPlot)getPlot()).isShowTickLabels()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
//				((JRFillBarPlot)getPlot()).isShowTickMarks()
//				);
//		((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
//				((JRFillBarPlot)getPlot()).isShowTickLabels()
//				);


		XYBarRenderer itemRenderer = (XYBarRenderer)xyPlot.getRenderer();
		itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator)getLabelGenerator() );
		itemRenderer.setShadowVisible(false);
		

		JRBarPlot barPlot = (JRBarPlot)getPlot();
		boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();
		
		itemRenderer.setBaseItemLabelsVisible( isShowLabels );

		// Handle the axis formating for the category axis
		configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
				barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
				barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(), barPlot.getCategoryAxisVerticalTickLabels(),
				barPlot.getCategoryAxisLineColor(), false,
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

		// Handle the axis formating for the value axis
		configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
				barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
				barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
				barPlot.getValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

		return jfreeChart;
	}
 
Example 17
Source File: IsotopePeakScannerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void addDialogComponents() {
  super.addDialogComponents();

  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  pnlChart = new EChartPanel(chart);
  pnlChart.setPreferredSize(
      new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
  pnlPreview.add(pnlChart, BorderLayout.CENTER);


  // get components
  cmpAutoCarbon = (OptionalModuleComponent) this
      .getComponentForParameter(IsotopePeakScannerParameters.autoCarbonOpt);
  cmpAutoCarbonCbx = (JCheckBox) cmpAutoCarbon.getComponent(0);
  cmpPreview =
      (JCheckBox) this.getComponentForParameter(IsotopePeakScannerParameters.showPreview);
  cmpPreview.setSelected(false); // i want to have the checkbox below the pattern settings
  // but it should be disabled by default. Thats why it's hardcoded here.

  // get parameters
  pElement = parameterSet.getParameter(IsotopePeakScannerParameters.element);
  pMinIntensity = parameterSet.getParameter(IsotopePeakScannerParameters.minPatternIntensity);
  pCharge = parameterSet.getParameter(IsotopePeakScannerParameters.charge);
  pMergeWidth = parameterSet.getParameter(IsotopePeakScannerParameters.mergeWidth);
  pAutoCarbon = parameterSet.getParameter(IsotopePeakScannerParameters.autoCarbonOpt);
  autoCarbonParameters = pAutoCarbon.getEmbeddedParameters();
  pMinC = autoCarbonParameters.getParameter(AutoCarbonParameters.minCarbon);
  pMaxC = autoCarbonParameters.getParameter(AutoCarbonParameters.maxCarbon);
  pMinSize = autoCarbonParameters.getParameter(AutoCarbonParameters.minPatternSize);

  // set up gui
  form = new NumberFormatter(NumberFormat.getInstance());
  form.setValueClass(Integer.class);
  form.setFormat(new DecimalFormat("0"));
  form.setAllowsInvalid(true);
  form.setMinimum(minC);
  form.setMaximum(maxC);

  btnPrevPattern = new JButton("Previous");
  btnPrevPattern.addActionListener(this);
  btnPrevPattern.setMinimumSize(btnPrevPattern.getPreferredSize());
  btnPrevPattern.setEnabled(cmpAutoCarbonCbx.isSelected());

  txtCurrentPatternIndex = new JFormattedTextField(form);
  txtCurrentPatternIndex.addActionListener(this);
  txtCurrentPatternIndex.setText(String.valueOf((minC + maxC) / 2));
  txtCurrentPatternIndex.setPreferredSize(new Dimension(50, 25));
  txtCurrentPatternIndex.setEditable(true);
  txtCurrentPatternIndex.setEnabled(cmpAutoCarbonCbx.isSelected());

  btnNextPattern = new JButton("Next");
  btnNextPattern.addActionListener(this);
  btnNextPattern.setPreferredSize(btnNextPattern.getMinimumSize());
  btnNextPattern.setEnabled(cmpAutoCarbonCbx.isSelected());

  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      new XYSeriesCollection(new XYSeries("")));
  chart.getPlot().setBackgroundPaint(Color.WHITE);
  chart.getXYPlot().setDomainGridlinePaint(Color.GRAY);
  chart.getXYPlot().setRangeGridlinePaint(Color.GRAY);

  pnlPreviewButtons.add(btnPrevPattern);
  pnlPreviewButtons.add(txtCurrentPatternIndex);
  pnlPreviewButtons.add(btnNextPattern);

  pack();
}
 
Example 18
Source File: IsotopePatternPreviewDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void addDialogComponents() {
  super.addDialogComponents();

  pFormula = parameterSet.getParameter(IsotopePatternPreviewParameters.formula);
  pMinIntensity = parameterSet.getParameter(IsotopePatternPreviewParameters.minIntensity);
  pMergeWidth = parameterSet.getParameter(IsotopePatternPreviewParameters.mergeWidth);
  pCharge = parameterSet.getParameter(IsotopePatternPreviewParameters.charge);

  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  cmpMinIntensity =
      (PercentComponent) getComponentForParameter(IsotopePatternPreviewParameters.minIntensity);
  cmpMergeWidth =
      (DoubleComponent) getComponentForParameter(IsotopePatternPreviewParameters.mergeWidth);
  cmpCharge = (IntegerComponent) getComponentForParameter(IsotopePatternPreviewParameters.charge);
  cmpFormula =
      (StringComponent) getComponentForParameter(IsotopePatternPreviewParameters.formula);

  // panels
  newMainPanel = new JPanel(new BorderLayout());
  pnText = new JScrollPane();
  pnlChart = new EChartPanel(chart);
  pnSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, pnlChart, pnText);
  table = new JTable();
  pnlParameters = new JPanel(new FlowLayout());
  pnlControl = new JPanel(new BorderLayout());

  pnText.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  pnText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

  pnText.setMinimumSize(new Dimension(350, 300));
  pnlChart.setMinimumSize(new Dimension(350, 200));
  pnlChart.setPreferredSize( // TODO: can you do this cleaner?
      new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
  table.setMinimumSize(new Dimension(350, 300));
  table.setDefaultEditor(Object.class, null);

  // controls
  ttGen = new SpectraToolTipGenerator();
  theme = new EIsotopePatternChartTheme();
  theme.initialize();

  // reorganize
  getContentPane().remove(mainPanel);
  organizeParameterPanel();
  pnlControl.add(pnlParameters, BorderLayout.CENTER);
  pnlControl.add(pnlButtons, BorderLayout.SOUTH);
  newMainPanel.add(pnSplit, BorderLayout.CENTER);
  newMainPanel.add(pnlControl, BorderLayout.SOUTH);
  getContentPane().add(newMainPanel);
  pnlButtons.remove(super.btnCancel);

  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      new XYSeriesCollection(new XYSeries("")));
  pnlChart.setChart(chart);
  pnText.setViewportView(table);

  updateMinimumSize();
  pack();
}
 
Example 19
Source File: LiquidityChartBuilder.java    From projectforge-webapp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @param forecast
 * @param settings (next days)
 * @return
 */
public JFreeChart createBarChart(final LiquidityForecast forecast, final LiquidityForecastSettings settings)
{
  Validate.isTrue(settings.getNextDays() > 0 && settings.getNextDays() < 500);
  final LiquidityForecastCashFlow cashFlow = new LiquidityForecastCashFlow(forecast, settings.getNextDays());
  final TimeSeries accumulatedSeriesExpected = new TimeSeries(I18n.getString("plugins.liquidityplanning.forecast.expected"));
  final TimeSeries creditSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.common.credit"));
  final TimeSeries debitSeries = new TimeSeries(I18n.getString("plugins.liquidityplanning.common.debit"));
  double accumulatedExpected = settings.getStartAmount().doubleValue();

  final DayHolder dh = new DayHolder();
  final Date lower = dh.getDate();
  for (int i = 0; i < settings.getNextDays(); i++) {
    final Day day = new Day(dh.getDayOfMonth(), dh.getMonth() + 1, dh.getYear());
    if (i > 0) {
      accumulatedExpected += cashFlow.getDebitsExpected()[i - 1].doubleValue() + cashFlow.getCreditsExpected()[i - 1].doubleValue();
    }
    accumulatedSeriesExpected.add(day, accumulatedExpected);
    creditSeries.add(day, cashFlow.getCreditsExpected()[i].doubleValue());
    debitSeries.add(day, cashFlow.getDebitsExpected()[i].doubleValue());
    dh.add(Calendar.DATE, 1);
  }
  dh.add(Calendar.DATE, -1);
  final XYChartBuilder cb = new XYChartBuilder(ChartFactory.createXYBarChart(null, null, false, null, null, PlotOrientation.VERTICAL,
      false, false, false));
  int counter = 0;

  final TimeSeriesCollection xyDataSeries = new TimeSeriesCollection();
  xyDataSeries.addSeries(accumulatedSeriesExpected);
  final XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, true);
  lineRenderer.setSeriesPaint(0, cb.getRedMarker());
  lineRenderer.setSeriesVisibleInLegend(0, true);
  cb.setRenderer(counter, lineRenderer).setDataset(counter++, xyDataSeries)
  .setStrongStyle(lineRenderer, false, accumulatedSeriesExpected);

  final TimeSeriesCollection cashflowSet = new TimeSeriesCollection();
  cashflowSet.addSeries(debitSeries);
  cashflowSet.addSeries(creditSeries);
  final XYBarRenderer barRenderer = new XYBarRenderer(.2);
  barRenderer.setSeriesPaint(0, cb.getGreenFill());
  barRenderer.setSeriesPaint(1, cb.getRedFill());
  barRenderer.setShadowVisible(false);
  cb.setRenderer(counter, barRenderer).setDataset(counter++, cashflowSet);

  cb.setDateXAxis(true).setDateXAxisRange(lower, dh.getDate()).setYAxis(true, null);
  return cb.getChart();
}
 
Example 20
Source File: IsotopePatternPreviewDialog.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
public IsotopePatternPreviewDialog(boolean valueCheckRequired, ParameterSet parameters) {
  super(valueCheckRequired, parameters);

  aboveMin = new Color(30, 180, 30);
  belowMin = new Color(200, 30, 30);

  lastCalc = 0;

  newParameters = false;
  // task = new IsotopePatternPreviewTask(formula, minIntensity,
  // mergeWidth, charge, pol, this);
  // thread = new Thread(task);

  pFormula = parameterSet.getParameter(IsotopePatternPreviewParameters.formula);
  pMinIntensity = parameterSet.getParameter(IsotopePatternPreviewParameters.minIntensity);
  pMergeWidth = parameterSet.getParameter(IsotopePatternPreviewParameters.mergeWidth);
  pCharge = parameterSet.getParameter(IsotopePatternPreviewParameters.charge);

  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  cmpMinIntensity = getComponentForParameter(IsotopePatternPreviewParameters.minIntensity);
  cmpMergeWidth = getComponentForParameter(IsotopePatternPreviewParameters.mergeWidth);
  cmpCharge = getComponentForParameter(IsotopePatternPreviewParameters.charge);
  cmpFormula = getComponentForParameter(IsotopePatternPreviewParameters.formula);

  // panels
  newMainPanel = new BorderPane();
  // pnText = new ScrollPane();
  pnlChart = new EChartViewer(chart);
  table = new TableView<>();
  pnSplit = new SplitPane(pnlChart, table);
  pnSplit.setOrientation(Orientation.HORIZONTAL);
  pnlParameters = new FlowPane();
  pnlControl = new BorderPane();

  // pnText.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
  // pnText.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

  // pnText.setMinimumSize(new Dimension(350, 300));
  // pnlChart.setMinimumSize(new Dimension(350, 200));
  // pnlChart.setPreferredSize( // TODO: can you do this cleaner?
  // new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
  // table.setMinimumSize(new Dimension(350, 300));
  // table.setDefaultEditor(Object.class, null);

  // controls
  ttGen = new SpectraToolTipGenerator();
  theme = new EIsotopePatternChartTheme();
  theme.initialize();

  // reorganize
  mainPane.getChildren().remove(paramsPane);
  organizeParameterPanel();
  pnlControl.setCenter(pnlParameters);
  pnlControl.setBottom(pnlButtons);
  newMainPanel.setCenter(pnSplit);
  newMainPanel.setBottom(pnlControl);
  mainPane.setCenter(newMainPanel);
  pnlButtons.getButtons().remove(super.btnCancel);

  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      new XYSeriesCollection(new XYSeries("")));
  pnlChart.setChart(chart);
  // pnText.setViewportView(table);


  formatChart();
  parametersChanged();
}