List of usage examples for org.jfree.chart.plot XYPlot setRenderer
public void setRenderer(XYItemRenderer renderer)
From source file:org.optaplanner.benchmark.impl.statistic.single.pickedmovetypestepscore.PickedMoveTypeStepScoreDiffSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYIntervalSeries>> moveTypeToSeriesMapList = new ArrayList<Map<String, XYIntervalSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (PickedMoveTypeStepScoreDiffStatisticPoint point : getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); String moveType = point.getMoveType(); double[] levelValues = ScoreUtils.extractLevelDoubles(point.getStepScoreDiff()); for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= moveTypeToSeriesMapList.size()) { moveTypeToSeriesMapList.add(new LinkedHashMap<String, XYIntervalSeries>()); }/*from w w w . j av a 2 s . c o m*/ Map<String, XYIntervalSeries> moveTypeToSeriesMap = moveTypeToSeriesMapList.get(i); XYIntervalSeries series = moveTypeToSeriesMap.get(moveType); if (series == null) { series = new XYIntervalSeries(moveType); moveTypeToSeriesMap.put(moveType, series); } double yValue = levelValues[i]; // In an XYInterval the yLow must be lower than yHigh series.add(timeMillisSpent, timeMillisSpent, timeMillisSpent, yValue, (yValue > 0.0) ? 0.0 : yValue, (yValue > 0.0) ? yValue : 0.0); } } graphFileList = new ArrayList<File>(moveTypeToSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < moveTypeToSeriesMapList.size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); XYItemRenderer renderer = new YIntervalRenderer(); plot.setRenderer(renderer); XYIntervalSeriesCollection seriesCollection = new XYIntervalSeriesCollection(); for (XYIntervalSeries series : moveTypeToSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName() + " picked move type step score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "PickedMoveTypeStepScoreDiffStatisticLevel" + scoreLevelIndex)); } }
From source file:org.optaplanner.benchmark.impl.statistic.subsingle.pickedmovetypestepscore.PickedMoveTypeStepScoreDiffSubSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYIntervalSeries>> moveTypeToSeriesMapList = new ArrayList<Map<String, XYIntervalSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (PickedMoveTypeStepScoreDiffStatisticPoint point : getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); String moveType = point.getMoveType(); double[] levelValues = ScoreUtils.extractLevelDoubles(point.getStepScoreDiff()); for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= moveTypeToSeriesMapList.size()) { moveTypeToSeriesMapList.add(new LinkedHashMap<String, XYIntervalSeries>()); }/*w w w . j a va2 s . com*/ Map<String, XYIntervalSeries> moveTypeToSeriesMap = moveTypeToSeriesMapList.get(i); XYIntervalSeries series = moveTypeToSeriesMap.get(moveType); if (series == null) { series = new XYIntervalSeries(moveType); moveTypeToSeriesMap.put(moveType, series); } double yValue = levelValues[i]; // In an XYInterval the yLow must be lower than yHigh series.add(timeMillisSpent, timeMillisSpent, timeMillisSpent, yValue, (yValue > 0.0) ? 0.0 : yValue, (yValue > 0.0) ? yValue : 0.0); } } graphFileList = new ArrayList<File>(moveTypeToSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < moveTypeToSeriesMapList.size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); XYItemRenderer renderer = new YIntervalRenderer(); plot.setRenderer(renderer); XYIntervalSeriesCollection seriesCollection = new XYIntervalSeriesCollection(); for (XYIntervalSeries series : moveTypeToSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName() + " picked move type step score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "PickedMoveTypeStepScoreDiffStatisticLevel" + scoreLevelIndex)); } }
From source file:org.optaplanner.benchmark.impl.statistic.single.pickedmovetypebestscore.PickedMoveTypeBestScoreDiffSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYIntervalSeries>> moveTypeToSeriesMapList = new ArrayList<Map<String, XYIntervalSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (PickedMoveTypeBestScoreDiffStatisticPoint point : getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); String moveType = point.getMoveType(); double[] levelValues = ScoreUtils.extractLevelDoubles(point.getBestScoreDiff()); for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= moveTypeToSeriesMapList.size()) { moveTypeToSeriesMapList.add(new LinkedHashMap<String, XYIntervalSeries>()); }/*from w w w .j a v a 2s .c o m*/ Map<String, XYIntervalSeries> moveTypeToSeriesMap = moveTypeToSeriesMapList.get(i); XYIntervalSeries series = moveTypeToSeriesMap.get(moveType); if (series == null) { series = new XYIntervalSeries(moveType); moveTypeToSeriesMap.put(moveType, series); } double yValue = levelValues[i]; // In an XYInterval the yLow must be lower than yHigh series.add(timeMillisSpent, timeMillisSpent, timeMillisSpent, yValue, (yValue > 0.0) ? 0.0 : yValue, (yValue > 0.0) ? yValue : 0.0); } } graphFileList = new ArrayList<File>(moveTypeToSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < moveTypeToSeriesMapList.size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); XYItemRenderer renderer = new YIntervalRenderer(); plot.setRenderer(renderer); XYIntervalSeriesCollection seriesCollection = new XYIntervalSeriesCollection(); for (XYIntervalSeries series : moveTypeToSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName() + " picked move type best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "PickedMoveTypeBestScoreDiffStatisticLevel" + scoreLevelIndex)); } }
From source file:org.interpss.chart.dist.LoadScheduleChart.java
public void createChart() { final JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xLabel, voltYLabel, createDataSet(voltDataAry, voltDataLabel), PlotOrientation.VERTICAL, true, false, false); final XYPlot plot = (XYPlot) chart.getPlot(); final XYStepRenderer renderer = new XYStepRenderer(); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(renderer); //NumberAxis axis_x = (NumberAxis) plot.getDomainAxis(); //axis_x.setRangeAboutValue(12.0, 24.0); final NumberAxis axisLeft = (NumberAxis) plot.getRangeAxis(); axisLeft.setAutoRangeIncludesZero(false); axisLeft.setAutoRangeMinimumSize(1.0); final NumberAxis axisRight = new NumberAxis(pqYLabel); axisRight.setAutoRangeIncludesZero(false); axisRight.setAutoRangeMinimumSize(1.0); plot.setRangeAxis(1, axisRight);//from w w w . j a va 2 s . c om final XYItemRenderer v_renderer = plot.getRenderer(0); v_renderer.setSeriesPaint(0, vColor); plot.setDataset(1, createDataSet(pDataAry, pDataLabel)); plot.mapDatasetToRangeAxis(1, 1); final XYStepRenderer p_renderer = new XYStepRenderer(); p_renderer.setSeriesPaint(0, pColor); p_renderer.setBaseShapesVisible(false); plot.setRenderer(1, p_renderer); plot.setDataset(2, createDataSet(qDataAry, qDataLabel)); plot.mapDatasetToRangeAxis(2, 1); final XYStepRenderer q_renderer = new XYStepRenderer(); q_renderer.setSeriesPaint(0, qColor); q_renderer.setBaseShapesVisible(false); plot.setRenderer(2, q_renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(Chart_Width, Chart_Height)); setContentPane(chartPanel); }
From source file:org.optaplanner.benchmark.impl.statistic.subsingle.pickedmovetypebestscore.PickedMoveTypeBestScoreDiffSubSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYIntervalSeries>> moveTypeToSeriesMapList = new ArrayList<Map<String, XYIntervalSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (PickedMoveTypeBestScoreDiffStatisticPoint point : getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); String moveType = point.getMoveType(); double[] levelValues = ScoreUtils.extractLevelDoubles(point.getBestScoreDiff()); for (int i = 0; i < levelValues.length && i < BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE; i++) { if (i >= moveTypeToSeriesMapList.size()) { moveTypeToSeriesMapList.add(new LinkedHashMap<String, XYIntervalSeries>()); }/*from ww w . ja v a2s . c o m*/ Map<String, XYIntervalSeries> moveTypeToSeriesMap = moveTypeToSeriesMapList.get(i); XYIntervalSeries series = moveTypeToSeriesMap.get(moveType); if (series == null) { series = new XYIntervalSeries(moveType); moveTypeToSeriesMap.put(moveType, series); } double yValue = levelValues[i]; // In an XYInterval the yLow must be lower than yHigh series.add(timeMillisSpent, timeMillisSpent, timeMillisSpent, yValue, (yValue > 0.0) ? 0.0 : yValue, (yValue > 0.0) ? yValue : 0.0); } } graphFileList = new ArrayList<File>(moveTypeToSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < moveTypeToSeriesMapList.size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); XYItemRenderer renderer = new YIntervalRenderer(); plot.setRenderer(renderer); XYIntervalSeriesCollection seriesCollection = new XYIntervalSeriesCollection(); for (XYIntervalSeries series : moveTypeToSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName() + " picked move type best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "PickedMoveTypeBestScoreDiffStatisticLevel" + scoreLevelIndex)); } }
From source file:lisong_mechlab.view.graphs.PayloadGraphPanel.java
public void updateGraph() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); for (Entry entry : chassis) { XYSeries series = new XYSeries(entry.name, false, false); if (entry.representant instanceof ChassisStandard) { ChassisStandard chassisStandard = (ChassisStandard) entry.representant; List<Modifier> stockModifiers = new ArrayList<>(chassisStandard.getQuirks()); stockModifiers.addAll(efficiencies.getModifiers()); for (int rating = chassisStandard.getEngineMin(); rating <= chassisStandard .getEngineMax(); rating += 5) { if (rating < 100) { continue; // TODO: Remove this when they remove the engine limit. }/* w w w. j av a 2 s.c o m*/ double speed = TopSpeed.calculate(rating, chassisStandard.getMovementProfileBase(), chassisStandard.getMassMax(), stockModifiers); series.add(speed, payloadStatistics.calculate(chassisStandard, rating)); } } else { // Omnimech ChassisOmniMech chassisOmniMech = (ChassisOmniMech) entry.representant; Engine engine = chassisOmniMech.getFixedEngine(); List<Modifier> stockModifiers = new ArrayList<>(chassisOmniMech.getStockModifiers()); stockModifiers.addAll(efficiencies.getModifiers()); double minSpeed = TopSpeed.calculate(engine.getRating(), chassisOmniMech.getMovementProfileMin(), chassisOmniMech.getMassMax(), efficiencies.getModifiers()); double stockSpeed = TopSpeed.calculate(engine.getRating(), chassisOmniMech.getMovementProfileBase(), chassisOmniMech.getMassMax(), stockModifiers); double maxSpeed = TopSpeed.calculate(engine.getRating(), chassisOmniMech.getMovementProfileMax(), chassisOmniMech.getMassMax(), efficiencies.getModifiers()); double payload = payloadStatistics.calculate(chassisOmniMech); if (minSpeed != stockSpeed) { series.add(minSpeed, payload); } series.add(stockSpeed, payload); if (maxSpeed != stockSpeed) { series.add(maxSpeed, payload); } } dataset.addSeries(series); } setChart(makeChart(dataset)); XYPlot plot = (XYPlot) getChart().getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); renderer.setBaseShapesFilled(false); plot.setRenderer(renderer); }
From source file:org.interpss.chart.dstab.SimpleOneStateChart.java
/** * create the chart based on the data attributes * //from www .j av a 2 s .co m */ public void createChart() { final JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, xLabel, yLabel, createXYDataSet(xDataAry, yDataAry, yDataLabel), PlotOrientation.VERTICAL, true, false, false); final XYPlot plot = (XYPlot) chart.getPlot(); final StandardXYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); plot.setRenderer(renderer); //NumberAxis axis_x = (NumberAxis) plot.getDomainAxis(); //axis_x.setRangeAboutValue(12.0, 24.0); final NumberAxis axisLeft = (NumberAxis) plot.getRangeAxis(); axisLeft.setAutoRangeIncludesZero(false); axisLeft.setAutoRangeMinimumSize(autoRangeMinimumSize); final XYItemRenderer v_renderer = plot.getRenderer(0); v_renderer.setSeriesPaint(0, yColor); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(Chart_Width, Chart_Height)); setContentPane(chartPanel); }
From source file:playground.yu.utils.charts.XYScatterLineChart.java
private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final XYSeriesCollection dataset) { // return ChartFactory.createScatterPlot(title, categoryAxisLabel, // valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend? // false, // tooltips? // false // URLs? // );//from w ww. ja va 2 s. co m NumberAxis xAxis = new NumberAxis(categoryAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setRange(0, 24); NumberAxis yAxis = new NumberAxis(valueAxisLabel); yAxis.setAutoRangeIncludesZero(true); yAxis.setRange(0, 100); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true); renderer.setBaseToolTipGenerator(null/* XYToolTipGenerator */); renderer.setURLGenerator(null/* urlGenerator */); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true/* legend */); return chart; }
From source file:org.squale.squaleweb.util.graph.HistoMaker.java
/** * This method create the JFreechart chart * /*from w w w.ja v a 2s . c om*/ * @param maxAxisToday Does the max for the date axis should be set to today ? * @return A JFreeChart chart */ public JFreeChart getChart(boolean maxAxisToday) { JFreeChart retChart = super.getChart(); if (null == retChart) { retChart = ChartFactory.createTimeSeriesChart(mTitle, mXLabel, mYLabel, mDataSet, mShowLegend, false, false); XYPlot plot = retChart.getXYPlot(); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); plot.setRenderer(xylineandshaperenderer); SimpleDateFormat sdf = new SimpleDateFormat(mDateFormat); DateAxis axis = (DateAxis) plot.getDomainAxis(); if (maxAxisToday) { axis.setMaximumDate(new Date()); } axis.setDateFormatOverride(sdf); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setAutoRangeMinimumSize(2.0); super.setChart(retChart); } return retChart; }
From source file:edu.wustl.cab2b.client.ui.visualization.charts.ScatterPlot.java
protected JFreeChart createChart(Dataset dataset) { XYDataset xyDataset = (XYDataset) dataset; JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter Plot", "X", "Y", xyDataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.white); XYDotRenderer xydotrenderer = new XYDotRenderer(); xydotrenderer.setDotWidth(4);//from w w w .j a v a2 s . c o m xydotrenderer.setDotHeight(4); xyplot.setRenderer(xydotrenderer); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setAutoRangeIncludesZero(false); return jfreechart; }