private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { String w = req.getParameter("width"); if(w==null) w=String.valueOf(defaultW); String h = req.getParameter("height"); if(h==null) h=String.valueOf(defaultH); Color graphBg = stringToColor(req.getParameter("graphBg")); Color plotBg = stringToColor(req.getParameter("plotBg")); if (graph==null) graph = createGraph(); graph.setBackgroundPaint(graphBg); Plot p = graph.getPlot(); p.setBackgroundPaint(plotBg); return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); }
private static void setPlotBackgroundColor(BarChart chartConfig, JFreeChart chart) { if (chartConfig.getPlotBackgroundColor().isPresent()) { final PlotBackgroundColor bgColor = chartConfig.getPlotBackgroundColor().get(); final Optional<Rgb> rgb = bgColor.getRgb(); if (rgb.isPresent()) { final Red red = rgb.get().getRed(); final Blue blue = rgb.get().getBlue(); final Green green = rgb.get().getGreen(); chart.getPlot().setBackgroundPaint(new Color(red.getRgbColor(), green.getRgbColor(), blue.getRgbColor())); } } }
private static void setPlotBackgroundColor(BarChart chartConfig, JFreeChart chart) { if (chartConfig.getPlotBackgroundColor().isPresent()) { final PlotBackgroundColor bgColor = chartConfig.getPlotBackgroundColor().get(); final Optional<Rgb> rgb = bgColor.getRgb(); if (rgb.isPresent()) { final Red red = rgb.get().getRed(); final Blue blue = rgb.get().getBlue(); final Green green = rgb.get().getGreen(); chart.getPlot().setBackgroundPaint(new Color(red.getRgbColor(), green.getRgbColor(), blue.getRgbColor())); } } }
chartPanel.getChart().getPlot().setBackgroundPaint(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); chartPanel.setBackground(new Color(bg.getRed(), bg.getGreen(), bg.getBlue())); chartPanel.getChart().setBackgroundPaint(new Color(bg.getRed(), bg.getGreen(), bg.getBlue()));
private BufferedImage render(StaplerRequest req, ChartRenderingInfo info) { String w = req.getParameter("width"); if(w==null) w=String.valueOf(defaultW); String h = req.getParameter("height"); if(h==null) h=String.valueOf(defaultH); Color graphBg = stringToColor(req.getParameter("graphBg")); Color plotBg = stringToColor(req.getParameter("plotBg")); if (graph==null) graph = createGraph(); graph.setBackgroundPaint(graphBg); Plot p = graph.getPlot(); p.setBackgroundPaint(plotBg); return graph.createBufferedImage(Integer.parseInt(w),Integer.parseInt(h),info); }
/** * Sets properties common to all plots of this plug-in. * * @param plot * the plot to set the properties for */ // CHECKSTYLE:OFF protected void setPlotProperties(final Plot plot) { plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); } // CHECKSTYLE:ON
/** * Sets properties common to all plots of this plug-in. * * @param plot * the plot to set the properties for */ // CHECKSTYLE:OFF protected void setPlotProperties(final Plot plot) { plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); } // CHECKSTYLE:ON
protected void setColors() { chart.setBackgroundPaint(ChartColorFactory.createColor(ofxChart, ChartColorFactory.Area.backgroundChart)); chart.getPlot().setBackgroundPaint(ChartColorFactory.createColor(ofxChart, ChartColorFactory.Area.backgroundPlot)); setSpecialColors(); } protected void setSpecialColors(){logger.error("This should be @Overridden");}
public static JFreeChart getStepChart(String title, TSContainer2 container) { TimeSeriesCollection tempDataSet = new TimeSeriesCollection(); for (int i = 0; i < container.getNumColumns(); i++) { DoubleColumn dc = (DoubleColumn) container.getColumns().get(i); List<TimeStamp> ts = container.getTimeStamps(); TimeSeries tsNew = new TimeSeries(container.getColumnHeaders().get(i)); for (int j = 0; j < dc.size(); j++) tsNew.addOrUpdate(new Millisecond(ts.get(j).getDate()), dc.get(j)); // add a new series. tempDataSet.addSeries(tsNew); } JFreeChart chart = ChartFactory.createXYStepChart(title, "Time", "Value", tempDataSet, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); chart.getPlot().setBackgroundPaint(Color.WHITE); ((XYPlot)chart.getPlot()).setDomainGridlinePaint(Color.LIGHT_GRAY); ((XYPlot)chart.getPlot()).setRangeGridlinePaint(Color.LIGHT_GRAY); return chart; } }
/** * Sets basic configuration including title font, subtitle, background paint and * anti-alias on the given JFreeChart. */ private void setBasicConfig( JFreeChart jFreeChart, BaseChart chart) { jFreeChart.getTitle().setFont( TITLE_FONT ); jFreeChart.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); jFreeChart.setAntiAlias( true ); if ( !chart.isHideTitle() ) { jFreeChart.addSubtitle( getSubTitle( chart ) ); } Plot plot = jFreeChart.getPlot(); plot.setBackgroundPaint( DEFAULT_BACKGROUND_COLOR ); plot.setOutlinePaint( DEFAULT_BACKGROUND_COLOR ); }
/** * Exports a JFreeChart to a scalable PDF file. * * @param chart JFreeChart to export * @param aOS stream to write to. * @param aWidth width of the chart in pixels * @param aHeight height of the chart in pixels * @throws IOException if writing the svgFile fails. */ public static void writeChartAsPDF(OutputStream aOS, JFreeChart chart, int aWidth, int aHeight) throws IOException { // Create an instance of the SVG Generator PDFDocumentGraphics2D pdfGenerator = new PDFDocumentGraphics2D(true, aOS, aWidth, aHeight); pdfGenerator.setDeviceDPI(PDFDocumentGraphics2D.NORMAL_PDF_RESOLUTION); pdfGenerator.setGraphicContext(new GraphicContext()); pdfGenerator.setSVGDimension(aWidth, aHeight); pdfGenerator.setClip(0, 0, aWidth, aHeight); pdfGenerator.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); pdfGenerator.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR); chart.setBackgroundPaint(Color.white); chart.getPlot().setBackgroundPaint(Color.white); // draw the chart in the SVG generator chart.draw(pdfGenerator, new Rectangle(aWidth, aHeight)); pdfGenerator.finish(); } }
plot.setBackgroundPaint(TRANSPARENT_PAINT); plot.setBackgroundPaint(getPlot().getBackcolor());
public static void customizePlot(Plot plot, ChartParams params) { if (params.get(ChartParams.PLOT_BACKGROUND_COLOR) != null) { plot.setBackgroundPaint(params.getColor(ChartParams.PLOT_BACKGROUND_COLOR)); } 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)); } }
/** * Exports a JFreeChart to a scalable PDF file. * * @param chart JFreeChart to export * @param aOS stream to write to. * @param aWidth width of the chart in pixels * @param aHeight height of the chart in pixels * @throws IOException if writing the svgFile fails. */ public static void writeChartAsPDF(OutputStream aOS, JFreeChart chart, int aWidth, int aHeight) throws IOException { // Create an instance of the SVG Generator PDFDocumentGraphics2D pdfGenerator = new PDFDocumentGraphics2D(true, aOS, aWidth, aHeight); pdfGenerator.setDeviceDPI(PDFDocumentGraphics2D.NORMAL_PDF_RESOLUTION); pdfGenerator.setGraphicContext(new GraphicContext()); pdfGenerator.setSVGDimension(aWidth, aHeight); pdfGenerator.setClip(0, 0, aWidth, aHeight); pdfGenerator.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON); pdfGenerator.setRenderingHint(KEY_INTERPOLATION, VALUE_INTERPOLATION_BILINEAR); chart.setBackgroundPaint(Color.white); chart.getPlot().setBackgroundPaint(Color.white); // draw the chart in the SVG generator chart.draw(pdfGenerator, new Rectangle(aWidth, aHeight)); pdfGenerator.finish(); } }
chart.getPlot().setBackgroundPaint(backgroundColor); chart.setBackgroundPaint(backgroundColor); } else { chart.getPlot().setBackgroundPaint(c.getBackground()); chart.setBackgroundPaint(c.getBackground());
plot.setBackgroundPaint(this.plotBackgroundPaint);
plot.setBackgroundPaint(getBackgroundPaint()); plot.setInsets(getPlotInsets());
public void configurePlot(Plot plot) { if (getPlotBackgroundAlpha() != null) { plot.setBackgroundAlpha(getPlotBackgroundAlpha()); } if (getPlotForegroundAlpha() != null) { plot.setForegroundAlpha(getPlotForegroundAlpha()); } if (getPlotBackgroundPaint() != null) { plot.setBackgroundPaint(findColor(getPlotBackgroundPaint())); } if (getPlotOutlinePaint() != null) { plot.setOutlinePaint(findColor(getPlotOutlinePaint())); } if (getPlotOutlineStroke() != null) { plot.setOutlineStroke(findStroke(getPlotOutlineStroke())); } }
plot.setBackgroundPaint(this.plotBackgroundPaint);
plot.setBackgroundPaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlinePaint(WidgetUtils.BG_COLOR_BRIGHTEST); plot.setOutlineVisible(true);