Java Code Examples for org.jfree.chart.plot.DefaultDrawingSupplier#DEFAULT_PAINT_SEQUENCE

The following examples show how to use org.jfree.chart.plot.DefaultDrawingSupplier#DEFAULT_PAINT_SEQUENCE . 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: ObdDataPlotter.java    From AndrOBD with GNU General Public License v3.0 5 votes vote down vote up
/**
 * add a new series to the graph
 *
 * @param series The new series to be added
 */
public synchronized void addSeries(TimeSeries series)
{

	if (oneRangePerSeries)
	{
		// get paint for current axis/range/...
		Paint currPaint =
			DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[
				raIndex % DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length];

		XYPlot plot = (XYPlot) chart.getPlot();
		// set dataset
		plot.setDataset(raIndex, new TimeSeriesCollection(series));
		// ** set axis
		NumberAxis axis = new NumberAxis();
		axis.setTickLabelFont(legendFont);
		axis.setAxisLinePaint(currPaint);
		axis.setTickLabelPaint(currPaint);
		axis.setTickMarkPaint(currPaint);
		// ** set axis in plot
		plot.setRangeAxis(raIndex, axis);
		plot.setRangeAxisLocation(raIndex, raIndex % 2 == 0 ? AxisLocation.TOP_OR_LEFT : AxisLocation.BOTTOM_OR_RIGHT);
		plot.mapDatasetToRangeAxis(raIndex, raIndex);
		// ** create renderer
		XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
		renderer.setBaseToolTipGenerator(toolTipGen);
		renderer.setSeriesPaint(0, currPaint);
		// ** set renderer in plot
		plot.setRenderer(raIndex, renderer);

		raIndex++;
	}
	dataset.addSeries(series);
}
 
Example 2
Source File: MultiAgentPerformancePlotter.java    From burlap with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a DeviationRenderer to use for the trial average plots
 * @return a DeviationRenderer
 */
protected DeviationRenderer createDeviationRenderer(){
	DeviationRenderer renderer = new DeviationRenderer(true, false);
	
	for(int i = 0; i < DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length; i++){
		Color c = (Color)DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i];
		Color nc = new Color(c.getRed(), c.getGreen(), c.getBlue(), 100);
		renderer.setSeriesFillPaint(i, nc);
	}
	
	return renderer;
}
 
Example 3
Source File: PerformancePlotter.java    From burlap with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a DeviationRenderer to use for the trial average plots
 * @return a DeviationRenderer
 */
protected DeviationRenderer createDeviationRenderer(){
	DeviationRenderer renderer = new DeviationRenderer(true, false);
	
	for(int i = 0; i < DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length; i++){
		Color c = (Color)DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[i];
		Color nc = new Color(c.getRed(), c.getGreen(), c.getBlue(), 100);
		renderer.setSeriesFillPaint(i, nc);
	}
	
	return renderer;
}
 
Example 4
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected void setPlotDrawingDefaults(Plot p, JRChartPlot jrPlot)
{
	@SuppressWarnings("unchecked")
	List<Paint> defaultSeriesColors = (List<Paint>)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
	Paint[] defaultPlotOutlinePaintSequence = 
		getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_OUTLINE_PAINT_SEQUENCE) != null ?
		(Paint[])getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_OUTLINE_PAINT_SEQUENCE) :
		DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE;
		
	Stroke[] defaultPlotStrokeSequence = 
		getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_STROKE_SEQUENCE) != null ?
		(Stroke[])getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_STROKE_SEQUENCE) :
		DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE;
		
	Stroke[] defaultPlotOutlineStrokeSequence = 
		getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_OUTLINE_STROKE_SEQUENCE) != null ?
		(Stroke[])getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_OUTLINE_STROKE_SEQUENCE) :
		DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE;
		
	Shape[] defaultPlotShapeSequence = 
		getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_SHAPE_SEQUENCE) != null ?
		(Shape[])getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_SHAPE_SEQUENCE) :
		DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE;
	// Set color series
	Paint[] colors = null;
	SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors();
	Paint[] colorSequence = null;
	if (seriesColors != null && seriesColors.size() > 0)
	{
		int seriesColorsSize = seriesColors.size();
		
		colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + seriesColorsSize];

		JRSeriesColor[] jrColorSequence = new JRSeriesColor[seriesColorsSize];
		seriesColors.toArray(jrColorSequence);
		colorSequence = new Paint[seriesColorsSize];
		
		for (int i = 0; i < seriesColorsSize; i++)
		{
			colorSequence[i] = jrColorSequence[i].getColor();
		}
		populateSeriesColors(colors, colorSequence);
	}
	else if (defaultSeriesColors != null && defaultSeriesColors.size() > 0)
	{
		colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + defaultSeriesColors.size()];
		colorSequence = new Paint[defaultSeriesColors.size()];
		defaultSeriesColors.toArray(colorSequence);
		populateSeriesColors(colors, colorSequence);
	}
	else
	{
		colors = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
	}
	
	p.setDrawingSupplier(new DefaultDrawingSupplier(
			colors,
			defaultPlotOutlinePaintSequence,
			defaultPlotStrokeSequence,
			defaultPlotOutlineStrokeSequence,
			defaultPlotShapeSequence
			)
		);
	
}
 
Example 5
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected Paint[] getPaintSequence(PlotSettings plotSettings, JRChartPlot jrPlot)
{
	Paint[] colors = null;
	SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors();
	Paint[] colorSequence = null;
	
	//The series gradient paint setting is considered first
	List<PaintProvider> themeSeriesPaintProvider = getChartThemeSettings().getPlotSettings().getSeriesGradientPaintSequence() != null 
			? getChartThemeSettings().getPlotSettings().getSeriesGradientPaintSequence()
			: getChartThemeSettings().getPlotSettings().getSeriesColorSequence();
			
	if (seriesColors != null && seriesColors.size() > 0)
	{
		int seriesColorsSize = seriesColors.size();
		
		colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + seriesColorsSize];

		JRSeriesColor[] jrColorSequence = new JRSeriesColor[seriesColorsSize];
		seriesColors.toArray(jrColorSequence);
		colorSequence = new Paint[seriesColorsSize];
		
		for (int i = 0; i < seriesColorsSize; i++)
		{
			colorSequence[i] = jrColorSequence[i].getColor();
		}
		populateSeriesColors(colors, colorSequence);
	}
	else if (themeSeriesPaintProvider != null && !themeSeriesPaintProvider.isEmpty())
	{
		colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + themeSeriesPaintProvider.size()];
		colorSequence = new Paint[themeSeriesPaintProvider.size()];
		List<Paint> themeSeriesColors = new ArrayList<Paint>();
		for (int i=0; i< themeSeriesPaintProvider.size(); i++)
		{
			themeSeriesColors.add(themeSeriesPaintProvider.get(i).getPaint());
		}
		themeSeriesColors.toArray(colorSequence);
		populateSeriesColors(colors, colorSequence);
	}
	else
	{
		colors = DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE;
	}
	return colors;
}