List of usage examples for org.jfree.chart.plot Plot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:net.nosleep.superanalyzer.util.Misc.java
public static void formatChart(Plot plot) { plot.setBackgroundPaint(Color.white); plot.setOutlineVisible(false);//from w ww.jav a2s . co m plot.setNoDataMessage(Misc.getString("NO_DATA_TO_DISPLAY")); if ((plot instanceof XYPlot)) { XYPlot xyPlot = (XYPlot) plot; xyPlot.setDomainGridlinePaint(Color.gray); xyPlot.setRangeGridlinePaint(Color.gray); } }
From source file:org.openfaces.component.chart.impl.plots.PlotUtil.java
public static void setupColorProperties(Chart chart, Plot plot) { StyleObjectModel cssChartViewModel = chart.getChartView().getStyleObjectModel(); plot.setBackgroundPaint(cssChartViewModel.getBackground()); StyleBorderModel border = cssChartViewModel.getBorder(); plot.setOutlinePaint(// ww w .j a va 2s .com border == null || border.isNone() ? cssChartViewModel.getBackground() : border.getColor()); }
From source file:org.eobjects.datacleaner.util.ChartUtils.java
public static void applyStyles(JFreeChart chart) { TextTitle title = chart.getTitle();//w w w. ja v a 2 s . c om if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); } } LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(WidgetUtils.FONT_SMALL); } // transparent background chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); chart.setBorderVisible(false); final Plot plot = chart.getPlot(); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d)); plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true); if (plot instanceof PiePlot) { // tweaks for pie charts final PiePlot piePlot = (PiePlot) plot; piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(normalStroke); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(normalStroke); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); } else if (plot instanceof CategoryPlot) { // tweaks for bar charts final CategoryPlot categoryPlot = (CategoryPlot) plot; int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); } categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); final CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK); renderer.setBaseOutlineStroke(wideStroke); if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter()); } } else if (plot instanceof XYPlot) { // tweaks for line charts final XYPlot xyPlot = (XYPlot) plot; xyPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); final XYItemRenderer renderer = xyPlot.getRenderer(); final int seriesCount = xyPlot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesStroke(i, wideStroke); } } }
From source file:org.datacleaner.util.ChartUtils.java
public static void applyStyles(JFreeChart chart) { TextTitle title = chart.getTitle();//from w ww .j a va 2 s . co m if (title != null) { title.setFont(WidgetUtils.FONT_HEADER1); title.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); } for (int i = 0; i < chart.getSubtitleCount(); i++) { Title subtitle = chart.getSubtitle(i); if (subtitle instanceof TextTitle) { ((TextTitle) subtitle).setFont(WidgetUtils.FONT_NORMAL); } } LegendTitle legend = chart.getLegend(); if (legend != null) { legend.setItemFont(WidgetUtils.FONT_SMALL); } // transparent background chart.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); chart.setBorderVisible(false); final Plot plot = chart.getPlot(); plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0d, 0d, 0d, 0d)); plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true); if (plot instanceof PiePlot) { // tweaks for pie charts final PiePlot piePlot = (PiePlot) plot; piePlot.setBaseSectionOutlinePaint(WidgetUtils.BG_COLOR_DARK); piePlot.setBaseSectionOutlineStroke(STROKE_NORMAL); piePlot.setLabelFont(WidgetUtils.FONT_SMALL); piePlot.setLabelBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHT); piePlot.setLabelOutlineStroke(STROKE_NORMAL); piePlot.setLabelPaint(WidgetUtils.BG_COLOR_DARK); piePlot.setSectionOutlinesVisible(false); piePlot.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); piePlot.setDrawingSupplier(new DCDrawingSupplier()); } else if (plot instanceof CategoryPlot) { // tweaks for bar charts final CategoryPlot categoryPlot = (CategoryPlot) plot; int columnCount = categoryPlot.getDataset().getColumnCount(); if (columnCount > 1) { categoryPlot.setDomainGridlinesVisible(true); } else { categoryPlot.setDomainGridlinesVisible(false); } categoryPlot.setDomainGridlinePaint(WidgetUtils.BG_COLOR_DARK); categoryPlot.setDomainGridlinePosition(CategoryAnchor.END); categoryPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); categoryPlot.setDrawingSupplier(new DCDrawingSupplier()); final CategoryItemRenderer renderer = categoryPlot.getRenderer(); renderer.setBaseOutlinePaint(WidgetUtils.BG_COLOR_DARK); renderer.setBaseOutlineStroke(STROKE_WIDE); if (renderer instanceof BarRenderer) { BarRenderer barRenderer = (BarRenderer) renderer; barRenderer.setShadowPaint(WidgetUtils.BG_COLOR_BRIGHT); barRenderer.setBarPainter(new StandardBarPainter()); } } else if (plot instanceof XYPlot) { // tweaks for line charts final XYPlot xyPlot = (XYPlot) plot; xyPlot.setDrawingSupplier(new DCDrawingSupplier()); xyPlot.getDomainAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getDomainAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setLabelFont(WidgetUtils.FONT_SMALL); xyPlot.getRangeAxis().setTickLabelFont(WidgetUtils.FONT_SMALL); final XYItemRenderer renderer = xyPlot.getRenderer(); final int seriesCount = xyPlot.getSeriesCount(); for (int i = 0; i < seriesCount; i++) { renderer.setSeriesStroke(i, STROKE_WIDE); } } }
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizePlot(Plot plot, ChartParams params) { if (params.get(ChartParams.PLOT_BACKGROUND_COLOR) != null) { plot.setBackgroundPaint(params.getColor(ChartParams.PLOT_BACKGROUND_COLOR)); }//from ww w. j a v a2s .co m if (params.get(ChartParams.PLOT_BACKGROUND_ALPHA) != null) { plot.setBackgroundAlpha(params.getFloat(ChartParams.PLOT_BACKGROUND_ALPHA).floatValue()); } if (params.get(ChartParams.PLOT_FOREGROUND_ALPHA) != null) { plot.setForegroundAlpha(params.getFloat(ChartParams.PLOT_FOREGROUND_ALPHA).floatValue()); } if (params.get(ChartParams.PLOT_INSERTS) != null) { plot.setInsets(params.getRectangleInsets(ChartParams.PLOT_INSERTS)); } if (params.get(ChartParams.PLOT_OUTLINE_COLOR) != null) { plot.setOutlinePaint(params.getColor(ChartParams.PLOT_OUTLINE_COLOR)); } if (params.get(ChartParams.PLOT_OUTLINE_STROKE) != null) { plot.setOutlineStroke(params.getStroke(ChartParams.PLOT_OUTLINE_STROKE)); } }
From source file:org.openfaces.component.chart.impl.configuration.PlotColorsConfigurator.java
public void configure(ConfigurablePlot configurablePlot, ChartView view) { StyleObjectModel cssChartViewModel = view.getStyleObjectModel(); Plot plot = (Plot) configurablePlot; if (view.getBackgroundPaint() != null) { plot.setBackgroundPaint(null); } else {// w w w. jav a 2s . com plot.setBackgroundPaint(cssChartViewModel.getBackground()); } StyleBorderModel border = cssChartViewModel.getBorder(); plot.setOutlinePaint( border == null || border.isNone() ? cssChartViewModel.getBackground() : border.getColor()); }
From source file:uk.ac.lkl.cram.ui.chart.AbstractChartMaker.java
/** * Apply some defaults to a chart, including background paint * and font./*from w w w .j a va2 s . c o m*/ * @param chart the chart to which defaults should be applied */ private void setChartDefaults(JFreeChart chart) { Paint backgroundPaint = UIManager.getColor("InternalFrame.background"); //Set the background colour of the chart chart.setBackgroundPaint(backgroundPaint); //Set the background colour of the plot to be the same as the chart Plot plot = chart.getPlot(); plot.setBackgroundPaint(backgroundPaint); //No outline around the bars plot.setOutlineVisible(false); //Get the legend LegendTitle legend = chart.getLegend(); //Set the font of the legend to be the same as the platform legend.setItemFont(UIManager.getFont("Label.font")); //Set the background colour of the legend to be the same as the platform legend.setBackgroundPaint(backgroundPaint); //No frame around the legend legend.setFrame(BlockBorder.NONE); //Locate the legend to the right of the chart legend.setPosition(RectangleEdge.RIGHT); }
From source file:WeeklyReport.Sections.Declines.java
private JFreeChart declinesByReasonChart() { DefaultPieDataset dataset = new DefaultPieDataset(); Map<Double, String> mp = DECLINES_BY_REASON; mp.entrySet().stream().forEach((mapEntry) -> { dataset.setValue(mapEntry.getValue(), mapEntry.getKey()); });/*from w w w . j a va 2s .c o m*/ JFreeChart pieChart = ChartFactory.createPieChart3D("Reason for Decline by total CBM", dataset, true, true, false); Plot plot = pieChart.getPlot(); plot.setBackgroundPaint(Color.WHITE); return pieChart; }
From source file:org.getobjects.samples.HelloChart.Main.java
/** * This defines the direct action which can be invoked using:<pre> * /HelloThumbnail/wa/Main/chart?chs=128x128&chartType=p3</pre> * //from w w w . ja v a 2s .c om * <p> * Note that the method returns a java.awt.BufferedImage. This will get * rendered to a GIF image by the GoDefaultRenderer. * (this method does not return a WOResponse, but it lets the Go machinery * deal with the image result object). * * @return a BufferedImage containing the scaled image */ public Object chartAction() { Dimension size = UGoogleChart.getDimensions(F("chs", "128x128"), null); String chartType = (String) F("cht", "p"); JFreeChart chart = null; if (chartType.equals("p")) { chart = ChartFactory.createPieChart((String) F("title", "Revenue Chart" /* default title */), this.getPieDataset(), UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } else if (chartType.equals("p3")) { chart = ChartFactory.createPieChart3D((String) F("title", "Revenue Chart" /* default title */), this.getPieDataset(), UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } else if (chartType.startsWith("b")) { // bhs, bvs (one bar with multiple values) // bhg, bvg (one bar for each row) PlotOrientation orientation = PlotOrientation.VERTICAL; if (chartType.startsWith("bh")) orientation = PlotOrientation.HORIZONTAL; if (chartType.endsWith("3")) { chart = ChartFactory.createBarChart3D((String) F("title", "Revenue Chart" /* default title */), (String) F("xlabel", "X-Axis"), (String) F("ylabel", "Y-Axis"), getCatDataSet(), orientation, UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } else { chart = ChartFactory.createBarChart((String) F("title", "Revenue Chart" /* default title */), (String) F("xlabel", "X-Axis"), (String) F("ylabel", "Y-Axis"), getRevCatDataSet(), orientation, UObject.boolValue(F("legend", true)) /* show legend */, UObject.boolValue(F("tooltips", true)) /* show tooltips */, false /* no URLs */); } } /* style the chart */ chart.setBorderVisible(true); //chart.setBorderPaint(new Paint(Color.blue)); Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.blue); chart.setBackgroundPaint(p); /* style the plot */ Plot plot = chart.getPlot(); plot.setBackgroundPaint(new Color(240, 240, 250)); /* add explosion for Pies */ if (plot instanceof PiePlot) { PiePlot pplot = (PiePlot) chart.getPlot(); pplot.setExplodePercent("Products", 0.30); // can be multiple explodes } /* create the image for HTTP delivery */ return chart.createBufferedImage(size.width, size.height); }
From source file:UI.MainViewPanel.java
public ChartPanel getPanel5(Metric5 m5) { int totalRiskCount = m5.totalCriticalCount + m5.totalHighCount + m5.totalLowCount + m5.totalMediumCount; String[][] risks = new String[totalRiskCount][3]; BarChart barChart = new BarChart(m5.totalCriticalCount, m5.totalHighCount, m5.totalMediumCount, m5.totalLowCount, 0, "", risks); ChartPanel thisChart = barChart.drawBarChart(); thisChart.setBackground(Color.white); JFreeChart chart = thisChart.getChart(); chart.setBackgroundPaint(new Color(0, 0, 0, 0)); Plot plot = chart.getPlot(); plot.setBackgroundPaint(chartBackgroundColor); return thisChart; }