List of usage examples for org.jfree.chart.plot XYPlot setDataset
public void setDataset(XYDataset dataset)
From source file:ec.ui.view.ARPView.java
protected void onARPDataChange() { XYPlot plot = getPlot(); reset();/*from w w w. j a va2 s .c om*/ if (data == null || data.values == null) return; XYSeries series = computeSeries(); plot.setDataset(new XYSeriesCollection(series)); chartPanel.getChart().getTitle().setText(data.name); if (data.freq > 0) { int freq2 = data.freq / 2; for (int i = 1; i <= freq2; ++i) { double f = i * TWO_PI / data.freq; addFreqMarker(f, KnownColor.BLUE); } double[] tdfreq = Periodogram.getTradingDaysFrequencies(data.freq); if (tdfreq != null) { for (int i = 0; i < tdfreq.length; ++i) { addFreqMarker(tdfreq[i], KnownColor.RED); } } configureChart(series); } }
From source file:edu.pdi2.visual.ThresholdSignature.java
private void plot() { if (signature != null) { XYSeries signature1 = new XYSeries("Original"); XYSeries signature2 = new XYSeries("Max"); XYSeries signature3 = new XYSeries("Min"); double aux = 0; for (int i = 0; i < signature.length; i++) { signature1.add(i + 1, signature[i]); }// w w w. ja v a 2 s .c o m for (int i = 0; i < signature.length; i++) { aux = signature[i] + banda[i]; if (aux > 255) aux = 255; signature2.add(i + 1, aux); } for (int i = 0; i < signature.length; i++) { aux = signature[i] - banda[i]; if (aux < 0) aux = 0; signature3.add(i + 1, aux); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(signature1); dataset.addSeries(signature2); dataset.addSeries(signature3); XYPlot plot = (XYPlot) signatureG.getPlot(); plot.setDataset(dataset); } }
From source file:com.android.ddmuilib.log.event.DisplaySyncHistogram.java
/** * Resets the display.// ww w . j a v a2 s . c o m */ @Override void resetUI() { super.resetUI(); XYPlot xyPlot = mChart.getXYPlot(); AbstractXYItemRenderer br = new XYBarRenderer(); mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS + 1]; @SuppressWarnings("unchecked") Map<SimpleTimePeriod, Integer> mTimePeriodMapTmp[] = new HashMap[NUM_AUTHS + 1]; mTimePeriodMap = mTimePeriodMapTmp; TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection(); xyPlot.setDataset(tpvc); xyPlot.setRenderer(br); for (int i = 0; i < NUM_AUTHS + 1; i++) { br.setSeriesPaint(i, AUTH_COLORS[i]); mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]); tpvc.addSeries(mDatasetsSyncHist[i]); mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>(); } }
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 www .j ava 2 s .co 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>()); }// ww w .ja va 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(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 va2 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 best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "PickedMoveTypeBestScoreDiffStatisticLevel" + scoreLevelIndex)); } }
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>()); }// w ww. ja va 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(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:org.optaplanner.benchmark.impl.statistic.single.constraintmatchtotalstepscore.ConstraintMatchTotalStepScoreSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }//from w w w . ja v a 2 s . co m while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName() + " constraint match total step score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:org.optaplanner.benchmark.impl.statistic.subsingle.constraintmatchtotalstepscore.ConstraintMatchTotalStepScoreSubSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }// w ww . j a va 2 s .co m while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName() + " constraint match total step score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:com.android.ddmuilib.log.event.DisplaySyncPerf.java
/** * Resets the display./* w w w . j a va 2s .c o m*/ */ @Override void resetUI() { super.resetUI(); XYPlot xyPlot = mChart.getXYPlot(); xyPlot.getRangeAxis().setVisible(false); mTooltipGenerator = new CustomXYToolTipGenerator(); @SuppressWarnings("unchecked") List<String>[] mTooltipsTmp = new List[NUM_SERIES]; mTooltips = mTooltipsTmp; XYBarRenderer br = new XYBarRenderer(); br.setUseYInterval(true); mDatasets = new TimePeriodValues[NUM_SERIES]; TimePeriodValuesCollection tpvc = new YIntervalTimePeriodValuesCollection(1); xyPlot.setDataset(tpvc); xyPlot.setRenderer(br); for (int i = 0; i < NUM_SERIES; i++) { br.setSeriesPaint(i, SERIES_COLORS[i]); mDatasets[i] = new TimePeriodValues(SERIES_NAMES[i]); tpvc.addSeries(mDatasets[i]); mTooltips[i] = new ArrayList<String>(); mTooltipGenerator.addToolTipSeries(mTooltips[i]); br.setSeriesToolTipGenerator(i, mTooltipGenerator); } }