List of usage examples for org.jfree.chart.plot DefaultDrawingSupplier DefaultDrawingSupplier
public DefaultDrawingSupplier(Paint[] paintSequence, Paint[] outlinePaintSequence, Stroke[] strokeSequence,
Stroke[] outlineStrokeSequence, Shape[] shapeSequence)
From source file:net.sourceforge.atunes.kernel.modules.statistics.StatsDialogController.java
/** * Sets the general chart.// w w w. j ava 2 s .co m */ private void setGeneralChart() { DefaultPieDataset dataset = new DefaultPieDataset(); int different = this.statisticsHandler.getDifferentAudioObjectsPlayed(); int total = this.repositoryHandler.getAudioFilesList().size(); dataset.setValue(I18nUtils.getString("SONGS_PLAYED"), different); dataset.setValue(I18nUtils.getString("SONGS_NEVER_PLAYED"), total - different); JFreeChart chart = ChartFactory.createPieChart3D(I18nUtils.getString("SONGS_PLAYED"), dataset, false, false, false); chart.setBackgroundPaint(GuiUtils.getBackgroundColor()); chart.getTitle().setPaint(GuiUtils.getForegroundColor()); chart.setPadding(new RectangleInsets(5, 0, 0, 0)); DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier( new Paint[] { new Color(0, 1, 0, 0.6f), new Color(1, 0, 0, 0.6f) }, new Paint[] { new Color(0, 1, 0, 0.4f), new Color(1, 0, 0, 0.4f) }, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); chart.getPlot().setDrawingSupplier(drawingSupplier); ((PiePlot3D) chart.getPlot()).setOutlineVisible(false); ((PiePlot3D) chart.getPlot()).setBackgroundPaint(GuiUtils.getBackgroundColor()); getComponentControlled().getGeneralChart().setIcon(new ImageIcon(chart.createBufferedImage(710, 250))); }
From source file:cs.cirg.cida.CIDAView.java
@Action public void plotGraph() { lineSeriesComboBox.removeAllItems(); int numSelectedColumns = userSelectedColumns.size(); int numSelectedRows = userSelectedRows.size(); if (numSelectedColumns == 0) { return;/* w w w.j av a 2 s.c om*/ } StandardDataTable<Numeric> data = (StandardDataTable<Numeric>) ((IOBridgeTableModel) analysisTable .getModel()).getDataTable(); List<Numeric> iterations = data.getColumn(0); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); for (int i = 0; i < numSelectedColumns; i++) { int selectedColumnIndex = userSelectedColumns.get(i); List<Numeric> selectedColumn = data.getColumn(selectedColumnIndex); XYSeries series = new XYSeries(data.getColumnName(selectedColumnIndex)); for (int k = 0; k < numSelectedRows; k++) { int selectedRowIndex = userSelectedRows.get(k); series.add(iterations.get(selectedRowIndex).getReal(), selectedColumn.get(selectedRowIndex).getReal()); } xySeriesCollection.addSeries(series); lineSeriesComboBox.addItem(new SeriesPair(i, (String) series.getKey())); } String chartName = experimentController.getAnalysisName(); if (chartName.compareTo("") == 0) { chartName = CIDAConstants.DEFAULT_CHART_NAME; } JFreeChart chart = ChartFactory.createXYLineChart(chartName, // Title CIDAConstants.CHART_ITERATIONS_LABEL, // X-Axis label CIDAConstants.CHART_VALUE_LABEL, // Y-Axis label xySeriesCollection, // Dataset PlotOrientation.VERTICAL, true, // Show legend, false, //tooltips false //urls ); chart.setAntiAlias(true); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); Paint[] paints = new Paint[7]; paints[0] = Color.RED; paints[1] = Color.BLUE; paints[2] = new Color(0.08f, 0.5f, 0.04f); paints[3] = new Color(1.0f, 0.37f, 0.0f); paints[4] = new Color(0.38f, 0.07f, 0.42f); paints[5] = Color.CYAN; paints[6] = Color.PINK; plot.setDrawingSupplier( new DefaultDrawingSupplier(paints, paints, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.GRAY); plot.setRangeGridlinePaint(Color.GRAY); IntervalXYRenderer renderer = new IntervalXYRenderer(true, false); plot.setRenderer(renderer); lineTickIntervalInput.setText(Integer.toString(renderer.getLineTickInterval())); ((ChartPanel) chartPanel).setChart(chart); }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*from ww w . ja v a2 s .c o m*/ protected void configurePlot(Plot plot) { plot.setOutlinePaint(null); if (getPlot().getOwnBackcolor() == null)// in a way, plot backcolor inheritence from chart is useless { plot.setBackgroundPaint(null); } else { plot.setBackgroundPaint(getPlot().getBackcolor()); } float backgroundAlpha = getPlot().getBackgroundAlphaFloat() == null ? 1f : getPlot().getBackgroundAlphaFloat(); float foregroundAlpha = getPlot().getForegroundAlphaFloat() == null ? 1f : getPlot().getForegroundAlphaFloat(); plot.setBackgroundAlpha(backgroundAlpha); plot.setForegroundAlpha(foregroundAlpha); if (plot instanceof CategoryPlot) { // Handle rotation of the category labels. CategoryAxis axis = ((CategoryPlot) plot).getDomainAxis(); // it's OK to use deprecated method here; avoiding it means attempting cast operations double labelRotation = getLabelRotation(); if (labelRotation == 90) { axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); } else if (labelRotation == -90) { axis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); } else if (labelRotation < 0) { axis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions((-labelRotation / 180.0) * Math.PI)); } else if (labelRotation > 0) { axis.setCategoryLabelPositions( CategoryLabelPositions.createDownRotationLabelPositions((labelRotation / 180.0) * Math.PI)); } } // Set any color series SortedSet<JRSeriesColor> seriesColors = getPlot().getSeriesColors(); if (seriesColors != null && seriesColors.size() > 0) { if (seriesColors.size() == 1) { // Add the single color to the beginning of the color cycle, using all the default // colors. To replace the defaults you have to specify at least two colors. Paint[] colors = new Paint[DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length + 1]; colors[0] = seriesColors.first().getColor(); System.arraycopy(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, 0, colors, 1, DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE.length); plot.setDrawingSupplier( new DefaultDrawingSupplier(colors, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); } else if (seriesColors.size() > 1) { // Set up a custom drawing supplier that cycles through the user's colors // instead of the default colors. Color[] colors = new Color[seriesColors.size()]; JRSeriesColor[] colorSequence = new JRSeriesColor[seriesColors.size()]; seriesColors.toArray(colorSequence); for (int i = 0; i < colorSequence.length; i++) { colors[i] = colorSequence[i].getColor(); } plot.setDrawingSupplier( new DefaultDrawingSupplier(colors, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); } } }
From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java
private static void updatePlot(final Plot plot, final ChartDefinition chartDefinition) { plot.setBackgroundPaint(chartDefinition.getPlotBackgroundPaint()); plot.setBackgroundImage(chartDefinition.getPlotBackgroundImage()); plot.setNoDataMessage(chartDefinition.getNoDataMessage()); // create a custom palette if it was defined if (chartDefinition.getPaintSequence() != null) { DefaultDrawingSupplier drawingSupplier = new DefaultDrawingSupplier(chartDefinition.getPaintSequence(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); plot.setDrawingSupplier(drawingSupplier); }/*from w ww .jav a 2s . co m*/ plot.setOutlineStroke(null); // TODO define outline stroke if (plot instanceof CategoryPlot) { CategoryPlot categoryPlot = (CategoryPlot) plot; CategoryDatasetChartDefinition categoryDatasetChartDefintion = (CategoryDatasetChartDefinition) chartDefinition; categoryPlot.setOrientation(categoryDatasetChartDefintion.getOrientation()); CategoryAxis domainAxis = categoryPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(categoryDatasetChartDefintion.getDomainTitle()); domainAxis.setLabelFont(categoryDatasetChartDefintion.getDomainTitleFont()); if (categoryDatasetChartDefintion.getDomainTickFont() != null) { domainAxis.setTickLabelFont(categoryDatasetChartDefintion.getDomainTickFont()); } domainAxis.setCategoryLabelPositions(categoryDatasetChartDefintion.getCategoryLabelPositions()); } NumberAxis numberAxis = (NumberAxis) categoryPlot.getRangeAxis(); if (numberAxis != null) { numberAxis.setLabel(categoryDatasetChartDefintion.getRangeTitle()); numberAxis.setLabelFont(categoryDatasetChartDefintion.getRangeTitleFont()); if (categoryDatasetChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { numberAxis.setLowerBound(categoryDatasetChartDefintion.getRangeMinimum()); } if (categoryDatasetChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { numberAxis.setUpperBound(categoryDatasetChartDefintion.getRangeMaximum()); } if (categoryDatasetChartDefintion.getRangeTickFormat() != null) { numberAxis.setNumberFormatOverride(categoryDatasetChartDefintion.getRangeTickFormat()); } if (categoryDatasetChartDefintion.getRangeTickFont() != null) { numberAxis.setTickLabelFont(categoryDatasetChartDefintion.getRangeTickFont()); } if (categoryDatasetChartDefintion.getRangeTickUnits() != null) { numberAxis.setTickUnit(new NumberTickUnit(categoryDatasetChartDefintion.getRangeTickUnits())); } } } if (plot instanceof PiePlot) { PiePlot pie = (PiePlot) plot; PieDatasetChartDefinition pieDefinition = (PieDatasetChartDefinition) chartDefinition; pie.setInteriorGap(pieDefinition.getInteriorGap()); pie.setStartAngle(pieDefinition.getStartAngle()); pie.setLabelFont(pieDefinition.getLabelFont()); if (pieDefinition.getLabelPaint() != null) { pie.setLabelPaint(pieDefinition.getLabelPaint()); } pie.setLabelBackgroundPaint(pieDefinition.getLabelBackgroundPaint()); if (pieDefinition.isLegendIncluded()) { StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{0}"); //$NON-NLS-1$ pie.setLegendLabelGenerator(labelGen); } if (pieDefinition.getExplodedSlices() != null) { for (Iterator iter = pieDefinition.getExplodedSlices().iterator(); iter.hasNext();) { pie.setExplodePercent((Comparable) iter.next(), .30); } } pie.setLabelGap(pieDefinition.getLabelGap()); if (!pieDefinition.isDisplayLabels()) { pie.setLabelGenerator(null); } else { if (pieDefinition.isLegendIncluded()) { StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator("{1} ({2})"); //$NON-NLS-1$ pie.setLabelGenerator(labelGen); } else { StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator( "{0} = {1} ({2})"); //$NON-NLS-1$ pie.setLabelGenerator(labelGen); } } } if (plot instanceof MultiplePiePlot) { MultiplePiePlot pies = (MultiplePiePlot) plot; CategoryDatasetChartDefinition categoryDatasetChartDefintion = (CategoryDatasetChartDefinition) chartDefinition; pies.setDataset(categoryDatasetChartDefintion); } if (plot instanceof MeterPlot) { MeterPlot meter = (MeterPlot) plot; DialWidgetDefinition widget = (DialWidgetDefinition) chartDefinition; List intervals = widget.getIntervals(); Iterator intervalIterator = intervals.iterator(); while (intervalIterator.hasNext()) { MeterInterval interval = (MeterInterval) intervalIterator.next(); meter.addInterval(interval); } meter.setNeedlePaint(widget.getNeedlePaint()); meter.setDialShape(widget.getDialShape()); meter.setDialBackgroundPaint(widget.getPlotBackgroundPaint()); meter.setRange(new Range(widget.getMinimum(), widget.getMaximum())); } if (plot instanceof XYPlot) { XYPlot xyPlot = (XYPlot) plot; if (chartDefinition instanceof XYSeriesCollectionChartDefinition) { XYSeriesCollectionChartDefinition xySeriesCollectionChartDefintion = (XYSeriesCollectionChartDefinition) chartDefinition; xyPlot.setOrientation(xySeriesCollectionChartDefintion.getOrientation()); ValueAxis domainAxis = xyPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(xySeriesCollectionChartDefintion.getDomainTitle()); domainAxis.setLabelFont(xySeriesCollectionChartDefintion.getDomainTitleFont()); domainAxis.setVerticalTickLabels(xySeriesCollectionChartDefintion.isDomainVerticalTickLabels()); if (xySeriesCollectionChartDefintion.getDomainTickFormat() != null) { ((NumberAxis) domainAxis) .setNumberFormatOverride(xySeriesCollectionChartDefintion.getDomainTickFormat()); } if (xySeriesCollectionChartDefintion.getDomainTickFont() != null) { domainAxis.setTickLabelFont(xySeriesCollectionChartDefintion.getDomainTickFont()); } if (xySeriesCollectionChartDefintion.getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { domainAxis.setLowerBound(xySeriesCollectionChartDefintion.getDomainMinimum()); } if (xySeriesCollectionChartDefintion.getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { domainAxis.setUpperBound(xySeriesCollectionChartDefintion.getDomainMaximum()); } } ValueAxis rangeAxis = xyPlot.getRangeAxis(); if (rangeAxis != null) { rangeAxis.setLabel(xySeriesCollectionChartDefintion.getRangeTitle()); rangeAxis.setLabelFont(xySeriesCollectionChartDefintion.getRangeTitleFont()); if (xySeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(xySeriesCollectionChartDefintion.getRangeMinimum()); } if (xySeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(xySeriesCollectionChartDefintion.getRangeMaximum()); } if (xySeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(xySeriesCollectionChartDefintion.getRangeMinimum()); } if (xySeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(xySeriesCollectionChartDefintion.getRangeMaximum()); } if (xySeriesCollectionChartDefintion.getRangeTickFormat() != null) { ((NumberAxis) rangeAxis) .setNumberFormatOverride(xySeriesCollectionChartDefintion.getRangeTickFormat()); } if (xySeriesCollectionChartDefintion.getRangeTickFont() != null) { rangeAxis.setTickLabelFont(xySeriesCollectionChartDefintion.getRangeTickFont()); } } } else if (chartDefinition instanceof TimeSeriesCollectionChartDefinition) { TimeSeriesCollectionChartDefinition timeSeriesCollectionChartDefintion = (TimeSeriesCollectionChartDefinition) chartDefinition; xyPlot.setOrientation(timeSeriesCollectionChartDefintion.getOrientation()); ValueAxis domainAxis = xyPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(timeSeriesCollectionChartDefintion.getDomainTitle()); domainAxis.setLabelFont(timeSeriesCollectionChartDefintion.getDomainTitleFont()); domainAxis .setVerticalTickLabels(timeSeriesCollectionChartDefintion.isDomainVerticalTickLabels()); if (domainAxis instanceof DateAxis) { DateAxis da = (DateAxis) domainAxis; if (timeSeriesCollectionChartDefintion.getDateMinimum() != null) { da.setMinimumDate(timeSeriesCollectionChartDefintion.getDateMinimum()); } if (timeSeriesCollectionChartDefintion.getDateMaximum() != null) { da.setMaximumDate(timeSeriesCollectionChartDefintion.getDateMaximum()); } } } ValueAxis rangeAxis = xyPlot.getRangeAxis(); if (rangeAxis != null) { rangeAxis.setLabel(timeSeriesCollectionChartDefintion.getRangeTitle()); rangeAxis.setLabelFont(timeSeriesCollectionChartDefintion.getRangeTitleFont()); if (timeSeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(timeSeriesCollectionChartDefintion.getRangeMinimum()); } if (timeSeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(timeSeriesCollectionChartDefintion.getRangeMaximum()); } } } else if (chartDefinition instanceof XYZSeriesCollectionChartDefinition) { XYZSeriesCollectionChartDefinition xyzSeriesCollectionChartDefintion = (XYZSeriesCollectionChartDefinition) chartDefinition; xyPlot.setOrientation(xyzSeriesCollectionChartDefintion.getOrientation()); ValueAxis domainAxis = xyPlot.getDomainAxis(); if (domainAxis != null) { domainAxis.setLabel(xyzSeriesCollectionChartDefintion.getDomainTitle()); domainAxis.setLabelFont(xyzSeriesCollectionChartDefintion.getDomainTitleFont()); domainAxis .setVerticalTickLabels(xyzSeriesCollectionChartDefintion.isDomainVerticalTickLabels()); if (xyzSeriesCollectionChartDefintion.getDomainMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { domainAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getDomainMinimum()); } if (xyzSeriesCollectionChartDefintion.getDomainMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { domainAxis.setUpperBound(xyzSeriesCollectionChartDefintion.getDomainMaximum()); } if (xyzSeriesCollectionChartDefintion.getDomainTickFormat() != null) { ((NumberAxis) domainAxis) .setNumberFormatOverride(xyzSeriesCollectionChartDefintion.getDomainTickFormat()); } if (xyzSeriesCollectionChartDefintion.getDomainTickFont() != null) { domainAxis.setTickLabelFont(xyzSeriesCollectionChartDefintion.getDomainTickFont()); } } ValueAxis rangeAxis = xyPlot.getRangeAxis(); if (rangeAxis != null) { rangeAxis.setLabel(xyzSeriesCollectionChartDefintion.getRangeTitle()); rangeAxis.setLabelFont(xyzSeriesCollectionChartDefintion.getRangeTitleFont()); rangeAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getRangeMinimum()); if (xyzSeriesCollectionChartDefintion.getRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) { rangeAxis.setLowerBound(xyzSeriesCollectionChartDefintion.getRangeMinimum()); } if (xyzSeriesCollectionChartDefintion.getRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) { rangeAxis.setUpperBound(xyzSeriesCollectionChartDefintion.getRangeMaximum()); } if (xyzSeriesCollectionChartDefintion.getRangeTickFormat() != null) { ((NumberAxis) rangeAxis) .setNumberFormatOverride(xyzSeriesCollectionChartDefintion.getRangeTickFormat()); } if (xyzSeriesCollectionChartDefintion.getRangeTickFont() != null) { rangeAxis.setTickLabelFont(xyzSeriesCollectionChartDefintion.getRangeTickFont()); } } } } }
From source file:com.sun.japex.ChartGenerator.java
static private void configureLineChart(JFreeChart chart) { CategoryPlot plot = chart.getCategoryPlot(); final DrawingSupplier supplier = new DefaultDrawingSupplier(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, // Draw a small diamond new Shape[] { new Polygon(new int[] { 3, 0, -3, 0 }, new int[] { 0, 3, 0, -3 }, 4) }); plot.setDomainGridlinePaint(Color.black); plot.setRangeGridlinePaint(Color.black); plot.setDrawingSupplier(supplier);/* ww w .ja v a 2s. c o m*/ LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setStroke(new BasicStroke(2.0f)); }
From source file:org.fhcrc.cpl.viewer.gui.MRMDialog.java
protected DrawingSupplier getDrawingSupplierForPlot(MRMTransition plot) { Paint colorseq[];//from w ww. j a v a2 s .c om if (plot != null) { int nColors = 0; nColors += plot.getDaughters().size(); colorseq = new Paint[nColors]; int i = 0; for (MRMDaughter d : plot.getDaughters().values()) { if (d == plot.getCurrentDaughter()) { colorseq[i] = Utils.paleColor((Color) plot.getCurrentDaughter().getGraphColor()); } else { colorseq[i] = Color.LIGHT_GRAY; } i++; } } else { colorseq = new Paint[1]; colorseq[0] = Color.WHITE; } return new DefaultDrawingSupplier(colorseq, DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected void setPlotDrawingDefaults(Plot p, JRChartPlot jrPlot) { PlotSettings plotSettings = getPlotSettings(); Paint[] paintSequence = getPaintSequence(plotSettings, jrPlot); Paint[] outlinePaintSequence = getOutlinePaintSequence(plotSettings); Stroke[] strokeSequence = getStrokeSequence(plotSettings); Stroke[] outlineStrokeSequence = getOutlineStrokeSequence(plotSettings); // Shape[] defaultPlotShapeSequence = // getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_SHAPE_SEQUENCE) != null ? // (Shape[])getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_SHAPE_SEQUENCE) : // DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE; p.setDrawingSupplier(new DefaultDrawingSupplier(paintSequence, outlinePaintSequence, strokeSequence, outlineStrokeSequence, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected void setPlotDrawingDefaults(Plot p, JRChartPlot jrPlot) { List defaultSeriesColors = (List) 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;// ww w .j av a 2s . c o m SortedSet 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)); }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
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;//from ww w .j av a 2 s.com 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)); }