List of usage examples for org.jfree.data.category CategoryToPieDataset CategoryToPieDataset
public CategoryToPieDataset(CategoryDataset source, TableOrder extract, int index)
From source file:org.openfaces.component.chart.impl.plots.MultiplePiePlotAdapter.java
public MultiplePiePlotAdapter(CategoryDataset ds, TableOrder order, Chart chart, PieChartView view) { super(ds);/*from w w w.jav a 2 s . co m*/ TextTitle seriesTitle = getSeriesTitle(chart); getPieChart().setTitle(seriesTitle); PiePlot piePlot = (PiePlot) getPieChart().getPlot(); piePlot.setDataset(new CategoryToPieDataset(ds, order, 0)); setDataExtractOrder(order); if (view.isEnable3D()) { new PiePlot3DAdapter(piePlot, ds, order, view, chart); } else { new PiePlotAdapter(piePlot, ds, order, view, chart); } addConfigurator(new PlotColorsConfigurator()); configure(view); }
From source file:org.operamasks.faces.render.graph.PieChartRenderer.java
protected JFreeChart createChart(UIChart comp) { Dataset dataset = createDataset(comp); JFreeChart chart = null;//from w w w. ja v a 2s.c o m PiePlot pieplot = null; boolean ring = Coercion.coerceToBoolean(comp.getAttributes().get("ring")); if (dataset instanceof CategoryDataset) { CategoryDataset catset = (CategoryDataset) dataset; if (catset.getRowCount() == 1) { PieDataset pieset = new CategoryToPieDataset(catset, TableOrder.BY_ROW, 0); if (ring) { chart = ChartFactory.createRingChart(null, pieset, false, false, false); } else if (comp.isEffect3D()) { chart = ChartFactory.createPieChart3D(null, pieset, false, false, false); } else { chart = ChartFactory.createPieChart(null, pieset, false, false, false); } pieplot = (PiePlot) chart.getPlot(); } else { if (comp.isEffect3D()) { chart = ChartFactory.createMultiplePieChart3D(null, catset, TableOrder.BY_ROW, false, false, false); } else { chart = ChartFactory.createMultiplePieChart(null, catset, TableOrder.BY_ROW, false, false, false); } pieplot = (PiePlot) ((MultiplePiePlot) chart.getPlot()).getPieChart().getPlot(); } } if (pieplot != null) { if (!comp.isDrawItemLabel()) { pieplot.setLabelGenerator(null); } if (comp.isShowItemTips()) { pieplot.setToolTipGenerator(new StandardPieToolTipGenerator()); } Object startAngle = comp.getAttributes().get("startAngle"); if (startAngle != null) { pieplot.setStartAngle(Coercion.coerceToDouble(startAngle)); } } return chart; }
From source file:org.jfree.data.category.CategoryToPieDatasetTest.java
/** * Some tests for the constructor./*from w ww . j av a 2 s . co m*/ */ @Test public void testConstructor() { // try a null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); assertNull(p1.getUnderlyingDataset()); assertEquals(p1.getItemCount(), 0); assertTrue(p1.getKeys().isEmpty()); assertNull(p1.getValue("R1")); }
From source file:org.jfree.data.category.CategoryToPieDatasetTest.java
/** * Some checks for the getValue() method. *//*from w w w . j a v a 2 s . c o m*/ @Test public void testGetValue() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(d1.getValue("C1"), new Double(1.1)); assertEquals(d1.getValue("C2"), new Double(2.2)); // check negative index throws exception try { /* Number n = */ d1.getValue(-1); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // check index == getItemCount() throws exception try { /* Number n = */ d1.getValue(d1.getItemCount()); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // test null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); try { /* Number n = */ p1.getValue(0); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } }
From source file:org.jfree.data.category.junit.CategoryToPieDatasetTest.java
/** * Some tests for the constructor.// ww w. j av a2 s .c o m */ public void testConstructor() { // try a null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); assertNull(p1.getUnderlyingDataset()); assertEquals(p1.getItemCount(), 0); assertTrue(p1.getKeys().isEmpty()); assertNull(p1.getValue("R1")); }
From source file:org.openfaces.component.chart.impl.plots.PiePlotAdapter.java
PiePlotAdapter(PiePlot piePlot, CategoryDataset categoryDataset, TableOrder order, PieChartView chartView,
Chart chart) { // todo: consider refactoring -- view the usage
this.order = order;
PieDataset dataset = new CategoryToPieDataset(categoryDataset, order, 0);
init(piePlot, chart, chartView, dataset, categoryDataset);
}
From source file:org.openfaces.component.chart.impl.plots.PiePlot3DAdapter.java
PiePlot3DAdapter(PiePlot piePlot, CategoryDataset categoryDataset, TableOrder order, PieChartView chartView,
Chart chart) {//w w w . j av a 2 s. c o m
// todo: consider refactoring -- view the usage
this.order = order;
PieDataset dataset = new CategoryToPieDataset(categoryDataset, order, 0);
init(piePlot, chart, chartView, dataset, categoryDataset);
}
From source file:org.jfree.data.category.junit.CategoryToPieDatasetTest.java
/** * Some checks for the getValue() method. */// w ww .j a va 2s. co m public void testGetValue() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(d1.getValue("C1"), new Double(1.1)); assertEquals(d1.getValue("C2"), new Double(2.2)); // check negative index throws exception try { /* Number n = */ d1.getValue(-1); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // check index == getItemCount() throws exception try { /* Number n = */ d1.getValue(d1.getItemCount()); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // test null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); try { /* Number n = */ p1.getValue(0); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } }
From source file:org.jfree.data.category.CategoryToPieDatasetTest.java
/** * Some checks for the getKey(int) method. *//* w w w.j ava 2s . co m*/ @Test public void testGetKey() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(d1.getKey(0), "C1"); assertEquals(d1.getKey(1), "C2"); // check negative index throws exception try { /* Number n = */ d1.getKey(-1); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // check index == getItemCount() throws exception try { /* Number n = */ d1.getKey(d1.getItemCount()); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // test null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); try { /* Number n = */ p1.getKey(0); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } }
From source file:org.jfree.data.category.junit.CategoryToPieDatasetTest.java
/** * Some checks for the getKey(int) method. *///from w w w . java2s . c o m public void testGetKey() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_ROW, 0); assertEquals(d1.getKey(0), "C1"); assertEquals(d1.getKey(1), "C2"); // check negative index throws exception try { /* Number n = */ d1.getKey(-1); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // check index == getItemCount() throws exception try { /* Number n = */ d1.getKey(d1.getItemCount()); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } // test null source CategoryToPieDataset p1 = new CategoryToPieDataset(null, TableOrder.BY_COLUMN, 0); try { /* Number n = */ p1.getKey(0); fail("Expected IndexOutOfBoundsException."); } catch (IndexOutOfBoundsException e) { // this is expected } }