List of usage examples for org.jfree.chart.renderer.xy XYBarRenderer setSeriesPaint
public void setSeriesPaint(int series, Paint paint, boolean notify)
From source file:org.simbrain.plot.histogram.HistogramPanel.java
public void reRender() { XYPlot plot = (XYPlot) mainChart.getPlot(); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); Iterator<ColoredDataSeries> series = model.getSeriesData().iterator(); for (int i = 0; i < model.getData().size(); i++) { if (i < colorPallet.length) { ColoredDataSeries s = series.next(); Color c = s.color;//from www . jav a 2 s .c o m if (c == null) { c = assignColor(); s.color = c; } renderer.setSeriesPaint(i, c, true); } } }
From source file:org.simbrain.plot.histogram.HistogramPanel.java
/** * Create the histogram panel based on the data. *//*from w w w. jav a2 s . c o m*/ public void createHistogram() { try { if (this.getModel().getData() != null) { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); XYPlot plot = (XYPlot) mainChart.getPlot(); plot.setForegroundAlpha(0.75F); // Sets y-axis ticks to integers. NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); Iterator<ColoredDataSeries> series = model.getSeriesData().iterator(); for (int i = 0; i < model.getData().size(); i++) { if (i < colorPallet.length) { ColoredDataSeries s = series.next(); Color c = s.color; if (c == null) { c = assignColor(); s.color = c; } renderer.setSeriesPaint(i, c, true); } } } else { mainChart = ChartFactory.createHistogram(title, xAxisName, yAxisName, model.getDataSet(), PlotOrientation.VERTICAL, true, true, false); mainChart.setBackgroundPaint(UIManager.getColor("this.Background")); } } catch (IllegalArgumentException iaEx) { iaEx.printStackTrace(); JOptionPane.showMessageDialog(null, iaEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } catch (IllegalStateException isEx) { isEx.printStackTrace(); JOptionPane.showMessageDialog(null, isEx.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } mainPanel = new ChartPanel(mainChart); }