List of usage examples for org.jfree.data.xy MatrixSeries MatrixSeries
public MatrixSeries(String name, int rows, int columns)
From source file:org.jfree.data.xy.junit.MatrixSeriesCollectionTest.java
/** * Serialize an instance, restore it, and check for equality. *//*from w w w . j av a2 s. c o m*/ public void testSerialization() { MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); c2 = (MatrixSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); }
From source file:org.jfree.data.xy.MatrixSeriesTest.java
/** * Tests the getItem() method./*from ww w. jav a 2 s . c o m*/ */ @Test public void testGetItem() { MatrixSeries m = new MatrixSeries("Test", 3, 2); m.update(0, 0, 0.0); m.update(0, 1, 1.0); m.update(1, 0, 2.0); m.update(1, 1, 3.0); m.update(2, 0, 4.0); m.update(2, 1, 5.0); assertEquals(0.0, m.getItem(0).doubleValue(), 0.001); assertEquals(1.0, m.getItem(1).doubleValue(), 0.001); assertEquals(2.0, m.getItem(2).doubleValue(), 0.001); assertEquals(3.0, m.getItem(3).doubleValue(), 0.001); assertEquals(4.0, m.getItem(4).doubleValue(), 0.001); assertEquals(5.0, m.getItem(5).doubleValue(), 0.001); }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputHeatmap.java
@Override protected void createNewSerie(final IScope scope, final String serieid) { final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid); final MatrixSeries serie = new MatrixSeries((String) dataserie.getSerieLegend(scope), Math.max(1, this.getChartdataset().getYSeriesValues().size()), Math.max(1, this.getChartdataset().getXSeriesValues().size())); final XYPlot plot = (XYPlot) this.chart.getPlot(); final MatrixSeriesCollection firstdataset = (MatrixSeriesCollection) plot.getDataset(); if (!IdPosition.containsKey(serieid)) { if (firstdataset.getSeriesCount() == 0) { firstdataset.addSeries(serie); plot.setDataset(0, firstdataset); } else {/*from w w w .j ava 2 s . co m*/ final MatrixSeriesCollection newdataset = new MatrixSeriesCollection(); newdataset.addSeries(serie); jfreedataset.add(newdataset); plot.setDataset(jfreedataset.size() - 1, newdataset); } plot.setRenderer(jfreedataset.size() - 1, (XYItemRenderer) getOrCreateRenderer(scope, serieid)); IdPosition.put(serieid, jfreedataset.size() - 1); // DEBUG.LOG("new serie"+serieid+" at // "+IdPosition.get(serieid)+" fdsize "+plot.getSeriesCount()+" jfds // "+jfreedataset.size()+" datasc "+plot.getDatasetCount()); // TODO Auto-generated method stub } }