/** * Tests the getItem() method. */ 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); }
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { MatrixSeries s1 = new MatrixSeries("Series", 2, 3); s1.update(0, 0, 1.1); MatrixSeriesCollection c1 = new MatrixSeriesCollection(); c1.addSeries(s1); MatrixSeries s2 = new MatrixSeries("Series", 2, 3); s2.update(0, 0, 1.1); MatrixSeriesCollection c2 = new MatrixSeriesCollection(); c2.addSeries(s2); assertTrue(c1.equals(c2)); assertTrue(c2.equals(c1)); c1.addSeries(new MatrixSeries("Empty Series", 1, 1)); assertFalse(c1.equals(c2)); c2.addSeries(new MatrixSeries("Empty Series", 1, 1)); assertTrue(c1.equals(c2)); }
/** * Tests the getItemColumn() method. */ public void testGetItemColumn() { MatrixSeries m = new MatrixSeries("Test", 3, 2); assertEquals(0, m.getItemColumn(0)); assertEquals(1, m.getItemColumn(1)); assertEquals(0, m.getItemColumn(2)); assertEquals(1, m.getItemColumn(3)); assertEquals(0, m.getItemColumn(4)); assertEquals(1, m.getItemColumn(5)); }
/** * Tests the getItemRow() method. */ public void testGetItemRow() { MatrixSeries m = new MatrixSeries("Test", 3, 2); assertEquals(0, m.getItemRow(0)); assertEquals(0, m.getItemRow(1)); assertEquals(1, m.getItemRow(2)); assertEquals(1, m.getItemRow(3)); assertEquals(2, m.getItemRow(4)); assertEquals(2, m.getItemRow(5)); }
@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 { 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); // System.out.println("new serie"+serieid+" at // "+IdPosition.get(serieid)+" fdsize "+plot.getSeriesCount()+" jfds // "+jfreedataset.size()+" datasc "+plot.getDatasetCount()); // TODO Auto-generated method stub } }
@Override protected void resetSerie(final IScope scope, final String serieid) { // TODO Auto-generated method stub this.createNewSerie(scope, serieid); final ChartDataSeries dataserie = chartdataset.getDataSeries(scope, serieid); final MatrixSeries serie = ((MatrixSeriesCollection) jfreedataset.get(IdPosition.get(dataserie.getSerieId(scope)))).getSeries(0); final ArrayList<Double> XValues = dataserie.getXValues(scope); final ArrayList<Double> YValues = dataserie.getYValues(scope); final ArrayList<Double> SValues = dataserie.getSValues(scope); final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis(); if (XValues.size()==0) { if (!usexrangeinterval && !usexrangeminmax) { domainAxis.setAutoRange(false); domainAxis.setRange(-0.5,XValues.size()+0.5); } } final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(); if (YValues.size()==0) { if (!useyrangeinterval && !useyrangeminmax) { rangeAxis.setAutoRange(false); rangeAxis.setRange(-0.5,YValues.size()+0.5); } } // final NumberAxis domainAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getDomainAxis(); // final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) this.chart.getPlot()).getRangeAxis(); if (XValues.size() > 0) { domainAxis.setAutoRange(false); rangeAxis.setAutoRange(false); domainAxis.setTickLabelsVisible(this.getXTickValueVisible(scope)); domainAxis.setTickMarksVisible(this.getXTickValueVisible(scope)); rangeAxis.setTickLabelsVisible(this.getYTickValueVisible(scope)); rangeAxis.setTickMarksVisible(this.getYTickValueVisible(scope)); for (int i = 0; i < XValues.size(); i++) { if (XValues.get(i)>domainAxis.getUpperBound()) { if (!usexrangeinterval && !usexrangeminmax) { domainAxis.setAutoRange(false); domainAxis.setRange(-0.5,YValues.get(i)+0.5); } } if (YValues.get(i)>rangeAxis.getUpperBound()) { if (!useyrangeinterval && !useyrangeminmax) { rangeAxis.setAutoRange(false); rangeAxis.setRange(-0.5,YValues.get(i)+0.5); } } serie.update(YValues.get(i).intValue(), XValues.get(i).intValue(), SValues.get(i).doubleValue()); } } this.resetRenderer(scope, serieid); }