List of usage examples for org.jfree.chart JFreeChart setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:edu.ucla.stat.SOCR.chart.demo.PolarChartDemo1.java
/** * Creates a sample chart./*from www . j a va 2 s . co m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createPolarChart(chartTitle, dataset, true, false, false); chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... PolarPlot plot = (PolarPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); if (isDemo) { plot.addCornerTextItem("Corner Item 1"); plot.addCornerTextItem("Corner Item 2"); } plot.setRenderer(new SOCRPolarItemRenderer()); //PolarItemRenderer renderer = plot.getRenderer(); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setXSummary(dataset); if (legendPanelOn) chart.removeLegend(); return chart; }
From source file:org.adempiere.webui.apps.graph.jfreegraph.ChartRendererServiceImpl.java
@Override public boolean renderPerformanceIndicator(Component parent, int chartWidth, int chartHeight, IndicatorModel model) {/* ww w . j a v a 2 s . c om*/ PerformanceGraphBuilder builder = new PerformanceGraphBuilder(); JFreeChart chart = builder.createIndicatorChart(model); chart.setBackgroundPaint(model.chartBackground); chart.setAntiAlias(true); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage image = new AImage("", bytes); Image myImage = new Image(); myImage.setContent(image); parent.appendChild(myImage); } catch (Exception e) { e.printStackTrace(); return false; } return true; }
From source file:com.swordlord.gozer.components.wicket.graph.GWPieChartPanel.java
public GWPieChartPanel(String id, IModel<?> model, GPieChart child) { super(id, model); DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey(); DataBindingMember dbMemberValue = child.getDataBindingMemberValue(); DataBindingManager dbManager = child.getDataBindingManager(); DefaultPieDataset dpd = new DefaultPieDataset(); List<DataRowBase> rowKeys = dbManager.getRows(dbMemberRowKey); List<DataRowBase> values = dbManager.getRows(dbMemberValue); String[] codes = new String[rowKeys.size()]; int[] results = new int[rowKeys.size()]; int i = 0;/*from ww w .ja va 2s . c o m*/ for (DataRowBase row : rowKeys) { codes[i] = row.getPropertyAsString(dbMemberRowKey.getDataBindingFieldName()); i++; } i = 0; for (DataRowBase row : values) { results[i] = row.getPropertyAsInt(dbMemberValue.getDataBindingFieldName()); i++; } for (Integer j = 0; j < rowKeys.size(); j++) { dpd.setValue(MessageFormat.format("{0}: {1}", codes[j], results[j]), results[j]); } JFreeChart chart = ChartFactory.createPieChart(child.getTitle(), dpd, child.getLegend(), false, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDrawingSupplier(child.getDrawingSupplier()); ChartImage image = new ChartImage("chart", chart, child.getWidth(200), child.getHeight(200)); add(image); }
From source file:com.greenpepper.confluence.macros.historic.LinearExecutionChartBuilder.java
private void customizeChart(JFreeChart chart) throws IOException { chart.setBackgroundPaint(Color.white); chart.setBorderVisible(settings.isBorder()); TextTitle chartTitle = chart.getTitle(); customizeTitle(chartTitle, DEFAULT_TITLE_FONT); addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT); addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setNoDataMessage(gpUtil.getText("greenpepper.historic.nodata")); CategoryItemRenderer renderer = plot.getRenderer(); int index = 0; renderer.setSeriesPaint(index++, GREEN_COLOR); if (settings.isShowIgnored()) renderer.setSeriesPaint(index++, Color.yellow); renderer.setSeriesPaint(index, Color.red); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new CategoryURLGenerator() { public String generateURL(CategoryDataset data, int series, int category) { Comparable valueKey = data.getColumnKey(category); ChartLongValue value = (ChartLongValue) valueKey; return "javascript:" + settings.getExecutionUID() + "_showExecutionResult('" + value.getId() + "');"; }/*from www . ja v a2 s.c o m*/ }); CategoryAxis domainAxis = plot.getDomainAxis(); customizeAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); ValueAxis rangeAxis = plot.getRangeAxis(); customizeAxis(rangeAxis); rangeAxis.setLowerBound(0); if (rangeAxis instanceof NumberAxis) { ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(1)); } plot.setForegroundAlpha(0.8f); }
From source file:com.romraider.logger.ecu.ui.tab.LoggerChartPanel.java
private JFreeChart createChart() { JFreeChart chart = createScatterPlot(null, labelX, labelY, null, VERTICAL, false, true, false); chart.setBackgroundPaint(BLACK); configurePlot(chart);/*w w w . j a v a 2s . com*/ addSeries(chart, 0, hilite, 4, GREEN); addTrendLine(chart, 1, trendline, BLUE); addSeries(chart, 2, data, 2, RED); return chart; }
From source file:playground.dgrether.analysis.charts.DgModalSplitDiffQuantilesChart.java
public JFreeChart createChart() { CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel); categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel); //RANGE// ww w. j av a 2 s.c om // valueAxis.setRange(-50.0, 50.0); //test valueAxis.setRange(-20.0, 20.0); //zh DgColorScheme colorScheme = new DgColorScheme(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(categoryAxis); // plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); plot.setRangeAxis(valueAxis); plot.setDataset(0, this.dataset); // plot.setDomainGridlinePosition(CategoryAnchor.END); // plot.setDomainGridlinesVisible(true); BarRenderer carRenderer = new BarRenderer(); carRenderer.setSeriesPaint(0, colorScheme.COLOR1A); carRenderer.setSeriesPaint(1, colorScheme.COLOR3A); carRenderer.setSeriesItemLabelGenerator(0, this.labelgenerator); carRenderer.setSeriesItemLabelGenerator(1, this.labelgenerator); Font labelFont = new Font("Helvetica", Font.BOLD, 14); carRenderer.setSeriesItemLabelFont(0, labelFont); carRenderer.setSeriesItemLabelFont(1, labelFont); carRenderer.setSeriesItemLabelsVisible(0, true); carRenderer.setSeriesItemLabelsVisible(1, true); carRenderer.setItemMargin(0.15); plot.setRenderer(0, carRenderer); JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(ChartColor.WHITE); chart.removeLegend(); // chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); return chart; }
From source file:org.adempiere.webui.apps.graph.WPerformanceIndicator.java
/** * Init Graph Display/*from w w w . jav a 2 s. c o m*/ * Kinamo (pelgrim) */ private void init() { JFreeChart chart = createChart(); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(true); chart.setBorderPaint(Color.LIGHT_GRAY); chart.setAntiAlias(true); BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT, null); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage image = new AImage("", bytes); Image myImage = new Image(); myImage.setContent(image); appendChild(myImage); } catch (Exception e) { // TODO: handle exception } invalidate(); }
From source file:include.picture.MyPieChart.java
public void paint() { try {/*from ww w.j av a2 s . c o m*/ check(); DefaultPieDataset dataset = getDataSet(item, quantity); JFreeChart chart = ChartFactory.createPie3DChart(title, dataset, true, // ? false, false); chart.setBackgroundPaint(Color.WHITE); Pie3DPlot plot = (Pie3DPlot) chart.getPlot(); plot.setSectionLabelType(PiePlot.PERCENT_LABELS); plot.setPercentFormatString("#,###0.00%"); //Pie3DPlotsetDepthFactor ? plot.setDepthFactor(0.05); FileOutputStream fos_jpg = null; try { fos_jpg = new FileOutputStream(fileName); ChartUtilities.writeChartAsJPEG(fos_jpg, 1000, chart, width, height, null); } finally { try { fos_jpg.close(); } catch (Exception e) { } } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.swordlord.gozer.components.fop.graph.GFopPieChart.java
public GFopPieChart(IGozerFrameExtension gfe, GPieChart child) { super(gfe);/*from ww w.j ava 2 s.c o m*/ DataBindingMember dbMemberRowKey = child.getDataBindingMemberRowKey(); DataBindingMember dbMemberValue = child.getDataBindingMemberValue(); DataBindingManager dbManager = child.getDataBindingManager(); DefaultPieDataset dpd = new DefaultPieDataset(); List<DataRowBase> rowKeys = dbManager.getRows(dbMemberRowKey); List<DataRowBase> values = dbManager.getRows(dbMemberValue); String[] codes = new String[rowKeys.size()]; int[] results = new int[rowKeys.size()]; int i = 0; for (DataRowBase row : rowKeys) { codes[i] = row.getPropertyAsString(dbMemberRowKey.getDataBindingFieldName()); i++; } i = 0; for (DataRowBase row : values) { results[i] = row.getPropertyAsInt(dbMemberValue.getDataBindingFieldName()); i++; } for (Integer j = 0; j < rowKeys.size(); j++) { dpd.setValue(MessageFormat.format("{0}: {1}", codes[j], results[j]), results[j]); } JFreeChart chart = ChartFactory.createPieChart(child.getTitle(), dpd, child.getLegend(), false, false); chart.setBackgroundPaint(Color.white); PiePlot plot = (PiePlot) chart.getPlot(); plot.setDrawingSupplier(child.getDrawingSupplier()); _image = new ChartImage("chart", chart, child.getWidth(800), child.getHeight(800)); }
From source file:ws.moor.bt.gui.charts.ConnectionTypes.java
private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Connection Types", "Time", "Connections", dataset, true, false, false);//from w ww . j a v a2 s . c o m chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }