List of usage examples for org.jfree.chart.plot XYPlot setForegroundAlpha
public void setForegroundAlpha(float alpha)
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);/* www . j a v a 2s . c o m*/ dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); xyplot.setForegroundAlpha(0.5F); return jfreechart; }
From source file:es.bsc.autonomic.powermodeller.graphics.TotalPowerAndPredictionDifference.java
private static JFreeChart createChart() { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(NAME, "Power (Watts)", "Power (Watts)", data, true, true, false);//from w w w . j a v a2 s .c o m jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYDifferenceRenderer xydifferencerenderer = new XYDifferenceRenderer(Color.green, Color.yellow, 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("Samples"); dateaxis.setTickLabelsVisible(false); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); xyplot.setForegroundAlpha(0.5F); return jfreechart; }
From source file:org.jfree.chart.demo.BubblePlotDemo.java
/** * Creates a chart./* w w w .ja v a 2s. com*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYZDataset dataset) { final JFreeChart chart = ChartFactory.createBubbleChart("Bubble Plot Demo", "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.65f); // increase the margins to account for the fact that the auto-range doesn't take into // account the bubble size... final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:org.codehaus.mojo.chronos.chart.HistogramChartGenerator.java
protected final JFreeChart createHistogramChart(ResponsetimeSamples samples, String label, ResourceBundle bundle, ReportConfig config) { HistogramDataset histogramdataset = new HistogramDataset(); double[] sampleArray = samples.extractResponsetimes(config.getResponsetimedivider()); histogramdataset.addSeries(label, sampleArray, BINS); HistogramDataset dataset = histogramdataset; JFreeChart chart = ChartFactory.createHistogram(bundle.getString("chronos.label.histogram"), bundle.getString("chronos.label.histogram.x"), bundle.getString("chronos.label.histogram.y"), dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot xyplot = (XYPlot) chart.getPlot(); xyplot.setForegroundAlpha(FOREGROUND_ALPHA); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); if (config.isShowpercentile()) { String label1 = bundle.getString("chronos.label.percentile95.arrow"); double value = samples.getPercentile95(config.getResponsetimedivider()); ChartUtil.addDomainMarker(xyplot, label1, value); }/*w w w. j a v a2 s . co m*/ if (config.isShowaverage()) { String label2 = bundle.getString("chronos.label.average.arrow"); double value = samples.getAverage(config.getResponsetimedivider()); ChartUtil.addDomainMarker(xyplot, label2, value); } return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.SimpleScatter.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYDataset dataset = (DefaultXYDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createScatterPlot(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, false, true, false);// w w w .j ava 2 s . c om Font font = new Font("Tahoma", Font.BOLD, titleDimension); //TextTitle title = new TextTitle(name, font); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); chart.setBackgroundPaint(Color.white); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); int seriesN = dataset.getSeriesCount(); if (colorMap != null) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); Color color = (Color) colorMap.get(serieName); if (color != null) { renderer.setSeriesPaint(i, color); } } } // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); if (legend == true) { drawLegend(chart); } return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BubbleChartDemo1.java
/** * Creates a chart.// w w w.j av a2 s.c o m * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(XYZDataset dataset) { JFreeChart chart = ChartFactory.createBubbleChart(chartTitle, domainLabel, rangeLabel, dataset, PlotOrientation.VERTICAL, !legendPanelOn, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); // SOCRBubbleRenderer renderer = new SOCRBubbleRenderer(dataset); // plot.setRenderer((XYItemRenderer)renderer); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setLegendItemLabelGenerator(new SOCRScaledBubbleSeriesLabelGenerator(zScale)); // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); return chart; }
From source file:slash.navigation.converter.gui.elevationview.ElevationView.java
private XYPlot createPlot(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.65F); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); Font font = new JLabel().getFont(); rangeAxis.setLabelFont(font);//from w ww .j ava 2s .com NumberAxis valueAxis = (NumberAxis) plot.getDomainAxis(); valueAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); valueAxis.setLowerMargin(0.0); valueAxis.setUpperMargin(0.0); valueAxis.setLabelFont(font); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{2}m @ {1} Km", NumberFormat.getIntegerInstance(), NumberFormat.getIntegerInstance())); return plot; }
From source file:BubbleChartDemo.java
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException { Connection conn = null;// w ww .jav a2s .c o m Statement stmt = null; ResultSet rs = null; ResultSetMetaData rsm = null; OutputStream out = response.getOutputStream(); try { DefaultXYZDataset dataset = new DefaultXYZDataset(); double[] x = { 2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8 }; double[] y = { 14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25 }; double[] z = { 2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4 }; double[][] series = new double[][] { x, y, z }; dataset.addSeries("Series 1", series); JFreeChart chart = ChartFactory.createBubbleChart("Bubble Chart Demo 1", "X", "Y", dataset, PlotOrientation.HORIZONTAL, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerMargin(0.15); domainAxis.setUpperMargin(0.15); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerMargin(0.15); rangeAxis.setUpperMargin(0.15); response.setContentType("image/png"); int width = 800; int height = 600; ChartUtilities.writeChartAsPNG(out, chart, width, height); } catch (Exception e) { throw new ServletException(e); } }
From source file:org.jfree.chart.demo.BubblyBubblesDemo.java
/** * A demonstration application showing a bubble chart using matrix series. * * @param title the frame title.//ww w .j a va2s .c o m */ public BubblyBubblesDemo(final String title) { super(title); this.series = createInitialSeries(); final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.series); final JFreeChart chart = ChartFactory.createBubbleChart(TITLE, "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue)); final XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.5f); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerBound(-0.5); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setInverted(true); // uncoment to reproduce a bug in jFreeChart rangeAxis.setLowerBound(-0.5); final ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setVerticalZoom(true); // chartPanel.setHorizontalZoom(true); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.BubblyBubblesDemo2.java
/** * A demonstration application showing a bubble chart using matrix series. * * @param title the frame title./*www . j av a 2s.co m*/ */ public BubblyBubblesDemo2(final String title) { super(title); this.series = createInitialSeries(); final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.series); final JFreeChart chart = ChartFactory.createBubbleChart(TITLE, "X", "Y", dataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.yellow)); final XYPlot plot = chart.getXYPlot(); plot.setForegroundAlpha(0.5f); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setLowerBound(-0.5); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLowerBound(-0.5); final ChartPanel chartPanel = new ChartPanel(chart); // chartPanel.setVerticalZoom(true); // chartPanel.setHorizontalZoom(true); setContentPane(chartPanel); }