List of usage examples for org.jfree.data.xy CategoryTableXYDataset CategoryTableXYDataset
public CategoryTableXYDataset()
From source file:org.jfree.data.xy.junit.CategoryTableXYDatasetTest.java
/** * This is a test for bug 1312066 - adding a new series should trigger a * recalculation of the interval width, if it is being automatically * calculated.//from w w w . j a v a 2 s . c o m */ public void testAddSeries() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.setAutoWidth(true); d1.add(3.0, 1.1, "Series 1"); d1.add(7.0, 2.2, "Series 1"); assertEquals(3.0, d1.getXValue(0, 0), EPSILON); assertEquals(7.0, d1.getXValue(0, 1), EPSILON); assertEquals(1.0, d1.getStartXValue(0, 0), EPSILON); assertEquals(5.0, d1.getStartXValue(0, 1), EPSILON); assertEquals(5.0, d1.getEndXValue(0, 0), EPSILON); assertEquals(9.0, d1.getEndXValue(0, 1), EPSILON); // now add some more data d1.add(7.5, 1.1, "Series 2"); d1.add(9.0, 2.2, "Series 2"); assertEquals(3.0, d1.getXValue(1, 0), EPSILON); assertEquals(7.0, d1.getXValue(1, 1), EPSILON); assertEquals(7.5, d1.getXValue(1, 2), EPSILON); assertEquals(9.0, d1.getXValue(1, 3), EPSILON); assertEquals(7.25, d1.getStartXValue(1, 2), EPSILON); assertEquals(8.75, d1.getStartXValue(1, 3), EPSILON); assertEquals(7.75, d1.getEndXValue(1, 2), EPSILON); assertEquals(9.25, d1.getEndXValue(1, 3), EPSILON); // and check the first series too... assertEquals(2.75, d1.getStartXValue(0, 0), EPSILON); assertEquals(6.75, d1.getStartXValue(0, 1), EPSILON); assertEquals(3.25, d1.getEndXValue(0, 0), EPSILON); assertEquals(7.25, d1.getEndXValue(0, 1), EPSILON); }
From source file:cachedataanalysis.FlowCache.java
public XYSeries exportReportChart() throws IOException { File outputHitRate = new File("report/" + name + "_" + policy + "_hitrate.txt"); FileWriter fw = new FileWriter(outputHitRate); XYSeries hitRateCount = new XYSeries(name + "(" + size + " entries)"); for (int i = 0; i < hitRateRecord.size(); i++) { hitRateCount.add(i, hitRateRecord.get(i)); fw.write(i + "," + hitRateRecord.get(i) + "\n"); fw.flush();/*from w w w.jav a 2 s .co m*/ } fw.close(); XYSeriesCollection HitRateData = new XYSeriesCollection(); HitRateData.addSeries(hitRateCount); JFreeChart hitRateStat = ChartFactory.createXYLineChart( "Hit Rate variatoion throughout recording in " + name, "Seconds", "HitRate", HitRateData, PlotOrientation.VERTICAL, true, true, false); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitRate" + size + ".jpg"), hitRateStat, 1500, 900); //------------------------------- if (!fullReport) { return hitRateCount; } DefaultPieDataset hitProtoData = new DefaultPieDataset(); DefaultPieDataset missProtoData = new DefaultPieDataset(); CategoryTableXYDataset hitProtoDataRec = new CategoryTableXYDataset(); for (int i = 0; i < hitProtoRec.size(); i++) { if (i % 120 != 0) { continue; } HashMap<String, Integer> _map = hitProtoRec.get(i); for (String _str : _map.keySet()) { hitProtoDataRec.add(i, _map.get(_str), _str); } } CategoryTableXYDataset missProtoDataRec = new CategoryTableXYDataset(); for (int i = 0; i < missProtoRec.size(); i++) { if (i % 120 != 0) { continue; } HashMap<String, Integer> _map = missProtoRec.get(i); for (String _str : _map.keySet()) { missProtoDataRec.add(i, _map.get(_str), _str); } } XYSeries hitCountData = new XYSeries("Hit"); XYSeries allCountData = new XYSeries("All"); for (int i = 0; i < hitCount.size(); i++) { hitCountData.add(i, hitCount.get(i)); //hitRateCount.add(i,(float)hitCount.get(i)/(hitCount.get(i)+allCount.get(i))); } for (int i = 0; i < allCount.size(); i++) { allCountData.add(i, allCount.get(i)); } XYSeriesCollection CountStatData = new XYSeriesCollection(); CountStatData.addSeries(hitCountData); CountStatData.addSeries(allCountData); for (String protocol : hitProto.keySet()) { hitProtoData.setValue(protocol, hitProto.get(protocol)); } for (String protocol : missProto.keySet()) { missProtoData.setValue(protocol, missProto.get(protocol)); } JFreeChart hitStatRec = ChartFactory.createStackedXYAreaChart( "Hit Protocol Fraction throughout record in " + name, "Seconds", "Count", hitProtoDataRec); JFreeChart missStatRec = ChartFactory.createStackedXYAreaChart( "Miss Protocol Fraction throughout record in " + name, "Seconds", "Count", missProtoDataRec); JFreeChart hitStat = ChartFactory.createPieChart3D("Protocal Fraction of Hit Flows in " + name, hitProtoData, true, true, false); JFreeChart missStat = ChartFactory.createPieChart3D("Protocal Fraction of Miss Flows in " + name, missProtoData, true, true, false); JFreeChart countStat = ChartFactory.createXYAreaChart("Hit Count to All Packet lookup in " + name, "Seconds", "Count", CountStatData, PlotOrientation.VERTICAL, true, true, false); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProto" + size + ".jpg"), hitStat, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProto" + size + ".jpg"), missStat, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitCount" + size + ".jpg"), countStat, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProtoRecord" + size + ".jpg"), hitStatRec, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProtoRecord" + size + ".jpg"), missStatRec, 1500, 900); return hitRateCount; }
From source file:org.ash.gui.StackedChart.java
/** * Creates the dataset.//from w w w. j a va 2s . com * * @throws DatabaseException the database exception */ private void createDataset() throws DatabaseException { dataset = new CategoryTableXYDataset(); this.database.loadDataToChartPanelDataSet(dataset); }
From source file:org.ash.history.TopActivityPreview.java
/** * Creates the dataset./* w ww. j ava2 s .c o m*/ * * @throws DatabaseException the database exception */ private void createDataset() throws DatabaseException { dataset = new CategoryTableXYDataset(); this.database.loadDataToChartPanelDataSetPreview(dataset); }
From source file:org.ash.history.TopActivityPreview.java
/** * Creates the dataset for Top Activity. * /*from w w w .j ava 2 s . c o m*/ * @param begin * @param end * @throws DatabaseException */ private void createDatasetTopActivity(double begin, double end) throws DatabaseException { dataset = new CategoryTableXYDataset(); this.database.loadDataToChartPanelDataSetTA(dataset, begin, end); }
From source file:CGgui.java
public void clearData() { //global variables reset MIN = Double.MAX_VALUE;//ww w .j a v a2 s . c om MAX = 0; BINS = 10000; key = ""; regLine = null; //clear min settings minText.setText(""); maxText.setText(""); smoothText.setText(""); fragmentMap.clear(); //new data sets lengthHist = null; histogramdataset = new XYSeriesCollection(); minimadataset = new CategoryTableXYDataset(); clusterdataset = new CategoryTableXYDataset(); //chart area reset XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setDataset(new XYSeriesCollection()); chartpanel.restoreAutoBounds(); XYPlot minxyplot = (XYPlot) minchart.getPlot(); minxyplot.setDataset(0, minimadataset); minxyplot.setDataset(1, new DefaultXYDataset()); minchart.clearSubtitles(); minchartpanel.restoreAutoBounds(); XYPlot clusterxyplot = (XYPlot) clusterchart.getPlot(); clusterxyplot.setDataset(clusterdataset); clusterchartpanel.restoreAutoBounds(); //remove marker if (intervalmarker != null) { xyplot = (XYPlot) chart.getPlot(); xyplot.removeDomainMarker(intervalmarker, Layer.BACKGROUND); intervalmarker = null; } //remove crosshair xyplot.setDomainCrosshairVisible(false); //clear text minText.setText(null); maxText.setText(null); smoothText.setText(null); //f.pack(); //System.gc(); }
From source file:ru.spbspu.viewer.DataView.java
/** * ? ? /* w w w. jav a2 s. c om*/ */ public void buildOscillogram() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization(); double startPosition = step * getFramePosition(); double[] data = null; if (LPF.isSelected()) { data = _presenter.lpFilter(_presenter.getFrameData(getFramePosition(), getFrameWidth()), Double.parseDouble(spinnerLimitFreq.getValue().toString())); } else { data = _presenter.getFrameData(getFramePosition(), getFrameWidth()); } for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); plot.setFixedRangeAxisSpace(GRAPHIC_SPACE); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); Range range = _presenter.getMinMaxRange(); if (range.getLength() > 0) { yAxis.setRange(range); } org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = getFramePosition() * 1.0 / getDiscretization(); double max = start + getFrameWidth() * 1.0 / getDiscretization(); xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfSignal(chartPanel); }
From source file:ru.spbspu.viewer.DataView.java
/** * ? ? /* w w w . java 2s . c om*/ */ public void buildEnergyGraph() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization(); double startPosition = step * getFramePosition(); double[] data = _presenter.getFrameEnergy(getFramePosition(), getFrameWidth(), getWindowWidth()); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step * getFrameWidth() / (data.length - 1); } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); String selection = scaling.getSelection().getActionCommand(); switch (selection) { case "max": { yAxis.setRange(_presenter.getMinMaxRangeEnergy()); } break; case "mean": { yAxis.setRange(_presenter.getMeanRangeEnergy()); } break; case "auto": break; } plot.setFixedRangeAxisSpace(GRAPHIC_SPACE); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = getFramePosition() * 1.0 / getDiscretization(); double max = start + getFrameWidth() * 1.0 / getDiscretization(); xAxis.setRange(start, max); // yAxis.setRange(3.99, 4.01); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfEnergy(chartPanel); }
From source file:ru.spbspu.viewer.DataView.java
/** * ? //from w w w . j a v a 2s. co m */ public void buildFourierTransformGraph() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double[] data = _presenter.getFourierTransform(getFramePosition(), getFrameWidth(), getWindowWidth()); JFreeChart chart = null; String select = v.getSelection().getActionCommand(); if (select.equalsIgnoreCase(vAcceleration.getActionCommand())) { for (int i = 0; i < data.length; i++) { serie.add(1.0 * i / getFrameWidth() * getDiscretization(), 2.0 * data[i], ""); } chart = ChartFactory.createXYLineChart("", "", "g, /?^2", serie); } else if (select.equalsIgnoreCase(vDisplacement.getActionCommand())) { for (int i = 0; i < data.length; i++) { double freq = 1.0 * i / getFrameWidth() * getDiscretization(); if (freq < 1.0) { continue; } double value = 2.0 * data[i] * Math.pow(10, 6) / Math.pow(freq, 2); serie.add(freq, value, ""); } chart = ChartFactory.createXYLineChart("", "", "?, ", serie); } else return; chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); // org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); // // org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); // yAxis.setRange(3.99, 4.01); ChartPanel chartPanel = new ChartPanel(chart); drawGraphOfEnergy(chartPanel); }
From source file:ru.spbspu.viewer.DataView.java
/** * ? ? ? ?//from ww w.j a va 2s. co m */ public void buildFullEnergyGraph() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false); double step = 1.0 / getDiscretization() * Integer.parseInt(spinnerWindowWidth.getValue().toString()) / 2; double startPosition = 0; double[] data = _presenter.getFullFrameEnergy(getWindowWidth()); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "", "t,c", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); AxisSpace space = new AxisSpace(); space.setLeft(GRAPHIC_SPACE.getLeft() - 8); plot.setFixedRangeAxisSpace(space); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); String selection = scaling.getSelection().getActionCommand(); switch (selection) { case "max": { yAxis.setRange(_presenter.getMinMaxRangeEnergy()); } break; case "mean": { yAxis.setRange(_presenter.getMeanRangeEnergy()); } break; case "auto": break; } org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = 0; double max = _presenter.getFullData().length / Double.valueOf(spinnerDiscretization.getValue().toString()); xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); drawFullGraphOfEnergy(chartPanel); }