List of usage examples for org.jfree.chart.renderer.xy XYItemRenderer setSeriesPaint
public void setSeriesPaint(int series, Paint paint);
From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java
public static JFreeChart createStackedAreaChart(String title, XYSeriesCollection areaData, XYSeriesCollection lineData, String xLabel, String yLabel, ColorTheme theme) { final ValueAxis xAxis = new NumberAxis(xLabel); final ValueAxis yAxis = new NumberAxis(yLabel); XYPlot mainPlot = new XYPlot(); mainPlot.setDomainAxis(xAxis);/*www . j a v a2 s . co m*/ mainPlot.setRangeAxis(yAxis); mainPlot.setForegroundAlpha(0.9f); //[ stacked area DefaultTableXYDataset areaDs = new DefaultTableXYDataset(); for (int i = 0; i < areaData.getSeriesCount(); i++) { areaDs.addSeries(areaData.getSeries(i)); } XYItemRenderer stackedRenderer = new StackedXYAreaRenderer2(); mainPlot.setDataset(areaDs); mainPlot.setRenderer(stackedRenderer); Color[] colors = generateJetSpectrum(areaData.getSeriesCount()); for (int i = 0; i < areaData.getSeriesCount(); i++) { stackedRenderer.setSeriesPaint(i, colors[i]); } //] //[ lines if (lineData != null) { XYItemRenderer lineRenderer = new StandardXYItemRenderer(); DefaultTableXYDataset lineDs = new DefaultTableXYDataset(); for (int i = 0; i < lineData.getSeriesCount(); i++) { lineDs.addSeries(lineData.getSeries(i)); } mainPlot.setDataset(1, lineDs); mainPlot.setRenderer(1, lineRenderer); colors = new Color[] { Color.black, Color.red, Color.darkGray }; for (int i = 0; i < lineData.getSeriesCount(); i++) { lineRenderer.setSeriesPaint(i, colors[i % colors.length]); lineRenderer.setSeriesStroke(i, new BasicStroke(2f)); } } //] mainPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); formatColorTheme(chart, theme); return chart; }
From source file:audio.cords.SimplestChart.java
private static JFreeChart createChart(XYSeriesCollection data) { JFreeChart chart = ChartFactory.createScatterPlot(null, "X", "Y", data, PlotOrientation.VERTICAL, true, false, false);//from w w w.j a va 2s . co m XYPlot plot = (XYPlot) chart.getPlot(); XYItemRenderer scatterRenderer = plot.getRenderer(); // plot.getDomainAxis().resizeRange(2); // plot.getRangeAxis().resizeRange(2); plot.zoom(2); //StandardXYItemRenderer regressionRenderer = new StandardXYItemRenderer(); //regressionRenderer.setBaseSeriesVisibleInLegend(false); //plot.setDataset(1, regress(data)); //plot.setRenderer(1, regressionRenderer); DrawingSupplier ds = plot.getDrawingSupplier(); for (int i = 0; i < data.getSeriesCount(); i++) { Paint paint = ds.getNextPaint(); scatterRenderer.setSeriesPaint(i, paint); //regressionRenderer.setSeriesPaint(i, paint); } return chart; }
From source file:ucar.unidata.idv.control.chart.HistogramWrapper.java
/** * Plot the displayed {@link DataChoice}. * //from w ww . ja v a 2 s . com * @param histoWrapper Cannot be {@code null}. */ public static void plotHistogram(HistogramWrapper histoWrapper) { XYPlot p = histoWrapper.plot; List<DataChoiceWrapper> dcWrappers = histoWrapper.getDataChoiceWrappers(); try { for (int dataSetIdx = 0; dataSetIdx < p.getDatasetCount(); dataSetIdx++) { MyHistogramDataset dataset = (MyHistogramDataset) p.getDataset(dataSetIdx); dataset.removeAllSeries(); } Hashtable props = new Hashtable(); props.put(TrackDataSource.PROP_TRACKTYPE, TrackDataSource.ID_TIMETRACE); for (int paramIdx = 0; paramIdx < dcWrappers.size(); paramIdx++) { DataChoiceWrapper wrapper = dcWrappers.get(paramIdx); DataChoice dataChoice = wrapper.getDataChoice(); FlatField data = histoWrapper.getFlatField((FieldImpl) dataChoice.getData(null, props)); Unit unit = ucar.visad.Util.getDefaultRangeUnits((FlatField) data)[0]; double[][] samples = data.getValues(false); double[] actualValues = histoWrapper.filterData(samples[0], histoWrapper.getTimeValues(samples, data))[0]; NumberAxis domainAxis = new NumberAxis(wrapper.getLabel(unit)); XYItemRenderer renderer; if (histoWrapper.stacked) { renderer = new StackedXYBarRenderer(); } else { renderer = new XYBarRenderer(); } p.setRenderer(paramIdx, renderer); Color c = wrapper.getColor(paramIdx); domainAxis.setLabelPaint(c); renderer.setSeriesPaint(0, c); MyHistogramDataset dataset = new MyHistogramDataset(); dataset.setType(HistogramType.FREQUENCY); dataset.addSeries(dataChoice.getName() + " [" + unit + "]", actualValues, histoWrapper.bins); p.setDomainAxis(paramIdx, domainAxis, false); p.mapDatasetToDomainAxis(paramIdx, paramIdx); p.setDataset(paramIdx, dataset); } } catch (VisADException | RemoteException e) { LogUtil.logException("Error creating data set", e); } }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
private static XYItemRenderer setAxisAndDataSet(int i, XYPlot plot, ValueAxis axis, XYDataset dataset, Paint p) {/*w w w. j a v a 2 s . c om*/ plot.setRangeAxis(i, axis); plot.setDataset(i, dataset); plot.mapDatasetToRangeAxis(i, i); XYItemRenderer renderer = new StandardXYItemRenderer(); renderer.setSeriesPaint(0, p); axis.setLabelPaint(p); axis.setTickLabelPaint(p); return renderer; }
From source file:au.edu.jcu.usb.USBPlotFrame.java
/** * Constructs the ChartPanel from the provided XYSeriesCollection * * @param xySeriesCollection//from w ww . j av a 2s. c o m * @return The constructed ChartPanel containing the XY scatter plot */ private ChartPanel constructChart(XYSeriesCollection xySeriesCollection) { // Construct the scatter plot from the provided xySeriesCollection JFreeChart chart = ChartFactory.createScatterPlot("Title", "X Axis", "Y Axis", xySeriesCollection); // Get the XY Plot from the scatter chart XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); // Create the renderer XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setVerticalTickLabels(true); ChartPanel chartPanel = new ChartPanel(chart); return chartPanel; }
From source file:oscar.oscarEncounter.oscarMeasurements.pageUtil.MeasurementGraphAction2.java
private static XYItemRenderer setAxisAndDataSet(int i, XYPlot plot, ValueAxis axis, XYDataset dataset, Paint p, XYItemRenderer renderer) { plot.setRangeAxis(i, axis);//from w ww . j a v a 2s. c o m plot.setDataset(i, dataset); plot.mapDatasetToRangeAxis(i, i); renderer.setSeriesPaint(0, p); axis.setLabelPaint(p); axis.setTickLabelPaint(p); return renderer; }
From source file:pl.poid.bzdp.zadanieObrazy.ImageHistogram.java
private JFreeChart createChart(final XYSeriesCollection dataset, Color c) { final JFreeChart chart = ChartFactory.createXYBarChart("Histogram", "Brightness", false, "Values", dataset, PlotOrientation.VERTICAL, true, true, false); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); renderer.setSeriesPaint(0, c); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.att.aro.ui.view.diagnostictab.plot.UserEventPlot.java
@Override public void populate(XYPlot plot, AROTraceData analysis) { if (analysis != null) { userInputData.removeAllSeries(); // create the dataset... Map<UserEvent.UserEventType, XYIntervalSeries> seriesMap = new EnumMap<UserEvent.UserEventType, XYIntervalSeries>( UserEvent.UserEventType.class); for (UserEvent.UserEventType eventType : UserEvent.UserEventType.values()) { XYIntervalSeries series = new XYIntervalSeries(eventType); seriesMap.put(eventType, series); userInputData.addSeries(series); }/* w ww . jav a 2 s .c o m*/ // Populate the data set //need to add something here for (UserEvent event : analysis.getAnalyzerResult().getTraceresult().getUserEvents()) { seriesMap.get(event.getEventType()).add(event.getPressTime(), event.getPressTime(), event.getReleaseTime(), 0.5, 0, 1); } // Assign ToolTip to renderer XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(userInputData.indexOf(UserEventType.SCREEN_LANDSCAPE), Color.BLUE); renderer.setSeriesPaint(userInputData.indexOf(UserEventType.SCREEN_PORTRAIT), Color.BLUE); renderer.setBaseToolTipGenerator(new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int series, int item) { UserEvent.UserEventType eventType = (UserEvent.UserEventType) userInputData.getSeries(series) .getKey(); return ResourceBundleHelper.getEnumString(eventType); } }); } plot.setDataset(userInputData); // return plot; }
From source file:edu.ucla.stat.SOCR.chart.demo.BubbleChartDemo1.java
/** * Creates a chart./*from w w w . j a va2 s.co 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:playground.dgrether.analysis.charts.DgMixedModeSwitcherOnlyDeltaScoreIncomeModeChoiceChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis);/* w w w.j a v a 2 s . co m*/ plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(false, true); renderer1.setSeriesPaint(0, colorScheme.COLOR3B); renderer1.setSeriesPaint(1, colorScheme.COLOR4B); plot.setDataset(0, this.inomeModeChoiceDs); plot.setRenderer(0, renderer1); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); plot.setDataset(1, this.avgDeltaScoreIncomeDs); for (int i = 2; i <= 3; i++) { renderer2.setSeriesStroke(i - 2, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(i - 2, new BasicStroke(3.0f)); renderer2.setSeriesPaint(i - 2, colorScheme.getColor(i + 1, "a")); } plot.setRenderer(1, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }