org.jfree.chart.renderer.xy.XYBarRenderer Java Examples

The following examples show how to use org.jfree.chart.renderer.xy.XYBarRenderer. 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: ChartFactory.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the current chart theme.  This will be applied to all new charts
 * created via methods in this class.
 *
 * @param theme  the theme (<code>null</code> not permitted).
 *
 * @see #getChartTheme()
 * @see ChartUtilities#applyCurrentTheme(JFreeChart)
 *
 * @since 1.0.11
 */
public static void setChartTheme(ChartTheme theme) {
    ParamChecks.nullNotPermitted(theme, "theme");
    currentTheme = theme;

    // here we do a check to see if the user is installing the "Legacy"
    // theme, and reset the bar painters in that case...
    if (theme instanceof StandardChartTheme) {
        StandardChartTheme sct = (StandardChartTheme) theme;
        if (sct.getName().equals("Legacy")) {
            BarRenderer.setDefaultBarPainter(new StandardBarPainter());
            XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
        }
        else {
            BarRenderer.setDefaultBarPainter(new GradientBarPainter());
            XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
        }
    }
}
 
Example #3
Source File: XYPlotTest.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"),
            new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #4
Source File: XYPlotTest.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"),
            new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #5
Source File: XYPlotTest.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"),
            new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #6
Source File: ChartFactory.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the current chart theme.  This will be applied to all new charts
 * created via methods in this class.
 *
 * @param theme  the theme (<code>null</code> not permitted).
 *
 * @see #getChartTheme()
 * @see ChartUtilities#applyCurrentTheme(JFreeChart)
 *
 * @since 1.0.11
 */
public static void setChartTheme(ChartTheme theme) {
    ParamChecks.nullNotPermitted(theme, "theme");
    currentTheme = theme;

    // here we do a check to see if the user is installing the "Legacy"
    // theme, and reset the bar painters in that case...
    if (theme instanceof StandardChartTheme) {
        StandardChartTheme sct = (StandardChartTheme) theme;
        if (sct.getName().equals("Legacy")) {
            BarRenderer.setDefaultBarPainter(new StandardBarPainter());
            XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
        }
        else {
            BarRenderer.setDefaultBarPainter(new GradientBarPainter());
            XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
        }
    }
}
 
Example #7
Source File: ChartJFreeChartOutputHistogram.java    From gama with GNU General Public License v3.0 6 votes vote down vote up
public static void enableFlatLook(final boolean flat) {
	if (flat) {
		BarRenderer.setDefaultBarPainter(new StandardBarPainter());
		BarRenderer.setDefaultShadowsVisible(false);
		XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
		XYBarRenderer.setDefaultShadowsVisible(false);
		StackedBarRenderer.setDefaultBarPainter(new StandardBarPainter());
		StackedBarRenderer.setDefaultShadowsVisible(false);
	} else {
		BarRenderer.setDefaultBarPainter(new GradientBarPainter());
		BarRenderer.setDefaultShadowsVisible(true);
		XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
		XYBarRenderer.setDefaultShadowsVisible(true);
		StackedBarRenderer.setDefaultBarPainter(new GradientBarPainter());
		StackedBarRenderer.setDefaultShadowsVisible(true);
	}
}
 
Example #8
Source File: EyeCandySixtiesChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
protected JFreeChart createXYBarChart() throws JRException
{
	JFreeChart jfreeChart = super.createXYBarChart();
	XYPlot xyPlot = (XYPlot)jfreeChart.getPlot();
	XYBarRenderer renderer = (XYBarRenderer)xyPlot.getRenderer();
	renderer.setMargin(0.1);
	renderer.setGradientPaintTransformer(
			new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)
			);
	XYDataset xyDataset = xyPlot.getDataset();
	if (xyDataset != null)
	{
		for (int i = 0; i < xyDataset.getSeriesCount(); i++)
		{
			renderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
		}
	}
	return jfreeChart;
}
 
Example #9
Source File: HistogramChartFactory.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min,
    double max) {
  if (data != null && data.length > 0) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.addSeries("histo", data, bin, min, max);

    JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset,
        PlotOrientation.VERTICAL, true, false, false);

    chart.setBackgroundPaint(new Color(230, 230, 230));
    chart.getLegend().setVisible(false);
    XYPlot xyplot = chart.getXYPlot();
    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;
  } else
    return null;
}
 
Example #10
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 #11
Source File: XYBarRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A simple test for the findRangeBounds() method.
 */
public void testFindRangeBounds() {
    DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset();
    double[] x = {1.0, 2.0, 3.0, 4.0};
    double[] startx = {0.9, 1.8, 2.7, 3.6};
    double[] endx = {1.1, 2.2, 3.3, 4.4};
    double[] y = {1.0, 2.0, 3.0, 4.0};
    double[] starty = {0.9, 1.8, 2.7, 3.6};
    double[] endy = {1.1, 2.2, 3.3, 4.4};
    double[][] data = new double[][] {x, startx, endx, y, starty, endy};
    dataset.addSeries("Series 1", data);
    XYBarRenderer renderer = new XYBarRenderer();
    renderer.setUseYInterval(true);
    Range r = renderer.findRangeBounds(dataset);
    assertEquals(0.9, r.getLowerBound(), EPSILON);
    assertEquals(4.4, r.getUpperBound(), EPSILON);

    renderer.setUseYInterval(false);
    r = renderer.findRangeBounds(dataset);
    assertEquals(1.0, r.getLowerBound(), EPSILON);
    assertEquals(4.0, r.getUpperBound(), EPSILON);
}
 
Example #12
Source File: PseudoSpectraRenderer.java    From mzmine2 with GNU General Public License v2.0 6 votes vote down vote up
public PseudoSpectraRenderer(Color color, boolean isTransparent) {

    this.isTransparent = isTransparent;

    // Set painting color
    setDefaultPaint(color);

    // Shadow makes fake peaks
    setShadowVisible(false);

    // Set the tooltip generator
    SpectraToolTipGenerator tooltipGenerator = new SpectraToolTipGenerator();
    setDefaultToolTipGenerator(tooltipGenerator);

    // We want to paint the peaks using simple color without any gradient
    // effects
    setBarPainter(new StandardXYBarPainter() {
      @Override
      public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, int column,
          RectangularShape bar, RectangleEdge base) {
        super.paintBar(g2, renderer, row, column, new Rectangle2D.Double(
            bar.getX() + (bar.getWidth() - 1.5) / 2, bar.getY(), 1.5, bar.getHeight()), base);
      }
    });
  }
 
Example #13
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Sets the current chart theme.  This will be applied to all new charts
 * created via methods in this class.
 *
 * @param theme  the theme (<code>null</code> not permitted).
 *
 * @see #getChartTheme()
 * @see ChartUtilities#applyCurrentTheme(JFreeChart)
 *
 * @since 1.0.11
 */
public static void setChartTheme(ChartTheme theme) {
    if (theme == null) {
        throw new IllegalArgumentException("Null 'theme' argument.");
    }
    currentTheme = theme;

    // here we do a check to see if the user is installing the "Legacy"
    // theme, and reset the bar painters in that case...
    if (theme instanceof StandardChartTheme) {
        StandardChartTheme sct = (StandardChartTheme) theme;
        if (sct.getName().equals("Legacy")) {
            BarRenderer.setDefaultBarPainter(new StandardBarPainter());
            XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
        }
        else {
            BarRenderer.setDefaultBarPainter(new GradientBarPainter());
            XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
        }
    }
}
 
Example #14
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates a histogram chart.  This chart is constructed with an
 * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range
 * axes are {@link NumberAxis} instances.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  the x axis label (<code>null</code> permitted).
 * @param yAxisLabel  the y axis label (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param legend  create a legend?
 *
 * @return The chart.
 */
public static JFreeChart createHistogram(String title, String xAxisLabel,
        String yAxisLabel, IntervalXYDataset dataset, boolean legend) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new XYBarRenderer();
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    currentTheme.apply(chart);
    return chart;

}
 
Example #15
Source File: XYPlotTest.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"),
            new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #16
Source File: StandardChartTheme.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToXYItemRenderer(XYItemRenderer renderer) {
    if (renderer == null) {
        throw new IllegalArgumentException("Null 'renderer' argument.");
    }
    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }
    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);
    if (renderer instanceof XYBarRenderer) {
        XYBarRenderer br = (XYBarRenderer) renderer;
        br.setBarPainter(this.xyBarPainter);
        br.setShadowVisible(this.shadowVisible);
    }
}
 
Example #17
Source File: BeltDateTimeColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(final Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example #18
Source File: BeltNumericalColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example #19
Source File: HistogramChartFactory.java    From mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min,
    double max) {
  if (data != null && data.length > 0) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.addSeries("histo", data, bin, min, max);

    JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset,
        PlotOrientation.VERTICAL, true, false, false);

    chart.setBackgroundPaint(new Color(230, 230, 230));
    chart.getLegend().setVisible(false);
    XYPlot xyplot = chart.getXYPlot();
    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;
  } else
    return null;
}
 
Example #20
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 #21
Source File: BeltTimeColumnStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 */
private JFreeChart createHistogramChart(final Table table) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(table),
			PlotOrientation.VERTICAL, false, false, false);
	setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example #22
Source File: DateTimeAttributeStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 *
 * @param exampleSet
 * @return
 */
private JFreeChart createHistogramChart(final ExampleSet exampleSet) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.getDomainAxis().setTickLabelsVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.DATE_TIME));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example #23
Source File: NumericalAttributeStatisticsModel.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Creates the histogram chart.
 *
 * @param exampleSet
 * @return
 */
private JFreeChart createHistogramChart(ExampleSet exampleSet) {
	JFreeChart chart = ChartFactory.createHistogram(null, null, null, createHistogramDataset(exampleSet),
			PlotOrientation.VERTICAL, false, false, false);
	AbstractAttributeStatisticsModel.setDefaultChartFonts(chart);
	chart.setBackgroundPaint(null);
	chart.setBackgroundImageAlpha(0.0f);

	XYPlot plot = (XYPlot) chart.getPlot();
	plot.setRangeGridlinesVisible(false);
	plot.setDomainGridlinesVisible(false);
	plot.setOutlineVisible(false);
	plot.setRangeZeroBaselineVisible(false);
	plot.setDomainZeroBaselineVisible(false);
	plot.setBackgroundPaint(COLOR_INVISIBLE);
	plot.setBackgroundImageAlpha(0.0f);

	XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
	renderer.setSeriesPaint(0, AttributeGuiTools.getColorForValueType(Ontology.NUMERICAL));
	renderer.setBarPainter(new StandardXYBarPainter());
	renderer.setDrawBarOutline(true);
	renderer.setShadowVisible(false);

	return chart;
}
 
Example #24
Source File: ChartFactory.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Sets the current chart theme.  This will be applied to all new charts
 * created via methods in this class.
 *
 * @param theme  the theme (<code>null</code> not permitted).
 *
 * @see #getChartTheme()
 * @see ChartUtilities#applyCurrentTheme(JFreeChart)
 *
 * @since 1.0.11
 */
public static void setChartTheme(ChartTheme theme) {
    ParamChecks.nullNotPermitted(theme, "theme");
    currentTheme = theme;

    // here we do a check to see if the user is installing the "Legacy"
    // theme, and reset the bar painters in that case...
    if (theme instanceof StandardChartTheme) {
        StandardChartTheme sct = (StandardChartTheme) theme;
        if (sct.getName().equals("Legacy")) {
            BarRenderer.setDefaultBarPainter(new StandardBarPainter());
            XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter());
        }
        else {
            BarRenderer.setDefaultBarPainter(new GradientBarPainter());
            XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter());
        }
    }
}
 
Example #25
Source File: HistogramChartFactory.java    From old-mzmine3 with GNU General Public License v2.0 6 votes vote down vote up
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min,
    double max) {
  if (data != null && data.length > 0) {
    HistogramDataset dataset = new HistogramDataset();
    dataset.addSeries("histo", data, bin, min, max);

    JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset,
        PlotOrientation.VERTICAL, true, false, false);

    chart.setBackgroundPaint(new Color(230, 230, 230));
    chart.getLegend().setVisible(false);
    XYPlot xyplot = chart.getXYPlot();
    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;
  } else
    return null;
}
 
Example #26
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 #27
Source File: XYPlotTest.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Tests cloning for a more complex plot.
 */
@Test
public void testCloning2() throws CloneNotSupportedException {
    XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"),
            new NumberAxis("Range Axis"), new StandardXYItemRenderer());
    p1.setRangeAxis(1, new NumberAxis("Range Axis 2"));
    List axisIndices = Arrays.asList(new Integer[] {new Integer(0),
            new Integer(1)});
    p1.mapDatasetToDomainAxes(0, axisIndices);
    p1.mapDatasetToRangeAxes(0, axisIndices);
    p1.setRenderer(1, new XYBarRenderer());
    XYPlot p2 = (XYPlot) p1.clone();
    assertTrue(p1 != p2);
    assertTrue(p1.getClass() == p2.getClass());
    assertTrue(p1.equals(p2));
}
 
Example #28
Source File: StandardChartTheme.java    From ECG-Viewer with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Applies the settings of this theme to the specified renderer.
 *
 * @param renderer  the renderer (<code>null</code> not permitted).
 */
protected void applyToXYItemRenderer(XYItemRenderer renderer) {
    ParamChecks.nullNotPermitted(renderer, "renderer");
    if (renderer instanceof AbstractRenderer) {
        applyToAbstractRenderer((AbstractRenderer) renderer);
    }
    renderer.setBaseItemLabelFont(this.regularFont);
    renderer.setBaseItemLabelPaint(this.itemLabelPaint);
    if (renderer instanceof XYBarRenderer) {
        XYBarRenderer br = (XYBarRenderer) renderer;
        br.setBarPainter(this.xyBarPainter);
        br.setShadowVisible(this.shadowVisible);
    }
}
 
Example #29
Source File: ChartFactory.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a histogram chart.  This chart is constructed with an 
 * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range 
 * axes are {@link NumberAxis} instances.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  the x axis label (<code>null</code> permitted).
 * @param yAxisLabel  the y axis label (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical) 
 *                     (<code>null</code> NOT permitted).
 * @param legend  create a legend?
 * @param tooltips  display tooltips?
 * @param urls  generate URLs?
 *
 * @return The chart.
 */
public static JFreeChart createHistogram(String title,
                                         String xAxisLabel,
                                         String yAxisLabel,
                                         IntervalXYDataset dataset,
                                         PlotOrientation orientation,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);

    XYItemRenderer renderer = new XYBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseURLGenerator(new StandardXYURLGenerator());
    }

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}
 
Example #30
Source File: ChartFactory.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a histogram chart.  This chart is constructed with an 
 * {@link XYPlot} using an {@link XYBarRenderer}.  The domain and range 
 * axes are {@link NumberAxis} instances.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  the x axis label (<code>null</code> permitted).
 * @param yAxisLabel  the y axis label (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param orientation  the orientation (horizontal or vertical) 
 *                     (<code>null</code> NOT permitted).
 * @param legend  create a legend?
 * @param tooltips  display tooltips?
 * @param urls  generate URLs?
 *
 * @return The chart.
 */
public static JFreeChart createHistogram(String title,
                                         String xAxisLabel,
                                         String yAxisLabel,
                                         IntervalXYDataset dataset,
                                         PlotOrientation orientation,
                                         boolean legend,
                                         boolean tooltips,
                                         boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    ValueAxis yAxis = new NumberAxis(yAxisLabel);

    XYItemRenderer renderer = new XYBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT,
            plot, legend);
    return chart;

}