List of usage examples for org.jfree.chart.plot PiePlot3D setStartAngle
public void setStartAngle(double angle)
From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java
public void displayChart(Date date1) { int total = 0; int k;// w ww .j a v a 2 s. c om int count = 0; int avg = 0; Sensor s = (Sensor) jTable1.getValueAt(0, 0); Date b = s.getDate(); DateFormat formatter = new SimpleDateFormat("MM/dd/yy"); Date date = new Date(); try { date = formatter.parse("12/11/16"); } catch (Exception e) { } //date = System.out.println(jTable1.getValueAt(0, 5)); System.out.println(jTable1.getValueAt(0, 4)); list = new ArrayList<>(); for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getCurrentEmissionCO2(); count++; } } avg = total / count; list.add(avg); int avg1 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getCurrentEmissionCO2(); count++; } } avg = total / count; list.add(avg); for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getNormalCO2(); count++; } } avg1 = total / count; int avg3 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getCurrentEmissionNOx(); count++; } } avg3 = total / count; int avg4 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getNormalNOx(); count++; } } avg4 = total / count; int avg5 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarCurrentEmissionCO2(); count++; } } avg5 = total / count; int avg6 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarNormalCO2(); count++; } } avg6 = total / count; int avg7 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarCurrentEmissionNOx(); count++; } } avg7 = total / count; int avg8 = 0; for (int l = 0; l < jTable1.getRowCount(); l++) { if (date.getDate() == b.getDate()) { Sensor s1 = (Sensor) jTable1.getValueAt(l, 0); total = total + s1.getSolarNormalNOx(); count++; } } avg8 = total / count; int combo = avg + avg3; int combo1 = avg5 + avg7; DefaultPieDataset dataset22 = new DefaultPieDataset(); dataset22.setValue("Fuel Emission", new Integer(combo)); dataset22.setValue("Solar Emission ", new Integer(combo1)); JFreeChart chart22 = ChartFactory.createPieChart3D("Comparison Chart ", // chart title dataset22, // data true, // include legend true, false); final PiePlot3D plot = (PiePlot3D) chart22.getPlot(); plot.setStartAngle(270); plot.setForegroundAlpha(0.60f); plot.setInteriorGap(0.02); ChartFrame frame33 = new ChartFrame("3D Pie Chart for EMission Comparison from different sources", chart22); frame33.setVisible(true); frame33.setSize(500, 400); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(avg, b, "curr CO2"); dataset.setValue(avg1, b, "normal CO2"); dataset.setValue(avg3, b, "current NOx"); dataset.setValue(avg4, b, "normal NOx"); //dataset.setValue(a1,b1,"current"); JFreeChart chart = ChartFactory.createBarChart("Normal Fuel Emission Chart", "CO2 Emission", "in (g/KM)", dataset, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("Bar Chart for Customer", chart); frame.setVisible(true); frame.setSize(500, 400); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset1.setValue(avg5, b, "curr CO2"); dataset1.setValue(avg6, b, "normal CO2"); dataset1.setValue(avg7, b, "current NOx"); dataset1.setValue(avg8, b, "normal NOx"); //dataset.setValue(a1,b1,"current"); JFreeChart chart2 = ChartFactory.createBarChart("Solar Emission Chart", "CO2 Emission", "in (g/KM)", dataset1, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p1 = chart.getCategoryPlot(); p1.setRangeGridlinePaint(Color.BLACK); ChartFrame frame1 = new ChartFrame("Bar Chart for Customer", chart2); frame1.setVisible(true); frame1.setSize(500, 400); }
From source file:org.gvsig.symbology.fmap.symbols.PieChart3DSymbol.java
protected Plot getOutlinePlot() { if (outlinePlot == null) { PiePlot3D myMapPlot = new PiePlot3D(); myMapPlot.setLabelGap(0);/*w w w .ja va 2s . c o m*/ myMapPlot.setIgnoreZeroValues(ignoreZeroValues); updateDataset(); myMapPlot.setDataset(new DefaultPieDataset(dataset)); myMapPlot.setDirection(clockwise ? Rotation.CLOCKWISE : Rotation.ANTICLOCKWISE); myMapPlot.setDepthFactor(depthFactor); myMapPlot.setMinimumArcAngleToDraw(minimumAngleToDraw); myMapPlot.setCircular(circular); myMapPlot.setStartAngle(getRotation()); /* * myMapPlot.setDarkerSides(false); // requires jfreechart 1.0.10 * myMapPlot.setForegroundAlpha(foregroundAlpha); // requires * jfreechart 1.0.10 */ outlinePlot = myMapPlot; } return outlinePlot; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * Creates a pie chart with 3D effect./* w w w . j ava2 s . c om*/ * * @return A pie chart. */ private static JFreeChart createPieChart3D() { JFreeChart chart = ChartFactory.createPieChart3D(null, null, false, true, false); chart.setBackgroundPaint(Color.white); chart.setBorderPaint(Color.white); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setDarkerSides(true); plot.setBaseSectionOutlinePaint(new Color(0, 0, 0, 0)); plot.setStartAngle(0.0); plot.setInteriorGap(0.10); plot.setLabelGenerator(null); plot.setOutlineVisible(false); plot.setLabelBackgroundPaint(Color.white); plot.setLabelOutlinePaint(null); plot.setLabelShadowPaint(null); plot.setLabelPadding(RectangleInsets.ZERO_INSETS); plot.setLabelFont(new Font("Dialog", Font.PLAIN, 12)); plot.setLabelPaint(Color.darkGray); plot.setToolTipGenerator(new StandardPieToolTipGenerator("{2}")); return chart; }
From source file:com.tocea.scertify.eclipse.scertifycode.ui.stats.views.GraphStatsView.java
/** * Cre le graphe JFreeChart.// www . jav a2 s . c o m * * @param piedataset * : la source de donnes afficher * @return le diagramme */ private JFreeChart createChart(final GraphPieDataset piedataset) { final JFreeChart jfreechart = ChartFactory.createPieChart3D(null, piedataset, false, true, false); jfreechart.setAntiAlias(true); jfreechart.setTextAntiAlias(true); final PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); // pieplot3d.setInsets(new RectangleInsets(0, 0, 0, 0)); final double angle = 290D; pieplot3d.setStartAngle(angle); pieplot3d.setDirection(Rotation.CLOCKWISE); final float foreground = 0.5F; pieplot3d.setForegroundAlpha(foreground); pieplot3d.setBackgroundAlpha(0.0F); pieplot3d.setNoDataMessage(Messages.GraphStatsView_noDataToDisplay); pieplot3d.setOutlinePaint(null); pieplot3d.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); pieplot3d.setLabelGap(0.02); pieplot3d.setLabelOutlinePaint(null); pieplot3d.setLabelShadowPaint(null); pieplot3d.setLabelBackgroundPaint(Color.WHITE); pieplot3d.setBackgroundPaint(Color.WHITE); pieplot3d.setInteriorGap(0.02); pieplot3d.setMaximumLabelWidth(0.20); return jfreechart; }
From source file:org.sonar.plugins.abacus.chart.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;/*from www. j a v a 2 s . c o m*/ if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(360); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.WHITE); plot.setDarkerSides(false); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.WHITE); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.02); plot.setMaximumLabelWidth(0.15); return plot; }
From source file:org.sonar.plugins.scmstats.charts.PieChart3D.java
@Override protected Plot getPlot(ChartParameters params) { PiePlot3D plot = new PiePlot3D(); String[] colorsHex = params.getValues(PARAM_COLORS, ",", true); String[] serie = params.getValues(PARAM_VALUES, ";", true); DefaultPieDataset set = new DefaultPieDataset(); Color[] colors = COLORS;//w w w .ja v a2 s. co m if (colorsHex != null && colorsHex.length > 0) { colors = new Color[colorsHex.length]; for (int i = 0; i < colorsHex.length; i++) { colors[i] = Color.decode("#" + colorsHex[i]); } } String[] keyValue = null; for (int i = 0; i < serie.length; i++) { if (!StringUtils.isEmpty(serie[i])) { keyValue = StringUtils.split(serie[i], "="); set.setValue(keyValue[0], Double.parseDouble(keyValue[1])); plot.setSectionPaint(keyValue[0], colors[i]); } } plot.setDataset(set); plot.setStartAngle(180); plot.setCircular(true); plot.setDirection(Rotation.CLOCKWISE); plot.setNoDataMessage(DEFAULT_MESSAGE_NODATA); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setForegroundAlpha(1.0f); plot.setBackgroundAlpha(0.0f); plot.setIgnoreNullValues(true); plot.setIgnoreZeroValues(true); plot.setOutlinePaint(Color.WHITE); plot.setShadowPaint(Color.GREEN); plot.setDarkerSides(true); plot.setLabelFont(DEFAULT_FONT); plot.setLabelPaint(Color.BLACK); plot.setLabelBackgroundPaint(Color.WHITE); plot.setLabelOutlinePaint(Color.WHITE); plot.setLabelShadowPaint(Color.GRAY); plot.setLabelPadding(new RectangleInsets(1, 1, 1, 1)); plot.setInteriorGap(0.01); plot.setMaximumLabelWidth(0.25); return plot; }
From source file:UserInterface.SystemAdmin.ReportsJPanel.java
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed int total = 0; // for(Network network : system.getNetworkList()){ // for(Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()){ // for(Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()){ // if(organization instanceof CustomerOrganization){ // for(Employee employee : organization.getEmployeeDirectory().getEmployeeList()){ // Customer customer = (Customer) employee; // total += customer.getTotalUsageVolume(); // } // } // }// w w w. j av a2 s . c o m // } // } for (Network network : system.getNetworkList()) { for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { if (enterprise instanceof WaterEnterprise) { for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof CustomerOrganization) { for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) { Customer customer = (Customer) employee; total += customer.getTotalUsageVolume(); } } } } } } if (total == 0) { JOptionPane.showMessageDialog(null, "No Customer has used water yet"); return; } DefaultPieDataset dataset = new DefaultPieDataset(); for (Network network : system.getNetworkList()) { for (Enterprise enterprise : network.getEnterpriseDirectory().getEnterpriseList()) { for (Organization organization : enterprise.getOrganizationDirectory().getOrganizationList()) { if (organization instanceof CustomerOrganization) { for (Employee employee : organization.getEmployeeDirectory().getEmployeeList()) { Customer customer = (Customer) employee; dataset.setValue(customer.getName(), customer.getTotalUsageVolume()); } } } } } JFreeChart chart = ChartFactory.createPieChart3D("Customer Water Usage", dataset, true, true, true); ChartFrame frame = new ChartFrame("Pie Chart demonstrating customer water usage ", chart); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(200); plot.setForegroundAlpha(0.50f); RefineryUtilities.centerFrameOnScreen(frame); frame.setVisible(true); frame.setSize(650, 550); }
From source file:GroupProject.OriginalChartUI.java
/** * The method to draw pie chart// w ww . j av a2 s . c o m * @param pieChartData the data used in the pie chart * @param pieTitle the measurement of pie chart */ public void drawPieChart(Map<String, Long> pieChartData, String pieTitle) { String title = pieTitle; ArrayList<String> keyArrayList = new ArrayList<>(); ArrayList<Long> valueArrayList = new ArrayList<>(); ArrayList<Color> colorArrayList = new ArrayList<>(); colorArrayList.add(new Color(222, 235, 247)); colorArrayList.add(new Color(109, 166, 217)); colorArrayList.add(new Color(155, 195, 230)); colorArrayList.add(new Color(126, 146, 222)); colorArrayList.add(new Color(96, 158, 218)); colorArrayList.add(new Color(53, 132, 203)); colorArrayList.add(new Color(46, 116, 180)); colorArrayList.add(new Color(31, 77, 119)); DefaultPieDataset dataset = new DefaultPieDataset(); Set set = pieChartData.keySet(); for (Map.Entry<String, Long> data : pieChartData.entrySet()) { String key = data.getKey(); Long value = data.getValue(); keyArrayList.add(key); valueArrayList.add(value); } for (int i = 0; i < valueArrayList.size(); i++) { dataset.setValue(keyArrayList.get(i), valueArrayList.get(i)); } JFreeChart chart = ChartFactory.createPieChart3D(title, dataset); chart.setBorderVisible(false); chart.setBorderPaint(new Color(255, 255, 255)); PiePlot3D plot = (PiePlot3D) chart.getPlot(); for (int i = 0; i < valueArrayList.size(); i++) { Color color = colorArrayList.get(i); plot.setSectionPaint(keyArrayList.get(i), color); } plot.setOutlineVisible(false); plot.setForegroundAlpha(0.6f); plot.setStartAngle(0); plot.setBackgroundPaint(new java.awt.Color(255, 255, 255)); ChartPanel chartPanel = new ChartPanel(chart); chartDisplayPanel.removeAll(); chartDisplayPanel.add(chartPanel, BorderLayout.CENTER); chartDisplayPanel.validate(); }
From source file:edu.ucla.stat.SOCR.chart.ChartGenerator_JTable.java
private JFreeChart createPieChart(String titleLabel, PieDataset dataset) { // System.out.println("rotation="+rotation); if (dimension.equalsIgnoreCase("3D")) { JFreeChart chart = ChartFactory.createPieChart3D(titleLabel, // chart title dataset, // data true, // include legend true, false);//w w w . j a v a 2 s .c om PiePlot3D plot = (PiePlot3D) chart.getPlot(); if (rotation.equalsIgnoreCase("clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } else if (rotation.equalsIgnoreCase("counter_clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.ANTICLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); return chart; } //end of 3D //2D ring if (rotation.equalsIgnoreCase("ring")) { JFreeChart chart = ChartFactory.createRingChart(titleLabel, // chart title dataset, // data false, // include legend true, false); RingPlot plot = (RingPlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; } //2D JFreeChart chart = ChartFactory.createPieChart(titleLabel, // chart title dataset, // data true, // include legend true, false); TextTitle title = chart.getTitle(); title.setToolTipText("A title tooltip!"); PiePlot plot = (PiePlot) chart.getPlot(); if (rotation.equalsIgnoreCase("clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } else if (rotation.equalsIgnoreCase("counter_clockwise")) { plot.setStartAngle(290); plot.setDirection(Rotation.ANTICLOCKWISE); Rotator rotator = new Rotator(plot); rotator.start(); } plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); plot.setNoDataMessage("No data available"); plot.setCircular(false); plot.setLabelGap(0.02); return chart; }
From source file:gui.images.ImageHubExplorer.java
/** * This method sets the image of the specified history index as the * currently selected image and updates all the views. * * @param index Integer that is the history index of the image to select as * the current image.//from w w w . j av a 2s. c o m */ private synchronized void setSelectedImageForHistoryIndex(int historyIndex) { // Update the selected image panels. BufferedImage photo = getPhoto(selectedImageHistory.get(historyIndex)); selectedImagePanelClassNeighborMain.setImage(photo); selectedImagePanelClassNeighbor.setImage(photo); selectedImagePanelClass.setImage(photo); selectedImagePanelSearch.setImage(photo); int index = selectedImageHistory.get(historyIndex); // Update the labels with the new name. String shortPath = imgPaths.get(index).substring(workspace.getPath().length(), imgPaths.get(index).length()); selectedImagePathLabelClassNeighborMain.setText(shortPath); selectedImagePathLabelClassNeighbor.setText(shortPath); selectedImagePathLabelClass.setText(shortPath); selectedImagePathLabelSearch.setText(shortPath); // Update the class colors. selectedImageLabelClassNeighborMain.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelClassNeighbor.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelClass.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); selectedImageLabelSearch.setBackground(classColors[quantizedRepresentation.getLabelOf(index)]); // Refresh the display. selectedImageLabelClassNeighborMain.setOpaque(true); selectedImageLabelClassNeighbor.setOpaque(true); selectedImageLabelClass.setOpaque(true); selectedImageLabelSearch.setOpaque(true); selectedImageLabelClassNeighborMain.repaint(); selectedImageLabelClassNeighbor.repaint(); selectedImageLabelClass.repaint(); selectedImageLabelSearch.repaint(); // Update the nearest neighbors and the reverse nearest neighbors. NeighborSetFinder nsf = getNSF(); nnPanel.removeAll(); rnnPanel.removeAll(); nnPanel.revalidate(); nnPanel.repaint(); rnnPanel.revalidate(); rnnPanel.repaint(); int[][] kneighbors = nsf.getKNeighbors(); for (int neighborIndex = 0; neighborIndex < neighborhoodSize; neighborIndex++) { BufferedImage thumb = thumbnails.get(kneighbors[index][neighborIndex]); try { Thread t = new Thread(new SetImageNeighborsHelper(nnPanel, thumb, quantizedRepresentation.getLabelOf(kneighbors[index][neighborIndex]), kneighbors[index][neighborIndex])); t.start(); t.join(500); if (t.isAlive()) { t.interrupt(); } } catch (Throwable thr) { System.err.println(thr.getMessage()); } } ArrayList<Integer>[] rrns = rnnSetsAllK[neighborhoodSize - 1]; if (rrns[index] != null && rrns[index].size() > 0) { for (int i = 0; i < rrns[index].size(); i++) { BufferedImage thumb = thumbnails.get(rrns[index].get(i)); try { Thread t = new Thread(new SetImageNeighborsHelper(rnnPanel, thumb, quantizedRepresentation.getLabelOf(rrns[index].get(i)), rrns[index].get(i))); t.start(); t.join(500); if (t.isAlive()) { t.interrupt(); } } catch (Throwable thr) { System.err.println(thr.getMessage()); } } } // Refresh the neighbor and reverse neighbor panels. nnPanel.revalidate(); nnPanel.repaint(); rnnPanel.revalidate(); rnnPanel.repaint(); // Visualize the neighbor occurrence profile of the selected image. DefaultPieDataset pieData = new DefaultPieDataset(); for (int c = 0; c < numClasses; c++) { pieData.setValue(classNames[c], occurrenceProfilesAllK[neighborhoodSize - 1][index][c]); } JFreeChart chart = ChartFactory.createPieChart3D("occurrence profile", pieData, true, true, false); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); PieRenderer prend = new PieRenderer(classColors); prend.setColor(plot, pieData); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(240, 200)); occProfileChartHolder.removeAll(); occProfileChartHolder.add(chartPanel); occProfileChartHolder.revalidate(); occProfileChartHolder.repaint(); }