List of usage examples for org.jfree.chart.plot DefaultDrawingSupplier getNextPaint
@Override
public Paint getNextPaint()
From source file:net.sourceforge.processdash.ui.web.reports.AreaChart.java
private void configureConsistentColors(CategoryPlot plot, CategoryDataset catData) { DefaultDrawingSupplier s = new DefaultDrawingSupplier(); String skip = getParameter("consistentSkip"); if (skip != null) for (int i = Integer.parseInt(skip); i-- > 0;) s.getNextPaint(); CategoryItemRenderer rend = plot.getRenderer(); for (int i = 0; i < catData.getRowCount(); i++) { Paint paint = s.getNextPaint(); rend.setSeriesPaint(i, paint);//from w w w . j a va 2 s .c o m } }
From source file:net.sourceforge.processdash.ui.web.reports.PieChart.java
private void configureConsistentColors(final PiePlot plot, PieDataset pieData) { DefaultDrawingSupplier s = new DefaultDrawingSupplier(); String skip = getParameter("consistentSkip"); if (skip != null) for (int i = Integer.parseInt(skip); i-- > 0;) s.getNextPaint(); for (Object key : pieData.getKeys()) { Paint paint = s.getNextPaint(); plot.setSectionPaint((Comparable) key, paint); }/* www . j a va 2s . co m*/ }
From source file:bc.ui.swing.charts.BarChart.java
private JFreeChart generateView() { JFreeChart ret = ChartFactory.createBarChart(model.getTitle(), model.getDomainAxisLabel(), model.getRangeAxisLabel(), ((DefaultCategoryDataset) dataset), PlotOrientation.VERTICAL, true, true, false);/*from w w w . j av a 2s . c o m*/ ret.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) ret.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(new Color(200, 200, 200)); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(new Color(200, 200, 200)); plot.setRangeGridlinesVisible(true); BarRenderer barrenderer = (BarRenderer) plot.getRenderer(); barrenderer.setDrawBarOutline(true); barrenderer.setBarPainter(new StandardBarPainter()); final Color baseColor = new Color(160, 200, 255); final DefaultDrawingSupplier otherColors = new DefaultDrawingSupplier(); plot.setDrawingSupplier(new DefaultDrawingSupplier() { boolean first = true; @Override public Paint getNextPaint() { if (first) { first = false; return baseColor; } return otherColors.getNextPaint(); } }); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setTickMarksVisible(true); return ret; }
From source file:edu.ucla.stat.SOCR.chart.util.MixtureEMExperiment.java
public void init(double x, double y, double sx, double sy) { xSize = x;/*from ww w . ja va 2s . co m*/ ySize = y; xStart = sx; yStart = sy; //System.out.println("MixtureEMExperiment init "+x+" ,"+y+" sx="+sx+" sy="+sy); //getContentPane().setLayout(new BorderLayout()); DB = new Database(xSize, ySize, sx, sy); CGMix = new CurvedGaussMixture(xSize, ySize, DB); GLMix = new GaussLineMixture(xSize, ySize, DB); initResutlsTable(); DefaultDrawingSupplier supplier = new DefaultDrawingSupplier(); color_mainGroup = supplier.getNextPaint(); for (int i = 0; i < 10; i++) { color_kernels[i] = supplier.getNextPaint(); } }
From source file:org.orbeon.oxf.processor.serializer.legacy.JFreeChartSerializer.java
protected ChartConfig createChartConfig(org.orbeon.oxf.pipeline.api.PipelineContext context, org.orbeon.oxf.processor.ProcessorInput input) { ChartConfig chart = new ChartConfig(); Document doc = readInputAsDOM4J(context, input); DefaultDrawingSupplier defaults = new DefaultDrawingSupplier(); String type = XPathUtils.selectStringValueNormalize(doc, "/chart/type"); if (type.equals("vertical-bar")) chart.setType(ChartConfig.VERTICAL_BAR_TYPE); else if (type.equals("horizontal-bar")) chart.setType(ChartConfig.HORIZONTAL_BAR_TYPE); else if (type.equals("line")) chart.setType(ChartConfig.LINE_TYPE); else if (type.equals("area")) chart.setType(ChartConfig.AREA_TYPE); else if (type.equals("stacked-vertical-bar")) chart.setType(ChartConfig.STACKED_VERTICAL_BAR_TYPE); else if (type.equals("stacked-horizontal-bar")) chart.setType(ChartConfig.STACKED_HORIZONTAL_BAR_TYPE); else if (type.equals("stacked-vertical-bar-3d")) chart.setType(ChartConfig.STACKED_VERTICAL_BAR3D_TYPE); else if (type.equals("stacked-horizontal-bar-3d")) chart.setType(ChartConfig.STACKED_HORIZONTAL_BAR3D_TYPE); else if (type.equals("vertical-bar-3d")) chart.setType(ChartConfig.VERTICAL_BAR3D_TYPE); else if (type.equals("horizontal-bar-3d")) chart.setType(ChartConfig.HORIZONTAL_BAR3D_TYPE); else if (type.equals("pie")) chart.setType(ChartConfig.PIE_TYPE); else if (type.equals("pie-3d")) chart.setType(ChartConfig.PIE3D_TYPE); else if (type.equals("xy-line")) chart.setType(ChartConfig.XY_LINE_TYPE); else if (type.equals("time-series")) chart.setType(ChartConfig.TIME_SERIES_TYPE); else/*from ww w .j a v a 2 s . c o m*/ throw new OXFException("Chart type " + type + " is not supported"); String title = XPathUtils.selectStringValueNormalize(doc, "/chart/title"); chart.setTitle(title == null ? "" : title); chart.setMap(XPathUtils.selectStringValueNormalize(doc, "/chart/map")); chart.setCategoryTitle(XPathUtils.selectStringValueNormalize(doc, "/chart/category-title")); String catMargin = XPathUtils.selectStringValueNormalize(doc, "/chart/category-margin"); if (catMargin != null) chart.setCategoryMargin(Double.parseDouble(catMargin)); chart.setSerieTitle(XPathUtils.selectStringValueNormalize(doc, "/chart/serie-title")); chart.setSerieAutoRangeIncludeZero(XPathUtils .selectBooleanValue(doc, "not(/chart/serie-auto-range-include-zero = 'false')").booleanValue()); chart.setxSize(XPathUtils.selectIntegerValue(doc, "/chart/x-size").intValue()); chart.setySize(XPathUtils.selectIntegerValue(doc, "/chart/y-size").intValue()); String bgColor = XPathUtils.selectStringValueNormalize(doc, "/chart/background-color"); String tColor = XPathUtils.selectStringValueNormalize(doc, "/chart/title-color"); Integer maxNumOfTickUnit = XPathUtils.selectIntegerValue(doc, "/chart/max-number-of-labels"); String sDateFormat = XPathUtils.selectStringValueNormalize(doc, "/chart/date-format"); String categoryLabelAngle = XPathUtils.selectStringValueNormalize(doc, "/chart/category-label-angle"); chart.setBackgroundColor(bgColor == null ? DEFAULT_BACKGROUND_COLOR : getRGBColor(bgColor)); chart.setTitleColor(tColor == null ? DEFAULT_TITLE_COLOR : getRGBColor(tColor)); if (maxNumOfTickUnit != null) chart.setMaxNumOfLabels(maxNumOfTickUnit.intValue()); if (sDateFormat != null) chart.setDateFormat(sDateFormat); if (categoryLabelAngle != null) { double angle = Double.parseDouble(categoryLabelAngle); chart.setCategoryLabelPosition( CategoryLabelPositions.createUpRotationLabelPositions(angle * (Math.PI / 180))); chart.setCategoryLabelAngle(angle); } String margin = XPathUtils.selectStringValueNormalize(doc, "/chart/bar-margin"); if (margin != null) chart.setBarMargin(Double.parseDouble(margin)); // legend CustomLegend legend = new CustomLegend(null); Boolean legendVis = XPathUtils.selectBooleanValue(doc, "/chart/legend/@visible = 'true'"); legend.setVisible(legendVis.booleanValue()); if (legend.isVisible()) { String pos = XPathUtils.selectStringValueNormalize(doc, "/chart/legend/@position"); if ("north".equals(pos)) { legend.setPosition(RectangleEdge.TOP); } else if ("east".equals(pos)) { legend.setPosition(RectangleEdge.RIGHT); } else if ("south".equals(pos)) { legend.setPosition(RectangleEdge.BOTTOM); } else if ("west".equals(pos)) { legend.setPosition(RectangleEdge.LEFT); } for (Iterator i = XPathUtils.selectIterator(doc, "/chart/legend/item"); i.hasNext();) { Element el = (Element) i.next(); Color color = getRGBColor(el.attributeValue("color")); String label = el.attributeValue("label"); legend.addItem(label, color); } } chart.setLegendConfig(legend); for (Iterator i = XPathUtils.selectIterator(doc, "/chart/*[name()='value']"); i.hasNext();) { Element el = (Element) i.next(); String c = el.attributeValue("color"); Paint color; if (c != null) color = getRGBColor(c); else color = defaults.getNextPaint(); chart.addValue(el.attributeValue("title"), el.attributeValue("categories"), el.attributeValue("series"), el.attributeValue("colors"), el.attributeValue("exploded-percents"), color); } return chart; }