List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:org.jfree.chart.demo.XYBarChartDemo7.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("XYBarChartDemo7", "Date", true, "Y", intervalxydataset, PlotOrientation.VERTICAL, true, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainAxis(new DateAxis("Date")); SymbolAxis symbolaxis = new SymbolAxis("Series", new String[] { "S1", "S2", "S3" }); symbolaxis.setGridBandsVisible(false); xyplot.setRangeAxis(symbolaxis);//from w w w . j a va2 s . co m XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setUseYInterval(true); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); return jfreechart; }
From source file:umberto.WeightedClusterCoefficient.ChartUtils.java
public static void decorateChart(JFreeChart chart) { XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(0, 0, 3, 3)); plot.setBackgroundPaint(java.awt.Color.WHITE); plot.setDomainGridlinePaint(java.awt.Color.GRAY); plot.setRangeGridlinePaint(java.awt.Color.GRAY); plot.setRenderer(renderer);//from w ww .j a v a2s . c o m }
From source file:Data.java
/** * Creates a chart.// w w w. ja v a 2s .c o m * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Graphique des tempratures et humidits", // title "Date", // x-axis label "Temperture/Humidit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); 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("d.M.yy HH:mm:ss")); return chart; }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileChartFactory.java
public static JFreeChart createDiveProfileChartPanel(DiveProfile diveProfile, Locale locale, LengthUnit lengthUnit) {/*ww w. j a v a 2s . com*/ XYSeries depthSerie = new XYSeries(SERIE_DEPTH); XYSeriesCollection depthCollection = new XYSeriesCollection(); depthCollection.addSeries(depthSerie); JFreeChart chart = ChartFactory.createXYAreaChart(null, getDomainLegend(locale), getRangeLegend(locale, lengthUnit), depthCollection, PlotOrientation.VERTICAL, false, true, false); XYPlot xyp = chart.getXYPlot(); Paint p = new GradientPaint(0f, 0f, UIAgent.getInstance().getColorWaterBottom(), 200f, 200f, UIAgent.getInstance().getColorWaterSurface(), false); xyp.setBackgroundPaint(p); xyp.setDomainGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); xyp.setRangeGridlinePaint(UIAgent.getInstance().getColorWaterGrid()); ((NumberAxis) xyp.getDomainAxis()).setNumberFormatOverride(new MinutesNumberFormat()); XYAreaRenderer renderer0 = new XYAreaRenderer(); renderer0.setOutline(true); renderer0.setBaseOutlinePaint(UIAgent.getInstance().getColorWaterBottom()); Color baseColor = UIAgent.getInstance().getColorBaseBackground(); renderer0.setSeriesPaint(0, new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), 50)); xyp.setRenderer(0, renderer0); int i = 1; XYSeriesCollection decoEntriesCollection = new XYSeriesCollection(); XYSeries decoEntriesSerie = new XYSeries(SERIE_DECO_ENTRY); decoEntriesCollection.addSeries(decoEntriesSerie); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorDecoEntries()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_ENTRY]); xyp.setDataset(i, decoEntriesCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection ascentTooFastCollection = new XYSeriesCollection(); XYSeries ascentTooFastSerie = new XYSeries(SERIE_WARNING_ASCENT_TOO_FAST); ascentTooFastCollection.addSeries(ascentTooFastSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningAscentTooFast()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_ASCENT_TOO_FAST_WARNING]); xyp.setDataset(i, ascentTooFastCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection decoWarningCollection = new XYSeriesCollection(); XYSeries decoWarningSerie = new XYSeries(SERIE_DECO_STOP); decoWarningCollection.addSeries(decoWarningSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningDecoCeiling()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_DECO_WARNING]); xyp.setDataset(i, decoWarningCollection); xyp.setRenderer(i, renderer2); i++; XYSeriesCollection remainBottomTimeCollection = new XYSeriesCollection(); XYSeries remainBottomTimeSerie = new XYSeries(SERIE_REMAINING_BOTTOM_TIME); remainBottomTimeCollection.addSeries(remainBottomTimeSerie); renderer2 = new XYLineAndShapeRenderer(); renderer2.setSeriesLinesVisible(0, false); renderer2.setAutoPopulateSeriesShape(false); renderer2.setSeriesPaint(0, UIAgent.getInstance().getColorWarningRemainingBottomTime()); renderer2.setBaseShape(DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE[SHAPE_REMAINING_BOTTOM_TIME_WARNING]); xyp.setDataset(i, remainBottomTimeCollection); xyp.setRenderer(i, renderer2); Map<Double, Double> depthEntries = diveProfile.getDepthEntries(); Set<Double> ascentWarning = diveProfile.getAscentWarnings(); Set<Double> decoWarnings = diveProfile.getDecoCeilingWarnings(); Set<Double> remainBottomTime = diveProfile.getRemainingBottomTimeWarnings(); Set<Double> decoEntryTime = diveProfile.getDecoEntries(); if (depthEntries.size() > 0 && depthEntries.get(0d) == null) { depthEntries.put(0d, 0d); } for (Double seconds : depthEntries.keySet()) { double d = UnitsAgent.getInstance().convertLengthFromModel(depthEntries.get(seconds), lengthUnit); depthSerie.add(seconds, Double.valueOf(d)); } if (null != ascentWarning) { for (Double seconds : ascentWarning) { ascentTooFastSerie.add(seconds, depthEntries.get(seconds)); } } if (null != decoWarnings) { for (Double seconds : decoWarnings) { decoWarningSerie.add(seconds, depthEntries.get(seconds)); } } if (null != remainBottomTime) { for (Double seconds : remainBottomTime) { remainBottomTimeSerie.add(seconds, depthEntries.get(seconds)); } } if (null != decoEntryTime) { for (Double seconds : decoEntryTime) { decoEntriesSerie.add(seconds, depthEntries.get(seconds)); } } return chart; }
From source file:org.jfree.chart.demo.DifferenceChartDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Difference Chart Demo 1", "Time", "Value", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.red, false); xydifferencerenderer.setRoundXCoordinates(true); xyplot.setDomainCrosshairLockedOnData(true); xyplot.setRangeCrosshairLockedOnData(true); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); xyplot.setRenderer(xydifferencerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); DateAxis dateaxis = new DateAxis("Time"); dateaxis.setLowerMargin(0.0D);/*from w w w.j a va 2s . co m*/ dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); xyplot.setForegroundAlpha(0.5F); return jfreechart; }
From source file:no.met.jtimeseries.chart.Utility.java
/** * Create a plot with an error message in case of error. * /* ww w. j a v a 2 s . c om*/ * @param width * The width of the plot * @return The JFreeChart error plot */ public static JFreeChart createErrorChart(int width) { XYPlot plot = new XYPlot(); plot.setBackgroundPaint(null); plot.setBackgroundImage(Symbols.getImage("/error.png")); JFreeChart jchart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); jchart.setBorderVisible(false); Paint paint = new GradientPaint(0, 0, Color.WHITE, width, 0, Color.WHITE); jchart.setBackgroundPaint(paint); return jchart; }
From source file:org.esa.beam.visat.toolviews.diag.TileCacheMonitor.java
private static TimeSeriesCollection addSubPlot(CombinedDomainXYPlot plot, String label) { final TimeSeriesCollection seriesCollection = new TimeSeriesCollection( new TimeSeries(label, Millisecond.class)); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(seriesCollection, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot);//from ww w . java 2 s .c o m return seriesCollection; }
From source file:com.alibaba.dubbo.monitor.simple.SimpleMonitorService.java
private static void createChart(String key, String service, String method, String date, String[] types, Map<String, long[]> data, double[] summary, String path) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm"); DecimalFormat numberFormat = new DecimalFormat("###,##0.##"); TimeSeriesCollection xydataset = new TimeSeriesCollection(); for (int i = 0; i < types.length; i++) { String type = types[i];/*ww w . j ava 2s . c o m*/ TimeSeries timeseries = new TimeSeries(type); for (Map.Entry<String, long[]> entry : data.entrySet()) { try { timeseries.add(new Minute(dateFormat.parse(date + entry.getKey())), entry.getValue()[i]); } catch (ParseException e) { logger.error(e.getMessage(), e); } } xydataset.addSeries(timeseries); } JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "max: " + numberFormat.format(summary[0]) + (summary[1] >= 0 ? " min: " + numberFormat.format(summary[1]) : "") + " avg: " + numberFormat.format(summary[2]) + (summary[3] >= 0 ? " sum: " + numberFormat.format(summary[3]) : ""), toDisplayService(service) + " " + method + " " + toDisplayDate(date), key, xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.WHITE); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.GRAY); xyplot.setRangeGridlinePaint(Color.GRAY); xyplot.setDomainGridlinesVisible(true); xyplot.setRangeGridlinesVisible(true); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("HH:mm")); BufferedImage image = jfreechart.createBufferedImage(600, 300); try { if (logger.isInfoEnabled()) { logger.info("write chart: " + path); } File methodChartFile = new File(path); File methodChartDir = methodChartFile.getParentFile(); if (methodChartDir != null && !methodChartDir.exists()) { methodChartDir.mkdirs(); } FileOutputStream output = new FileOutputStream(methodChartFile); try { ImageIO.write(image, "png", output); output.flush(); } finally { output.close(); } } catch (IOException e) { logger.warn(e.getMessage(), e); } }
From source file:org.gumtree.vis.awt.PlotFactory.java
public static JFreeChart createXYBlockChart(IXYZDataset dataset) { NumberAxis xAxis = createXAxis(dataset); NumberAxis yAxis = createYAxis(dataset); NumberAxis scaleAxis = createScaleAxis(dataset); float min = (float) dataset.getZMin(); float max = (float) dataset.getZMax(); PaintScale scale = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE); XYBlockRenderer renderer = createRender(dataset, scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); plot.setDomainPannable(true);/*from ww w .j av a 2s.c o m*/ plot.setRangePannable(true); JFreeChart chart = new JFreeChart(dataset.getTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, false); // chart = new JFreeChart(dataset.getTitle(), plot); chart.removeLegend(); chart.setBackgroundPaint(Color.white); PaintScale scaleBar = generateRainbowScale(min, max, StaticValues.DEFAULT_COLOR_SCALE); PaintScaleLegend legend = createScaleLegend(scale, scaleAxis); legend.setSubdivisionCount(ColorScale.DIVISION_COUNT); // legend.setStripOutlineVisible(true); chart.addSubtitle(legend); chart.setBorderVisible(true); // ChartUtilities.applyCurrentTheme(chart); chartTheme.apply(chart); chart.fireChartChanged(); return chart; }
From source file:eu.cassandra.training.utils.ChartUtils.java
/** * This function is used for the visualization of two Area Diagrams. * //from w w w . ja va2s . c om * @param title * The title of the chart. * @param x * The unit on the X axis of the chart. * @param y * The unit on the Y axis of the chart. * @param doubles * The array of values of the first array. * * @return a chart panel with the graphical representation. */ public static ChartPanel createExpectedPowerChart(String title, String x, String y, double[] data) { JFreeChart chart = null; XYSeries series1 = new XYSeries("Expected Power"); for (int i = 0; i < data.length; i++) { series1.add(i, data[i]); } XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; chart = ChartFactory.createXYLineChart(title, x, y, dataset, orientation, show, toolTips, urls); 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); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setVerticalTickLabels(true); domainAxis.setRange(0.0, 1440.0); domainAxis.setTickUnit(new NumberTickUnit(100)); return new ChartPanel(chart); }