List of usage examples for org.jfree.data.xy XYSeriesCollection getSeries
public XYSeries getSeries(Comparable key)
From source file:tdunnick.jphineas.console.queue.Charts.java
private void addLineData(XYSeriesCollection data, long d, int[] values) { for (int i = 0; i < values.length; i++) { data.getSeries(i).add(d, values[i]); values[i] = 0;/*from ww w . ja v a2 s. c o m*/ } }
From source file:umontreal.iro.lecuyer.charts.EmpiricalChart.java
private void fixZeroPoint() { // reset the first point (x0, 0) with x0 at the beginning of x-axis double xmin = Math.min(XAxis.getAxis().getRange().getLowerBound(), XAxis.getTwinAxisPosition()); XYSeriesCollection col = (XYSeriesCollection) dataset.getSeriesCollection(); for (int i = 0; i < col.getSeriesCount(); i++) { XYSeries ser = col.getSeries(i); ser.remove(0); // remove temporary 0-point ser.add(xmin, 0); // replace }/* w w w.java2s . c om*/ }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * /* ww w. j a va 2s. co m*/ * Returns a chart of the evolution of the focus component tdc * * @param tdc * @param label * @param database * @param agent * @param index * @param ged * @return */ public static JFreeChart chartFocusEvolution(tdComponent tdc, String label, tdDataBase database, Agent agent, List<Double> index, GraphEvolutionDescriptor ged) { List<String> focusEnergyColors = null; switch (tdc.getType()) { case INSTANCE: focusEnergyColors = ged.focusInstanceEnergyColors; break; case VI: focusEnergyColors = ged.focusViEnergyColors; break; case CHOICE: focusEnergyColors = null; break; } // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // focus energy values (if needed) if (ged.graphFocusEnergy) { for (String ec : focusEnergyColors) { xysc.addSeries(new XYSeries("FocusEnergy_" + ec)); } } // focus salience values (if needed) if (ged.graphFocusSalience) { for (String ec : focusEnergyColors) { xysc.addSeries(new XYSeries("FocusSalience_" + ec)); } } // // Fill in the values into the xysc // for (Double time : index) { double dtime = time; if (ged.graphFocusEnergy) { for (String ec : focusEnergyColors) { double value = database.getEnergy(tdc.getIdentifier(), ec, time); xysc.getSeries("FocusEnergy_" + ec).add(dtime, value); } } // focus salience values (if needed) if (ged.graphFocusSalience) { for (String ec : focusEnergyColors) { double value = database.getSalience(tdc.getIdentifier(), ec, time); xysc.getSeries("FocusSalience_" + ec).add(dtime, value); } } } JFreeChart chart = ChartFactory.createXYLineChart(label + " - Focus", "Time", "Value", xysc, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesConservative); return chart; }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Returns a chart of the evolution of the memory component tdc * /* ww w . ja va2s. co m*/ * @param tdc * @param label * @param database * @param agent * @param index * @param ged * @return */ public static JFreeChart chartMemoryEvolution(tdComponent tdc, String label, tdDataBase database, Agent agent, List<Double> index, GraphEvolutionDescriptor ged) { List<String> memoryColors = null; if (tdc.getType() == tdComponentType.INSTANCE) { memoryColors = ged.memoryInstanceEnergyColors; } else { memoryColors = ged.memoryViEnergyColors; } // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // memory energy values (if needed) if (ged.graphMemoryEnergy) { for (String ec : memoryColors) { xysc.addSeries(new XYSeries("MemoryEnergy_" + ec)); } } // memory salience values (if needed) if (ged.graphMemorySalience) { for (String ec : memoryColors) { xysc.addSeries(new XYSeries("MemorySalience_" + ec)); } } // // Fill in the values into the xysc // for (Double time : index) { double dtime = time; // memory energy values (if needed) if (ged.graphMemoryEnergy) { for (String ec : memoryColors) { double value = database.getEnergy(tdc.getIdentifier(), ec, time); xysc.getSeries("MemoryEnergy_" + ec).add(dtime, value); } } // memory salience values (if needed) if (ged.graphMemorySalience) { for (String ec : memoryColors) { double value = database.getSalience(tdc.getIdentifier(), ec, time); xysc.getSeries("MemorySalience_" + ec).add(dtime, value); } } } // // the chart with the memory values // JFreeChart chart = ChartFactory.createXYLineChart(label + " - memory", "Time", "Value", xysc, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesConservative); return chart; }
From source file:turtlekit.pvequalsnrt.PhysicsChecker.java
@Override public void setupFrame(JFrame frame) { XYSeriesCollection dataset = new XYSeriesCollection(); final ChartPanel chartPanel = ChartsUtil.createChartPanel(dataset, "PV = nRT", null, null); chartPanel.setPreferredSize(new java.awt.Dimension(550, 250)); rightSide = new XYSeries("Gas on the right side"); dataset.addSeries(rightSide);/* w ww .j ava 2 s . co m*/ total = new XYSeries("Total"); dataset.addSeries(total); frame.setContentPane(chartPanel); frame.setLocation(50, 0); XYSeries s = dataset.getSeries("Total"); }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * A test for bug report 1170825.//from w w w .j a v a 2s.co m */ public void test1170825() { XYSeries s1 = new XYSeries("Series1"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(s1); try { /* XYSeries s = */ dataset.getSeries(1); } catch (IllegalArgumentException e) { // correct outcome } catch (IndexOutOfBoundsException e) { assertTrue(false); // wrong outcome } }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Returns a chart for the evolution of the shadowing of the component tdc with sh. * /* w ww . j a v a 2 s. c om*/ * @param tdc * @param sh * @param database * @param agent * @param index * @param shadowRange * @param ged * @return */ public static JFreeChart chartShadowEvolution(tdComponent tdc, String sh, tdDataBase database, Agent agent, List<Double> index, double shadowRange, GraphEvolutionDescriptor ged) { List<String> shadowColors = null; if (tdc.getType() == tdComponentType.INSTANCE) { shadowColors = ged.shadowInstanceEnergyColors; } else { shadowColors = ged.shadowViEnergyColors; } // create a general purpose xy collection for jfreechart XYSeriesCollection xysc = new XYSeriesCollection(); // shadow energy values (if needed) if (ged.graphShadowEnergy) { for (String ec : shadowColors) { xysc.addSeries(new XYSeries("ShadowEnergy_" + ec + "_" + sh)); } } // shadow salience values (if needed) if (ged.graphShadowSalience) { for (String ec : shadowColors) { xysc.addSeries(new XYSeries("ShadowSalience_" + ec + "_" + sh)); } } // // Fill in the values into the xysc // for (Double time : index) { double dtime = time; // shadow energy values (if needed) if (ged.graphShadowEnergy) { for (String ec : shadowColors) { double value = database.getEnergy(tdc.getIdentifier(), sh, ec, time); xysc.getSeries("ShadowEnergy_" + ec + "_" + sh).add(dtime, value); } } // shadow salience values (if needed) if (ged.graphShadowSalience) { for (String ec : shadowColors) { double value = database.getSalience(tdc.getIdentifier(), sh, ec, time); xysc.getSeries("ShadowSalience_" + ec + "_" + sh).add(dtime, value); } } } XYSeriesCollection xysSH = new XYSeriesCollection(); // shadow energy (if needed) if (ged.graphShadowEnergy) { for (String ec : shadowColors) { xysSH.addSeries(xysc.getSeries("ShadowEnergy_" + ec + "_" + sh)); } } // shadow salience (if needed) if (ged.graphShadowSalience) { for (String ec : shadowColors) { xysSH.addSeries(xysc.getSeries("ShadowSalience_" + ec + "_" + sh)); } } // FIND a label String shadowLabel = "Shadow:" + sh; if (tdc.getType() == tdComponentType.INSTANCE) { Instance instance = agent.getAutobiographicalMemory().getInstance(sh); shadowLabel += " - " + SpInstance.spc(instance, agent); } else { VerbInstance vi = agent.getAutobiographicalMemory().getVerbInstance(sh); shadowLabel += " - " + XapiPrint.ppsViXapiForm(vi, agent); } JFreeChart chart = ChartFactory.createXYLineChart(shadowLabel, "Time", "Value", xysSH, PlotOrientation.VERTICAL, true, false, false); GraphEvolution.setChartProperties(chart, GraphEvolution.lineStylesConservative); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis(0).setRange(0, shadowRange); return chart; }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * Some basic checks for the getSeries() method. *//* w ww . ja v a 2 s . c o m*/ public void testGetSeries() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries(0).getKey()); boolean pass = false; try { c.getSeries(-1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); pass = false; try { c.getSeries(1); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.xy.junit.XYSeriesCollectionTest.java
/** * Some checks for the getSeries(Comparable) method. *//*from w w w . j a v a2 s.c om*/ public void testGetSeriesByKey() { XYSeriesCollection c = new XYSeriesCollection(); XYSeries s1 = new XYSeries("s1"); c.addSeries(s1); assertEquals("s1", c.getSeries("s1").getKey()); boolean pass = false; try { c.getSeries("s2"); } catch (UnknownKeyException e) { pass = true; } assertTrue(pass); pass = false; try { c.getSeries(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
From source file:com.anrisoftware.prefdialog.miscswing.multichart.freechart.FreechartXYChart.java
private void updateDeletedData(int row0, int row1, int offset) { XYSeriesCollection series = getCategory(); for (int col = 0; col < series.getSeriesCount(); col++) { XYSeries xyseries = series.getSeries(col); for (int row = row1; row >= row0; row--) { xyseries.remove(row);/*from w ww. j a va 2 s. c o m*/ } } }