/** * Writes out the contents of a series colors block for a chart. Assumes the caller * has already written the <code><seriesColors></code> tag. * * @param seriesColors the colors to write */ private void writeSeriesColors(SortedSet<JRSeriesColor> seriesColors) throws IOException { if (seriesColors == null || seriesColors.size() == 0) { return; } //FIXME why do we need an array? JRSeriesColor[] colors = seriesColors.toArray(new JRSeriesColor[seriesColors.size()]); for (int i = 0; i < colors.length; i++) { writer.startElement(JRXmlConstants.ELEMENT_seriesColor); writer.addAttribute(JRXmlConstants.ATTRIBUTE_seriesOrder, colors[i].getSeriesOrder()); writer.addAttribute(JRXmlConstants.ATTRIBUTE_color, colors[i].getColor()); writer.closeElement(); } }
/** * Writes out the contents of a series colors block for a chart. Assumes the caller * has already written the <code><seriesColors></code> tag. * * @param seriesColors the colors to write */ private void writeSeriesColors( SortedSet<JRSeriesColor> seriesColors, String parentName) { if (seriesColors == null || seriesColors.size() == 0) { return; } //FIXME why do we need an array? JRSeriesColor[] colors = seriesColors.toArray(new JRSeriesColor[seriesColors.size()]); for (int i = 0; i < colors.length; i++) { String seriesColorName = parentName + "SeriesColor" +i; write( "JRBaseSeriesColor " + seriesColorName + " = new JRBaseSeriesColor(" + colors[i].getSeriesOrder() +", {0});\n", colors[i].getColor()); write( parentName + ".addSeriesColor(" + seriesColorName + ");\n"); flush(); } }
/** * The series colors set in the main plot of a multiple axis chart are used for * all the rendered charts in the plot. This is a problem with multiple line * charts, using different scales and thus different axis. All the lines will * be drawn using the first series color (since they are the first series for that * rendered) and it will be impossible to tell them apart. * <br><br> * For this reason we interpret series colors for charts included in a multiple * axis chart as specify absolute series colors for that renderer. * * @param renderer the renderer of the chart being created * @param jrPlot the Jasper view of that plot */ private void configureAxisSeriesColors(CategoryItemRenderer renderer, JRChartPlot jrPlot) { SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors(); if (seriesColors != null) { Iterator<JRSeriesColor> iter = seriesColors.iterator(); while (iter.hasNext()) { JRSeriesColor seriesColor = iter.next(); renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor()); } } }
/** * The series colors set in the main plot of a multiple axis chart are used for * all the rendered charts in the plot. This is a problem with multiple line * charts, using different scales and thus different axis. All the lines will * be drawn using the first series color (since they are the first series for that * rendered) and it will be impossible to tell them apart. * <br> * For this reason we interpret series colors for charts included in a multiple * axis chart as specify absolute series colors for that renderer. * * @param renderer the renderer of the chart being created * @param jrPlot the Jasper view of that plot */ private void configureAxisSeriesColors(XYItemRenderer renderer, JRChartPlot jrPlot) { SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors(); if (seriesColors != null) { Iterator<JRSeriesColor> iter = seriesColors.iterator(); while (iter.hasNext()) { JRSeriesColor seriesColor = iter.next(); renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor()); } } }
public void setPropertyValue(Object id, Object value) { JRBaseChartPlot jrElement = (JRBaseChartPlot) getValue(); if (id.equals(JRBaseChartPlot.PROPERTY_BACKCOLOR)) { if (value instanceof AlfaRGB) jrElement.setBackcolor(Colors.getAWT4SWTRGBColor((AlfaRGB) value)); } else if (id.equals(JRBaseChartPlot.PROPERTY_BACKGROUND_ALPHA)) { jrElement.setBackgroundAlpha((Float) value); } else if (id.equals(JRBaseChartPlot.PROPERTY_FOREGROUND_ALPHA)) { jrElement.setForegroundAlpha((Float) value); } else if (id.equals(JRBaseChartPlot.PROPERTY_ORIENTATION)) { switch ((Integer) value) { case 0: jrElement.setOrientation((PlotOrientationEnum) null); break; case 1: jrElement.setOrientation(PlotOrientationEnum.HORIZONTAL); break; case 2: jrElement.setOrientation(PlotOrientationEnum.VERTICAL); break; } // jrElement.setOrientation((PlotOrientationEnum) orientationD // .getEnumValue(value)); } else if (id.equals(JRBaseChartPlot.PROPERTY_SERIES_COLORS)) { jrElement.setSeriesColors((Collection<JRSeriesColor>) value); // jrElement.clearSeriesColors(); // if (value instanceof SortedSet) { // SortedSet<JRSeriesColor> set = (SortedSet<JRSeriesColor>) value; // for (JRSeriesColor sc : set) { // jrElement.addSeriesColor(sc); // } // } } }
private void configureAxisSeriesColors(CategoryItemRenderer renderer, JRChartPlot jrPlot) { SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors(); if (seriesColors != null) { Iterator<JRSeriesColor> iter = seriesColors.iterator(); while (iter.hasNext()) { JRSeriesColor seriesColor = iter.next(); renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor()); } } }
private void configureAxisSeriesColors(XYItemRenderer renderer, JRChartPlot jrPlot) { SortedSet<JRSeriesColor> seriesColors = jrPlot.getSeriesColors(); if (seriesColors != null) { Iterator<JRSeriesColor> iter = seriesColors.iterator(); while (iter.hasNext()) { JRSeriesColor seriesColor = iter.next(); renderer.setSeriesPaint(seriesColor.getSeriesOrder(), seriesColor.getColor()); } } }
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 ) ); }
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; }