List of usage examples for org.jfree.chart.plot PiePlot3D setForegroundAlpha
public void setForegroundAlpha(float alpha)
From source file:org.emftrace.quarc.ui.views.RatioView.java
/** * create a PieChart for the priorities of the goals * @param dataset the used Dataset/*ww w . j a va2s . c o m*/ * @return the created Chart */ private JFreeChart createChart(PieDataset dataset) { JFreeChart chart = ChartFactory.createPieChart3D("priorities of selected goals", // chart // title dataset, // data true, // include legend true, false); final org.jfree.chart.plot.PiePlot3D plot = (org.jfree.chart.plot.PiePlot3D) chart.getPlot(); plot.setStartAngle(290); plot.setDirection(Rotation.CLOCKWISE); plot.setForegroundAlpha(0.5f); plot.setNoDataMessage("No data to display"); plot.setLabelGenerator(new org.jfree.chart.labels.StandardPieSectionLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance())); return chart; }
From source file:UserInterface.CustomerRole.CustomerTaxJPanel.java
public void displayChart(Date date1) { int total = 0; int k;//from w w w .j ava 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:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.StatView.java
/** * method to update the displayed chart based on the user's selection */// www . j a va 2s. co m public void updateChart() { JFreeChart chart = null; AbstractRequirementStatistics stats = null; // initialize the stats based on the type of data which the user has // selected switch (chartDataType) { case STATUS: stats = new StatusRequirementStatistics(); break; case ITERATION: stats = new IterationRequirementStatistics(); break; case ASSIGNEE: stats = new AssigneeRequirementStatistics(); break; case ESTIMATES: stats = new EstimateRequirementStatistics(); break; case EFFORT: stats = new ActualRequirementStatistics(); break; case VELOCITY: stats = new VelocityIterationStatistics(); break; case TASK: stats = new TaskRequirementStatistics(); break; default: // if you encounter this default statement, it means that new // values // have been // added to the DataType enum, but nobody has modified this poor // little method } // build the chart based on the type of chart the user has selected switch (chartType) { case BAR: // TODO: determine if additional modifications need to be // made // to the plot chart = stats.buildBarChart(); final CategoryPlot barPlot = (CategoryPlot) chart.getPlot(); barPlot.setNoDataMessage("No data available"); break; case PIE: chart = stats.buildPieChart(); final PiePlot3D piePlot = (PiePlot3D) chart.getPlot(); piePlot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); piePlot.setNoDataMessage("No data available"); piePlot.setCircular(true); piePlot.setLabelGap(0.02); piePlot.setForegroundAlpha(0.7f); final PieSectionLabelGenerator generator = new StandardPieSectionLabelGenerator("{0} = {1} ({2})"); piePlot.setLabelGenerator(generator); break; case LINE: chart = stats.buildLineChart(); final CategoryPlot linePlot = (CategoryPlot) chart.getPlot(); linePlot.setNoDataMessage("No data available"); default: // if you encounter this default statement, it means that new // values have been added to the ChartType enum, but nobody has // modified this poor little method } // add the newly generated chart to the panel final JSplitPane mainPane = (JSplitPane) getComponent(0); final ChartPanel chartPanel = (ChartPanel) mainPane.getLeftComponent(); chartPanel.setChart(chart); return; }
From source file:com.smhdemo.common.report.generate.factory.ChartFactory.java
public byte[] export(Chart report, Map<String, String> pageParams) throws Exception { if (report == null) { return null; }/*from w w w . jav a 2 s . c o m*/ DefaultCategoryDataset dataset = buildDataset(report, pageParams); java.awt.Font titleFont = new java.awt.Font(report.getFontName(), report.getFontStyle(), report.getFontSize()); String chartTitle = report.getChartTitle(); chartTitle = replaceParam(pageParams, report.getParameters(), chartTitle, false); String horizAxisLabel = report.getHorizAxisLabel(); horizAxisLabel = replaceParam(pageParams, report.getParameters(), horizAxisLabel, false); String vertAxisLabel = report.getVertAxisLabel(); vertAxisLabel = replaceParam(pageParams, report.getParameters(), vertAxisLabel, false); Boolean showLegend = report.getShowLegend(); Boolean showTooltips = report.getShowTooltips(); Boolean drillThroughEnabled = false; Chart.Type chartType = report.getType(); CategoryURLGenerator urlGenerator = null; JFreeChart chart = null; switch (chartType) { case VERTBAR: chart = ChartGenerationService.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTBAR3D: chart = ChartGenerationService.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZBAR: chart = ChartGenerationService.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZBAR3D: chart = ChartGenerationService.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDVERTBAR: chart = ChartGenerationService.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDVERTBAR3D: chart = ChartGenerationService.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDHORIZBAR: chart = ChartGenerationService.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDHORIZBAR3D: chart = ChartGenerationService.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTLINE: chart = ChartGenerationService.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZLINE: chart = ChartGenerationService.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTAREA: chart = ChartGenerationService.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZAREA: chart = ChartGenerationService.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTSTACKEDAREA: chart = ChartGenerationService.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZSTACKEDAREA: chart = ChartGenerationService.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case PIEBYCOLUMN: chart = ChartGenerationService.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, null); break; case PIEBYROW: chart = ChartGenerationService.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, null); break; case PIEBYCOLUMN3D: chart = ChartGenerationService.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, null); break; case PIEBYROW3D: chart = ChartGenerationService.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, null); break; default: throw new BaseException("", ""); } try { Integer bgColorR = report.getBgColorR(); Integer bgColorG = report.getBgColorG(); Integer bgColorB = report.getBgColorB(); chart.setBackgroundPaint(new java.awt.Color(bgColorR, bgColorG, bgColorB)); String axisFontName = report.getAxisFontName(); Integer axisFontStyle = report.getAxisFontStyle(); Integer axisFontSize = report.getAxisFontSize(); java.awt.Font axisFont = new java.awt.Font(axisFontName, axisFontStyle, axisFontSize); String axisTickFontName = report.getAxisTickFontName(); Integer axisTickFontStyle = report.getAxisTickFontStyle(); Integer axisTickFontSize = report.getAxisTickFontSize(); java.awt.Font axisTickFont = new java.awt.Font(axisTickFontName, axisTickFontStyle, axisTickFontSize); String legendFontName = report.getLegendFontName(); Integer legendFontStyle = report.getLegendFontStyle(); Integer legendFontSize = report.getLegendFontSize(); java.awt.Font legendFont = new java.awt.Font(legendFontName, legendFontStyle, legendFontSize); Integer tickLabelRotate = report.getTickLabelRotate(); String dataFontName = report.getDataFontName(); Integer dataFontStyle = report.getDataFontStyle(); Integer dataFontSize = report.getDataFontSize(); java.awt.Font dataFont = new java.awt.Font(dataFontName, dataFontStyle, dataFontSize); Plot plot = chart.getPlot(); if (!(plot instanceof MultiplePiePlot)) { CategoryPlot categoryPlot = chart.getCategoryPlot(); CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator(0.0)); renderer.setBaseItemLabelFont(dataFont); renderer.setBaseItemLabelsVisible(true); if (chartType == Chart.Type.VERTLINE || chartType == Chart.Type.HORIZLINE) { LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer(); lineRenderer.setBaseShapesVisible(true); lineRenderer.setDrawOutlines(true); lineRenderer.setUseFillPaint(true); } } if (plot instanceof CategoryPlot) { CategoryPlot catPlot = (CategoryPlot) plot; catPlot.getDomainAxis().setLabelFont(axisFont); catPlot.getRangeAxis().setLabelFont(axisFont); catPlot.getDomainAxis().setTickLabelFont(axisTickFont); catPlot.getRangeAxis().setTickLabelFont(axisTickFont); catPlot.getDomainAxis().setMaximumCategoryLabelWidthRatio(100.0f); double angle = -2.0 * Math.PI / 360.0 * (double) tickLabelRotate; CategoryLabelPositions oldp = catPlot.getDomainAxis().getCategoryLabelPositions(); CategoryLabelPositions newp = new CategoryLabelPositions(oldp.getLabelPosition(RectangleEdge.TOP), new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, angle, CategoryLabelWidthType.RANGE, 0.0f), oldp.getLabelPosition(RectangleEdge.LEFT), oldp.getLabelPosition(RectangleEdge.RIGHT)); catPlot.getDomainAxis().setCategoryLabelPositions(newp); } else if (plot instanceof PiePlot3D) { PiePlot3D piePlot = (PiePlot3D) plot; piePlot.setLabelFont(axisFont); piePlot.setDirection(org.jfree.util.Rotation.CLOCKWISE); piePlot.setForegroundAlpha(0.5f); piePlot.setNoDataMessage("?"); } else if (plot instanceof PiePlot) { PiePlot piePlot = (PiePlot) plot; piePlot.setLabelFont(axisFont); } LegendTitle legend = (LegendTitle) chart.getLegend(); if (legend != null) { legend.setItemFont(legendFont); RectangleEdge legendRectEdge = RectangleEdge.BOTTOM; Integer legendPosition = report.getLegendPosition(); switch (legendPosition) { case 0: legendRectEdge = RectangleEdge.LEFT; break; case 1: legendRectEdge = RectangleEdge.TOP; break; case 2: legendRectEdge = RectangleEdge.RIGHT; break; case 3: legendRectEdge = RectangleEdge.BOTTOM; break; } legend.setPosition(legendRectEdge); } } catch (Exception e) { logger.error("Chart Export Exception", e); } ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(out, chart, report.getChartWidth(), report.getChartHeight()); return out.toByteArray(); }
From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java
/** * onClick button PieChart 3D. <br> * /* ww w. ja va 2 s . c om*/ * @param event * @throws IOException */ public void onClick$button_CustomerChart_PieChart3D(Event event) throws InterruptedException, IOException { // logger.debug(event.toString()); div_chartArea.getChildren().clear(); // get the customer ID for which we want show a chart long kunId = getCustomer().getId(); // get a list of data List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId); if (kunAmountList.size() > 0) { DefaultPieDataset pieDataset = new DefaultPieDataset(); for (ChartData chartData : kunAmountList) { Calendar calendar = new GregorianCalendar(); calendar.setTime(chartData.getChartKunInvoiceDate()); int month = calendar.get(Calendar.MONTH) + 1; int year = calendar.get(Calendar.YEAR); String key = String.valueOf(month) + "/" + String.valueOf(year); BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3); String amount = String.valueOf(bd.doubleValue()); // fill the data pieDataset.setValue(key + " " + amount, new Double(chartData.getChartKunInvoiceAmount().doubleValue())); } String title = "Monthly amount for year 2009"; JFreeChart chart = ChartFactory.createPieChart3D(title, pieDataset, true, true, true); PiePlot3D plot = (PiePlot3D) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage chartImage = new AImage("Pie Chart", bytes); Image img = new Image(); img.setContent(chartImage); img.setParent(this.div_chartArea); } else { div_chartArea.getChildren().clear(); Label label = new Label(); label.setValue("This customer have no data for showing in a chart!"); label.setParent(div_chartArea); } }
From source file:com.ewcms.plugin.report.generate.factory.ChartFactory.java
public byte[] export(ChartReport report, Map<String, String> pageParams) throws Exception { if (report == null) { return null; }// ww w. ja v a 2 s . c o m DefaultCategoryDataset dataset = buildDataset(report, pageParams); java.awt.Font titleFont = new java.awt.Font(report.getFontName(), report.getFontStyle(), report.getFontSize()); String chartTitle = report.getChartTitle(); chartTitle = replaceParam(pageParams, report.getParameters(), chartTitle, false); String horizAxisLabel = report.getHorizAxisLabel(); horizAxisLabel = replaceParam(pageParams, report.getParameters(), horizAxisLabel, false); String vertAxisLabel = report.getVertAxisLabel(); vertAxisLabel = replaceParam(pageParams, report.getParameters(), vertAxisLabel, false); Boolean showLegend = report.getShowLegend(); Boolean showTooltips = report.getShowTooltips(); Boolean drillThroughEnabled = false; ChartReport.Type chartType = report.getType(); CategoryURLGenerator urlGenerator = null; JFreeChart chart = null; switch (chartType) { case VERTBAR: chart = ChartGenerationService.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTBAR3D: chart = ChartGenerationService.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZBAR: chart = ChartGenerationService.createBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZBAR3D: chart = ChartGenerationService.createBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDVERTBAR: chart = ChartGenerationService.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDVERTBAR3D: chart = ChartGenerationService.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDHORIZBAR: chart = ChartGenerationService.createStackedBarChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case STACKEDHORIZBAR3D: chart = ChartGenerationService.createStackedBarChart3D(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTLINE: chart = ChartGenerationService.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZLINE: chart = ChartGenerationService.createLineChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTAREA: chart = ChartGenerationService.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZAREA: chart = ChartGenerationService.createAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case VERTSTACKEDAREA: chart = ChartGenerationService.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.VERTICAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case HORIZSTACKEDAREA: chart = ChartGenerationService.createStackedAreaChart(chartTitle, titleFont, horizAxisLabel, vertAxisLabel, dataset, PlotOrientation.HORIZONTAL, showLegend, showTooltips, drillThroughEnabled, urlGenerator); break; case PIEBYCOLUMN: chart = ChartGenerationService.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, null); break; case PIEBYROW: chart = ChartGenerationService.createPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, null); break; case PIEBYCOLUMN3D: chart = ChartGenerationService.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_COLUMN, showLegend, showTooltips, drillThroughEnabled, null); break; case PIEBYROW3D: chart = ChartGenerationService.create3DPieChart(chartTitle, titleFont, dataset, TableOrder.BY_ROW, showLegend, showTooltips, drillThroughEnabled, null); break; default: throw new BaseException("", ""); } try { Integer bgColorR = report.getBgColorR(); Integer bgColorG = report.getBgColorG(); Integer bgColorB = report.getBgColorB(); chart.setBackgroundPaint(new java.awt.Color(bgColorR, bgColorG, bgColorB)); String axisFontName = report.getAxisFontName(); Integer axisFontStyle = report.getAxisFontStyle(); Integer axisFontSize = report.getAxisFontSize(); java.awt.Font axisFont = new java.awt.Font(axisFontName, axisFontStyle, axisFontSize); String axisTickFontName = report.getAxisTickFontName(); Integer axisTickFontStyle = report.getAxisTickFontStyle(); Integer axisTickFontSize = report.getAxisTickFontSize(); java.awt.Font axisTickFont = new java.awt.Font(axisTickFontName, axisTickFontStyle, axisTickFontSize); String legendFontName = report.getLegendFontName(); Integer legendFontStyle = report.getLegendFontStyle(); Integer legendFontSize = report.getLegendFontSize(); java.awt.Font legendFont = new java.awt.Font(legendFontName, legendFontStyle, legendFontSize); Integer tickLabelRotate = report.getTickLabelRotate(); String dataFontName = report.getDataFontName(); Integer dataFontStyle = report.getDataFontStyle(); Integer dataFontSize = report.getDataFontSize(); java.awt.Font dataFont = new java.awt.Font(dataFontName, dataFontStyle, dataFontSize); Plot plot = chart.getPlot(); if (!(plot instanceof MultiplePiePlot)) { CategoryPlot categoryPlot = chart.getCategoryPlot(); CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator(0.0)); renderer.setBaseItemLabelFont(dataFont); renderer.setBaseItemLabelsVisible(true); if (chartType == ChartReport.Type.VERTLINE || chartType == ChartReport.Type.HORIZLINE) { LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer(); lineRenderer.setBaseShapesVisible(true); lineRenderer.setDrawOutlines(true); lineRenderer.setUseFillPaint(true); } } if (plot instanceof CategoryPlot) { CategoryPlot catPlot = (CategoryPlot) plot; catPlot.getDomainAxis().setLabelFont(axisFont); catPlot.getRangeAxis().setLabelFont(axisFont); catPlot.getDomainAxis().setTickLabelFont(axisTickFont); catPlot.getRangeAxis().setTickLabelFont(axisTickFont); catPlot.getDomainAxis().setMaximumCategoryLabelWidthRatio(100.0f); double angle = -2.0 * Math.PI / 360.0 * (double) tickLabelRotate; CategoryLabelPositions oldp = catPlot.getDomainAxis().getCategoryLabelPositions(); CategoryLabelPositions newp = new CategoryLabelPositions(oldp.getLabelPosition(RectangleEdge.TOP), new CategoryLabelPosition(RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, angle, CategoryLabelWidthType.RANGE, 0.0f), oldp.getLabelPosition(RectangleEdge.LEFT), oldp.getLabelPosition(RectangleEdge.RIGHT)); catPlot.getDomainAxis().setCategoryLabelPositions(newp); } else if (plot instanceof PiePlot3D) { PiePlot3D piePlot = (PiePlot3D) plot; piePlot.setLabelFont(axisFont); piePlot.setDirection(org.jfree.util.Rotation.CLOCKWISE); piePlot.setForegroundAlpha(0.5f); piePlot.setNoDataMessage("?"); } else if (plot instanceof PiePlot) { PiePlot piePlot = (PiePlot) plot; piePlot.setLabelFont(axisFont); } LegendTitle legend = (LegendTitle) chart.getLegend(); if (legend != null) { legend.setItemFont(legendFont); RectangleEdge legendRectEdge = RectangleEdge.BOTTOM; Integer legendPosition = report.getLegendPosition(); switch (legendPosition) { case 0: legendRectEdge = RectangleEdge.LEFT; break; case 1: legendRectEdge = RectangleEdge.TOP; break; case 2: legendRectEdge = RectangleEdge.RIGHT; break; case 3: legendRectEdge = RectangleEdge.BOTTOM; break; } legend.setPosition(legendRectEdge); } } catch (Exception e) { logger.error("Chart Export Exception", e); } ByteArrayOutputStream out = new ByteArrayOutputStream(); ChartUtilities.writeChartAsPNG(out, chart, report.getChartWidth(), report.getChartHeight()); return out.toByteArray(); }
From source file:com.estate.pdf.Page.java
protected void drawTaxPie(Rectangle rct, double totalValue, double tax, String taxLabel, String netLabel) { double taxPercent = (tax / totalValue) * 100; double netValuePercent = 100 - taxPercent; DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue(taxLabel, taxPercent); dataset.setValue(netLabel, netValuePercent); PiePlot3D plot = new PiePlot3D(dataset); plot.setLabelGenerator(new StandardPieItemLabelGenerator()); plot.setInsets(new Insets(0, 5, 5, 5)); plot.setToolTipGenerator(new CustomeGenerators.CustomToolTipGenerator()); plot.setLabelGenerator(new CustomeGenerators.CustomLabelGenerator()); plot.setSectionPaint(0, new Color(pgRed)); plot.setSectionPaint(1, new Color(pgGreen)); plot.setForegroundAlpha(.6f); plot.setOutlinePaint(Color.white); plot.setBackgroundPaint(Color.white); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true);//ww w .jav a 2 s . c om Rectangle page = rct; try { Image img = Image.getInstance(chart.createBufferedImage((int) page.getWidth(), (int) page.getHeight()), null); drawDiagram(img, rct, 0, 72); } catch (Exception e) { System.out.println(e.getMessage()); } }
From source file:com.tocea.scertify.eclipse.scertifycode.ui.stats.views.GraphStatsView.java
/** * Cre le graphe JFreeChart./*w w w. j a v a2 s .c om*/ * * @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:com.pureinfo.srm.reports.impl.PieChartBuilder.java
/** * @throws PureException//w w w .j av a 2 s . c o m * @see com.pureinfo.srm.reports.IChartBuilder#draw(java.util.List, int) */ public JFreeChart buildChart() { Iterator result = m_datas.iterator(); DefaultPieDataset ds = getDataset(result); JFreeChart jfreechart = ChartFactory.createPieChart3D(null, ds, false, false, false); jfreechart.setBackgroundPaint(Color.WHITE); PiePlot3D pieplot3d = (PiePlot3D) jfreechart.getPlot(); pieplot3d.setOutlinePaint(Color.GRAY); pieplot3d.setOutlineStroke(new BasicStroke(1)); pieplot3d.setStartAngle(30D); pieplot3d.setDepthFactor(0.04); pieplot3d.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(), DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE, DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE, DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE)); pieplot3d.setCircular(false); pieplot3d.setDirection(Rotation.CLOCKWISE); pieplot3d.setOutlinePaint(Color.WHITE); pieplot3d.setInteriorGap(.15); Color color = new Color(0xaa, 0xaa, 0xaa, 255); pieplot3d.setBaseSectionOutlinePaint(color); pieplot3d.setBaseSectionOutlineStroke(new BasicStroke(0)); pieplot3d.setForegroundAlpha(0.6f); pieplot3d.setLabelLinkStroke(new BasicStroke(1)); pieplot3d.setLabelOutlinePaint(new Color(0x777777)); pieplot3d.setLabelBackgroundPaint(new Color(0xf1f1f7)); pieplot3d.setLabelLinkPaint(new Color(0xaa, 0xaa, 0xaa, 60)); pieplot3d.setNoDataMessage("No data to display"); pieplot3d.setLabelShadowPaint(new Color(0xdddddd)); pieplot3d.setLabelFont(new Font("", Font.PLAIN, 10)); if (m_nType == TYPE_PERCENT) { pieplot3d.setLabelGenerator(new StandardPieItemLabelGenerator("{0} = {2}", NumberFormat.getNumberInstance(), PERCENT_NUMBER_FORMAT)); } fillChartInfo(ds); return jfreechart; }
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(); // } // } // }//from ww w .ja v a 2 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); }