List of usage examples for org.jfree.data.xy DefaultXYZDataset getSeriesCount
@Override public int getSeriesCount()
From source file:edu.gmu.cs.sim.util.media.chart.BubbleChartGenerator.java
public SeriesAttributes addSeries(double[][] values, String name, final org.jfree.data.general.SeriesChangeListener stopper) { DefaultXYZDataset dataset = (DefaultXYZDataset) (getSeriesDataset()); int i = dataset.getSeriesCount(); dataset.addSeries(new UniqueString(name), values); // need to have added the dataset BEFORE calling this since it'll try to change the name of the series BubbleChartSeriesAttributes csa = new BubbleChartSeriesAttributes(this, name, i, values, stopper); seriesAttributes.add(csa, name);//from w ww . j a va2s. c om revalidate(); update(); // won't update properly unless I force it here by letting all the existing scheduled events to go through. Dumb design. :-( SwingUtilities.invokeLater(new Runnable() { public void run() { update(); } }); return csa; }
From source file:org.jfree.data.xy.DefaultXYZDatasetTest.java
/** * Some tests for the addSeries() method. *///www . ja va 2 s. c om @Test public void testAddSeries() { DefaultXYZDataset d = new DefaultXYZDataset(); d.addSeries("S1", new double[][] { { 1.0 }, { 2.0 }, { 3.0 } }); assertEquals(1, d.getSeriesCount()); assertEquals("S1", d.getSeriesKey(0)); // check that adding a series will overwrite the old series d.addSeries("S1", new double[][] { { 11.0 }, { 12.0 }, { 13.0 } }); assertEquals(1, d.getSeriesCount()); assertEquals(12.0, d.getYValue(0, 0), EPSILON); // check null key boolean pass = false; try { d.addSeries(null, new double[][] { { 1.0 }, { 2.0 }, { 3.0 } }); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.xy.junit.DefaultXYZDatasetTest.java
/** * Some tests for the addSeries() method. */// w ww.j av a 2 s . com public void testAddSeries() { DefaultXYZDataset d = new DefaultXYZDataset(); d.addSeries("S1", new double[][] { { 1.0 }, { 2.0 }, { 3.0 } }); assertEquals(1, d.getSeriesCount()); assertEquals("S1", d.getSeriesKey(0)); // check that adding a series will overwrite the old series d.addSeries("S1", new double[][] { { 11.0 }, { 12.0 }, { 13.0 } }); assertEquals(1, d.getSeriesCount()); assertEquals(12.0, d.getYValue(0, 0), EPSILON); // check null key boolean pass = false; try { d.addSeries(null, new double[][] { { 1.0 }, { 2.0 }, { 3.0 } }); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.SimpleCluster.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createBubbleChart(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, legend, true, false);/* w w w. j a va 2 s . c om*/ /*Font font = new Font("Tahoma", Font.BOLD, titleDimension); TextTitle title = new TextTitle(name, font); chart.setTitle(title);*/ TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } Color colorSubInvisibleTitle = Color.decode("#FFFFFF"); StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle); TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle); chart.addSubtitle(subsubTitle); chart.setBackgroundPaint(color); XYPlot plot = (XYPlot) chart.getPlot(); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); //plot.setForegroundAlpha(0.50f); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); //define colors int seriesN = dataset.getSeriesCount(); if (colorMap != null) { boolean isSerieSel = true; for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); String tmpName = serieName.replaceAll(" ", ""); tmpName = tmpName.replace('.', ' ').trim(); if (serie_selected != null && serie_selected.size() > 0) { String serieSel = serie_selected.get(tmpName).toString(); isSerieSel = (serieSel.equalsIgnoreCase("TRUE") || serieSel.equalsIgnoreCase("YES") || serieSel.equalsIgnoreCase("1")) ? true : false; serieName = tmpName; } if (color != null && isSerieSel) { Color color = (Color) colorMap.get(serieName); renderer.setSeriesPaint(i, color); } else { Color color = new Color(Integer.decode(defaultColor).intValue()); renderer.setSeriesPaint(i, color); } } } // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); //domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); //rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); TickUnits units = null; if (decimalXValues == false) units = (TickUnits) NumberAxis.createIntegerTickUnits(); else units = (TickUnits) NumberAxis.createStandardTickUnits(); rangeAxis.setStandardTickUnits(units); TickUnits domainUnits = null; if (decimalYValues == false) domainUnits = (TickUnits) NumberAxis.createIntegerTickUnits(); else domainUnits = (TickUnits) NumberAxis.createStandardTickUnits(); domainAxis.setStandardTickUnits(domainUnits); rangeAxis.setLowerMargin(1.0); rangeAxis.setUpperMargin(1.0); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); domainAxis.setLowerMargin(1.0); domainAxis.setUpperMargin(1.0); //DecimalFormat format=(new DecimalFormat("0")); //rangeAxis.setNumberFormatOverride(format); if (legend == true) drawLegend(chart); return chart; }