List of usage examples for org.jfree.util TableOrder BY_ROW
TableOrder BY_ROW
To view the source code for org.jfree.util TableOrder BY_ROW.
Click Source Link
From source file:com.itemanalysis.jmetrik.graph.piechart.PieChartPanel.java
public void setGraph() { if (hasGroupVariable) { DefaultCategoryDataset piedat = new DefaultCategoryDataset(); chart = ChartFactory.createMultiplePieChart(chartTitle, piedat, TableOrder.BY_ROW, showLegend, true, false);//from w ww . ja v a2 s . co m if (chartSubtitle != null && !"".equals(chartSubtitle)) { TextTitle subtitle1 = new TextTitle(chartSubtitle); chart.addSubtitle(subtitle1); } MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); JFreeChart subchart = plot.getPieChart(); PiePlot p = (PiePlot) subchart.getPlot(); p.setBackgroundPaint(Color.WHITE); p.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); if (explode) p.setExplodePercent(explodeValue, explodePercent); ChartPanel panel = new ChartPanel(chart); panel.setPreferredSize(new Dimension(width, height)); chart.setPadding(new RectangleInsets(20.0, 5.0, 20.0, 5.0)); this.add(panel); } else { DefaultPieDataset piedat = new DefaultPieDataset(); if (command.getSelectOneOption("view").isValueSelected("3D")) { chart = ChartFactory.createPieChart3D(chartTitle, piedat, showLegend, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); if (explode) plot.setExplodePercent(explodeValue, explodePercent); } else { chart = ChartFactory.createPieChart(command.getFreeOption("title").getString(), piedat, showLegend, true, false); } if (chartSubtitle != null && !"".equals(chartSubtitle)) { TextTitle subtitle = new TextTitle(chartSubtitle); chart.addSubtitle(subtitle); } PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelGap(0.02); plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({2})")); plot.setBackgroundPaint(Color.WHITE); if (explode) plot.setExplodePercent(explodeValue, explodePercent); ChartPanel panel = new ChartPanel(chart); panel.getPopupMenu().addSeparator(); this.addJpgMenuItem(this, panel.getPopupMenu()); panel.setPreferredSize(new Dimension(width, height)); chart.setPadding(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); this.setBackground(Color.WHITE); this.add(panel); } }
From source file:org.jfree.data.category.CategoryToPieDataset.java
/** * Returns the number of items (values) in the collection. If the * underlying dataset is <code>null</code>, this method returns zero. * * @return The item count.//from w w w .j a v a2 s. com */ @Override public int getItemCount() { int result = 0; if (this.source != null) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnCount(); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowCount(); } } return result; }
From source file:com.dnsoft.inmobiliaria.controllers.ConsultaCCPropietariosController.java
void muestraGrafico() { DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); //DefaultPieDataset dataDolares = new DefaultPieDataset(); for (Propietario propietario : listPropietarios) { CCPropietario ccPesos = cCPropietarioDAO.findUltimoMovimiento(Moneda.PESOS, propietario); if (ccPesos != null) { dataSet.setValue(ccPesos.getSaldo(), "Pesos", propietario.toString()); }//w w w . jav a2 s. c om CCPropietario ccDolares = cCPropietarioDAO.findUltimoMovimiento(Moneda.DOLARES, propietario); if (ccDolares != null) { dataSet.setValue(ccDolares.getSaldo(), "Dolares", propietario.toString()); } } // Creando el Grafico //JFreeChart chart = ChartFactory.createPieChart("Saldos", (PieDataset) dataSet, true, true, false); JFreeChart chart = ChartFactory.createMultiplePieChart("Saldos", dataSet, TableOrder.BY_ROW, false, true, false); //PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); JFreeChart subchart = plot.getPieChart(); PiePlot p = (PiePlot) subchart.getPlot(); p.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}: {1} ({2})")); //JFreeChart chartDolares = ChartFactory.createPieChart("Saldos en Dolares", dataDolares, true, true, false); // Mostrar Grafico ChartFrame frame = new ChartFrame("JFreeChart", chart); frame.pack(); frame.setVisible(true); }
From source file:org.jfree.chart.demo.ImageMapDemo6.java
/** * Creates a sample chart with the given dataset. * //from w w w .ja v a2s .c o m * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createMultiplePieChart("Multiple Pie Chart", // chart title dataset, // dataset TableOrder.BY_ROW, true, // include legend true, true); final MultiplePiePlot plot = (MultiplePiePlot) chart.getPlot(); final JFreeChart subchart = plot.getPieChart(); final PiePlot p = (PiePlot) subchart.getPlot(); p.setLabelGenerator(new StandardPieItemLabelGenerator("{0}")); p.setLabelFont(new Font("SansSerif", Font.PLAIN, 8)); p.setInteriorGap(0.30); return chart; }
From source file:org.jfree.data.category.CategoryToPieDatasetTest.java
/** * Some checks for the getIndex() method. *///from w w w . j a v a2s .c om @Test public void testGetIndex() { 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(0, d1.getIndex("C1")); assertEquals(1, d1.getIndex("C2")); assertEquals(-1, d1.getIndex("XX")); // try null boolean pass = false; try { d1.getIndex(null); } catch (IllegalArgumentException e) { pass = true; } assertTrue(pass); }
From source file:org.jfree.data.category.CategoryToPieDataset.java
/** * Returns a value from the dataset.// w ww. ja v a 2 s. com * * @param item the item index (zero-based). * * @return The value (possibly <code>null</code>). * * @throws IndexOutOfBoundsException if <code>item</code> is not in the * range <code>0</code> to <code>getItemCount() - 1</code>. */ @Override public Number getValue(int item) { Number result = null; if (item < 0 || item >= getItemCount()) { // this will include the case where the underlying dataset is null throw new IndexOutOfBoundsException("The 'item' index is out of bounds."); } if (this.extract == TableOrder.BY_ROW) { result = this.source.getValue(this.index, item); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getValue(item, this.index); } return result; }
From source file:org.jfree.data.category.CategoryToPieDataset.java
/** * Returns the key at the specified index. * * @param index the item index (in the range <code>0</code> to * <code>getItemCount() - 1</code>). * * @return The key./*ww w. j a v a2 s . c om*/ * * @throws IndexOutOfBoundsException if <code>index</code> is not in the * specified range. */ @Override public Comparable getKey(int index) { Comparable result = null; if (index < 0 || index >= getItemCount()) { // this includes the case where the underlying dataset is null throw new IndexOutOfBoundsException("Invalid 'index': " + index); } if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnKey(index); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowKey(index); } return result; }
From source file:org.jfree.data.category.CategoryToPieDataset.java
/** * Returns the index for a given key, or <code>-1</code> if there is no * such key./*from ww w . j av a 2s . com*/ * * @param key the key. * * @return The index for the key, or <code>-1</code>. */ @Override public int getIndex(Comparable key) { int result = -1; if (this.source != null) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnIndex(key); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowIndex(key); } } return result; }
From source file:result.analysis.Chart.java
void subjectWisePerformance(String batch, String sem, String[] colleges, String code) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (String college : colleges) { db = mongoClient.getDB(college); String collection_name = "cs_" + batch + "_" + sem + "_sem"; DBCollection collection = db.getCollection(collection_name); analyz = new Analyze(db); double number[] = analyz.GetSubjectPassPercent(collection, code); dataset.setValue(number[1] - number[0], college, "FAIL"); dataset.setValue(number[0], college, "PASS"); }// w ww.j ava 2s .co m JFreeChart pieChart = ChartFactory.createMultiplePieChart("Classwise Distribution", dataset, TableOrder.BY_ROW, true, true, true); // MultiplePiePlot plot = (PiePlot3D) pieChart.getPlot(); MultiplePiePlot plot = (MultiplePiePlot) pieChart.getPlot(); // plot.setStartAngle(290); // plot.setDirection(Rotation.CLOCKWISE); // plot.setForegroundAlpha(0.5f); JFreeChart subchart = plot.getPieChart(); PiePlot p = (PiePlot) subchart.getPlot(); p.setExplodePercent("PASS", 0.10); p.setExplodePercent("FAIL", 0.30); PieSectionLabelGenerator gen = new StandardPieSectionLabelGenerator("{0}: {1} ({2})", new DecimalFormat("0"), new DecimalFormat("0%")); p.setLabelGenerator(gen); ChartFrame frame = new ChartFrame("Subject Performance of " + batch + " year " + sem + " Semester ", pieChart); frame.setVisible(true); frame.setSize(500, 500); save_jpeg(pieChart); }
From source file:org.jfree.data.category.CategoryToPieDataset.java
/** * Returns the keys for the dataset./*from w w w . j a va2s . com*/ * <p> * If the underlying dataset is <code>null</code>, this method returns an * empty list. * * @return The keys. */ @Override public List getKeys() { List result = Collections.EMPTY_LIST; if (this.source != null) { if (this.extract == TableOrder.BY_ROW) { result = this.source.getColumnKeys(); } else if (this.extract == TableOrder.BY_COLUMN) { result = this.source.getRowKeys(); } } return result; }