List of usage examples for org.jfree.chart.plot DefaultDrawingSupplier DefaultDrawingSupplier
public DefaultDrawingSupplier()
From source file:org.tsho.dmc2.core.chart.TrajectoryMultiRenderer.java
public TrajectoryMultiRenderer(final DmcRenderablePlot plot, final Stepper[] list, TrajectoryComponent component) { super(plot, null, component); this.plot = plot; this.stepperList = list; computeRanges = true;//from w w w .j a v a 2 s . c o m prevX = new int[list.length]; prevY = new int[list.length]; paintList = new Paint[list.length]; DrawingSupplier mySupplier = new DefaultDrawingSupplier(); for (int i = 0; i < list.length; i++) { paintList[i] = mySupplier.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();//ww w . j a v a 2 s . c o m CategoryItemRenderer rend = plot.getRenderer(); for (int i = 0; i < catData.getRowCount(); i++) { Paint paint = s.getNextPaint(); rend.setSeriesPaint(i, paint); } }
From source file:org.optaplanner.benchmark.impl.statistic.movecountperstep.MoveCountPerStepProblemStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Accepted/selected moves per step"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); DrawingSupplier drawingSupplier = new DefaultDrawingSupplier(); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { XYSeries acceptedSeries = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " accepted"); XYSeries selectedSeries = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " selected"); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); if (singleBenchmarkResult.isSuccess()) { MoveCountPerStepSingleStatistic singleStatistic = (MoveCountPerStepSingleStatistic) singleBenchmarkResult .getSingleStatistic(problemStatisticType); for (MoveCountPerStepStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); long acceptedMoveCount = point.getMoveCountPerStepMeasurement().getAcceptedMoveCount(); long selectedMoveCount = point.getMoveCountPerStepMeasurement().getSelectedMoveCount(); acceptedSeries.add(timeMillisSpent, acceptedMoveCount); selectedSeries.add(timeMillisSpent, selectedMoveCount); }//from w w w.ja v a 2s .c o m } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(acceptedSeries); seriesCollection.addSeries(selectedSeries); plot.setDataset(seriesIndex, seriesCollection); if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); // Dashed line for selected move count renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); } else { // Dashed line for selected move count renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); } // Render both lines in the same color Paint linePaint = drawingSupplier.getNextPaint(); renderer.setSeriesPaint(0, linePaint); renderer.setSeriesPaint(1, linePaint); plot.setRenderer(seriesIndex, renderer); seriesIndex++; } JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " move count per step statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "MoveCountPerStepStatistic"); }
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 . ja v a 2 s .c om*/ 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: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();//w ww . jav a2 s . c o m for (Object key : pieData.getKeys()) { Paint paint = s.getNextPaint(); plot.setSectionPaint((Comparable) key, paint); } }
From source file:org.ietr.preesm.mapper.ui.GanttPlotter.java
/** * Creates a chart.//from ww w . j av a 2 s. c o m * * @param dataset * a dataset. * * @return A chart. */ private JFreeChart createChart(IntervalCategoryDataset dataset) { JFreeChart chart = ChartFactory.createGanttChart("Solution Gantt", // title "Operators", // x-axis label "Time", // y-axis label null, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); Paint p = getBackgroundColorGradient(); chart.setBackgroundPaint(p); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setOrientation(PlotOrientation.HORIZONTAL); DateAxis xaxis = (DateAxis) plot.getRangeAxis(); xaxis.setDateFormatOverride(new VertexDateFormat()); xaxis.setPositiveArrowVisible(true); DefaultDrawingSupplier d = new DefaultDrawingSupplier(); plot.setDrawingSupplier(d); MyGanttRenderer ren = new MyGanttRenderer(); // ren.setRepaintedListener(new RefreshRepaintedListener(this)); ren.setSeriesItemLabelsVisible(0, false); ren.setSeriesVisibleInLegend(0, false); ren.setSeriesItemLabelGenerator(0, new IntervalCategoryItemLabelGenerator()); ren.setSeriesToolTipGenerator(0, new MapperGanttToolTipGenerator()); ren.setAutoPopulateSeriesShape(false); plot.setRenderer(ren); plot.setDataset(dataset); return chart; }
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. j av a2s.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 w ww . ja v a 2 s.co 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; }