List of usage examples for org.jfree.chart.plot CombinedDomainXYPlot add
public void add(XYPlot subplot)
From source file:org.jfree.chart.demo.XYTaskDatasetDemo2.java
private static JFreeChart createChart() { CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new DateAxis("Date/Time")); combineddomainxyplot.setDomainPannable(true); combineddomainxyplot.add(createSubplot1(createDataset1())); combineddomainxyplot.add(createSubplot2(createDataset2())); JFreeChart jfreechart = new JFreeChart("XYTaskDatasetDemo2", combineddomainxyplot); jfreechart.setBackgroundPaint(Color.white); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.fhcrc.cpl.viewer.gui.SpectrumChartFactory.java
public static ChartPanel CreateChartPanel(java.util.List datasets, Color[] colors) { if (datasets.size() == 1) return CreateChartPanel((XYSeriesCollection) datasets.get(0), colors); CombinedDomainXYPlot combined = new CombinedDomainXYPlot(); for (Iterator it = datasets.iterator(); it.hasNext();) { XYSeriesCollection series = (XYSeriesCollection) it.next(); XYPlot xy = createXYPlot(series, colors); combined.add(xy); }//from ww w . j av a2 s. c o m NumberAxis axisDomain = new NumberAxis(); axisDomain.setAutoRangeIncludesZero(false); // axisDomain.setRange(400.0, 1600.0); combined.setDomainAxis(axisDomain); JFreeChart chart = new JFreeChart(combined); ChartPanel chartPanel = new SpectrumChartPanel(chart); chartPanel.setDisplayToolTips(true); chartPanel.setMouseZoomable(true); // Remove the autogenerated subtitle if (chart.getSubtitleCount() == 1) chart.removeSubtitle(chart.getSubtitle(chart.getSubtitleCount() - 1)); return chartPanel; }
From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java
public static ChartPanel buildChartPanelForNominalAttribute(final Instances ds, final Attribute attr, final int dateIdx) { final TaskSeriesCollection localTaskSeriesCollection = new TaskSeriesCollection(); final java.util.List<String> names = new ArrayList<String>(); final Set<String> present = WekaDataStatsUtil.getPresentValuesForNominalAttribute(ds, attr.index()); for (final String pr : present) { names.add(pr);//from w ww . j a v a2 s. c o m localTaskSeriesCollection.add(new TaskSeries(pr)); } final Calendar cal = Calendar.getInstance(); try { for (final double[] dd : WekaTimeSeriesUtil.split(ds, attr.index())) { cal.setTimeInMillis((long) dd[0]); final Date start = cal.getTime(); cal.setTimeInMillis((long) dd[1]); final Date end = cal.getTime(); final String sd = ds.instance((int) dd[2]).stringValue(attr); localTaskSeriesCollection.getSeries(sd).add(new Task("T", start, end)); } } catch (Exception e) { e.printStackTrace(); } final XYTaskDataset localXYTaskDataset = new XYTaskDataset(localTaskSeriesCollection); localXYTaskDataset.setTransposed(true); localXYTaskDataset.setSeriesWidth(0.6D); final DateAxis localDateAxis = new DateAxis(DATE_TIME_LABEL); final SymbolAxis localSymbolAxis = new SymbolAxis("", names.toArray(new String[names.size()])); localSymbolAxis.setGridBandsVisible(false); final XYBarRenderer localXYBarRenderer = new XYBarRenderer(); localXYBarRenderer.setUseYInterval(true); localXYBarRenderer.setShadowVisible(false); final XYPlot localXYPlot = new XYPlot(localXYTaskDataset, localDateAxis, localSymbolAxis, localXYBarRenderer); final CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot( new DateAxis(DATE_TIME_LABEL)); localCombinedDomainXYPlot.add(localXYPlot); final JFreeChart localJFreeChart = new JFreeChart("", localCombinedDomainXYPlot); localJFreeChart.setBackgroundPaint(Color.white); final ChartPanel cp = new ChartPanel(localJFreeChart, true); cp.setBorder(new TitledBorder(attr.name())); return cp; }
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); return seriesCollection; }
From source file:no.met.jtimeseries.netcdf.plot.MultiPlotProvider.java
public XYPlot getPlot(List<NumberPhenomenon> dataList) { DateAxis domainAxis = new DateAxis("T", TimeZone.getTimeZone("UTC"), Locale.getDefault()); domainAxis.setRange(dataList.get(0).getStartTime(), dataList.get(0).getEndTime()); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domainAxis); for (PlotProvider provider : subProviders) { List<String> variables = dataForProviders.get(provider); if (variables == null) plot.add(provider.getPlot(dataList)); else//from w w w . j a v a 2s . c om plot.add(provider.getPlot(extractNumberPhenomena(variables, dataList))); } return plot; }
From source file:net.relet.freimap.LinkInfo.java
public void setFlowProfile(LinkedList<FlowData> lp) { XYSeries packets = new XYSeries("packets"); XYSeries bytes = new XYSeries("bytes"); XYSeries icmp = new XYSeries("icmp"); XYSeries tcp = new XYSeries("tcp"); XYSeries udp = new XYSeries("udp"); XYSeries other = new XYSeries("other"); XYSeriesCollection data1 = new XYSeriesCollection(bytes); XYSeriesCollection data2 = new XYSeriesCollection(packets); XYSeriesCollection data3 = new XYSeriesCollection(icmp); data3.addSeries(tcp);//from www . j a v a2s . c om data3.addSeries(udp); data3.addSeries(other); //linkChart = ChartFactory.createXYLineChart("packets, bytes\r\nicmp, tcp, udp other", "time", "count", data1, PlotOrientation.VERTICAL, false, false, false); ValueAxis domain = new DateAxis(); ValueAxis range1 = new NumberAxis(); ValueAxis range2 = new NumberAxis(); ValueAxis range3 = new NumberAxis(); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(domain); plot.add(new XYPlot(data2, domain, range1, new XYLineAndShapeRenderer(true, false))); plot.add(new XYPlot(data1, domain, range2, new XYLineAndShapeRenderer(true, false))); plot.add(new XYPlot(data3, domain, range1, new XYLineAndShapeRenderer(true, false))); linkChart = new JFreeChart(plot); linkChart.setTitle(""); sexupLayout(linkChart); long min = lp.getFirst().begin, max = lp.getLast().end; for (float i = 0.0f; i < 1000.0f; i += 1.0f) { long cur = min + (long) ((max - min) * (i / 1000.0)); long cpackets = 0; long cbytes = 0; long cicmp = 0; long ctcp = 0; long cudp = 0; long cother = 0; Iterator<FlowData> li = lp.iterator(); while (li.hasNext()) { FlowData data = li.next(); if (data.begin > cur) break; if (data.end < cur) continue; cpackets += data.packets; cbytes += data.bytes; switch (data.protocol) { case 1: { cicmp += data.packets; break; } case 6: { ctcp += data.packets; break; } case 17: { cudp += data.packets; break; } default: { cother += data.packets; break; } } } packets.add(cur, cpackets); bytes.add(cur, cbytes); icmp.add(cur, cicmp); tcp.add(cur, ctcp); udp.add(cur, cudp); other.add(cur, cother); } status = STATUS_AVAILABLE; }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java
/** * * @param track// w ww. j a va 2 s .c om */ private void plotCoordinatesTime(Track track) { Double[][] coordinates = track.getCoordinates(); Double[][] transpose2DArray = ComputationUtils.transpose2DArray(coordinates); double[] timeIndexes = track.getTimeIndexes(); double[] xCoordinates = ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(transpose2DArray[0])); XYSeries xtSeries = JFreeChartUtils.generateXYSeries(timeIndexes, xCoordinates); XYSeriesCollection xtSeriesCollection = new XYSeriesCollection(xtSeries); XYItemRenderer renderer = new StandardXYItemRenderer(); NumberAxis xAxis = new NumberAxis("x"); XYPlot xTPlot = new XYPlot(xtSeriesCollection, null, xAxis, renderer); NumberAxis yAxis = new NumberAxis("y"); double[] yCoordinates = ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(transpose2DArray[1])); XYSeries ytSeries = JFreeChartUtils.generateXYSeries(timeIndexes, yCoordinates); XYSeriesCollection ytSeriesCollection = new XYSeriesCollection(ytSeries); XYPlot yTPlot = new XYPlot(ytSeriesCollection, null, yAxis, renderer); // domain axis NumberAxis domainAxis = new NumberAxis("time index"); CombinedDomainXYPlot combinedDomainXYPlot = new CombinedDomainXYPlot(domainAxis); combinedDomainXYPlot.setRenderer(new XYLineAndShapeRenderer()); combinedDomainXYPlot.add(xTPlot); combinedDomainXYPlot.add(yTPlot); combinedDomainXYPlot.setOrientation(PlotOrientation.VERTICAL); JFreeChart combinedChart = new JFreeChart("temp. evolution", combinedDomainXYPlot); ChartPanel chartPanel = new ChartPanel(combinedChart); computationDataPanel.getxYParentPanel().removeAll(); computationDataPanel.getxYParentPanel().add(chartPanel, gridBagConstraints); computationDataPanel.getxYParentPanel().revalidate(); computationDataPanel.getxYParentPanel().repaint(); }
From source file:com.mgmtp.perfload.perfalyzer.reportpreparation.PlotCreator.java
public JFreeChart createPlot(final AxisType xAxisType, final AxisType yAxisType, final RendererType rendererType, final DisplayData displayData, final DataRange dataRange, boolean showMarkers, final NumberDataSet... dataSets) { NumberAxis xAxis = createAxis(xAxisType, resourceBundle.getString(displayData.getUnitX())); XYPlot plot;/*from w w w . j a v a2 s . c o m*/ if (dataSets.length == 1) { NumberAxis yAxis = createAxis(yAxisType, resourceBundle.getString(displayData.getUnitY())); plot = new XYPlot(dataSets[0], xAxis, yAxis, rendererType.createRenderer()); } else { CombinedDomainXYPlot combinedPlot = new CombinedDomainXYPlot(xAxis); for (int i = 0; i < dataSets.length; ++i) { NumberDataSet dataSet = dataSets[i]; // no range for y-axis! NumberAxis yAxis = createAxis(yAxisType, resourceBundle.getString(displayData.getUnitYList().get(i))); XYPlot subPlot = new XYPlot(dataSet, null, yAxis, rendererType.createRenderer()); combinedPlot.add(subPlot); formatPlot(subPlot); } plot = combinedPlot; } JFreeChart chart = new JFreeChart(plot); CHART_THEME.apply(chart); formatPlot(plot); if (showMarkers) { for (Marker marker : markers) { IntervalMarker im = new IntervalMarker(marker.getLeftMillis() / 1000L, marker.getRightMillis() / 1000L); im.setLabel(marker.getName()); im.setLabelFont(new Font("Sans Serif", Font.ITALIC | Font.BOLD, 14)); im.setLabelAnchor(RectangleAnchor.TOP); im.setLabelOffset(new RectangleInsets(8d, 0d, 0d, 0d)); im.setLabelPaint(Color.BLACK); im.setAlpha(.2f); im.setPaint(Color.WHITE); im.setOutlinePaint(Color.BLACK); im.setOutlineStroke(new BasicStroke(1.0f)); plot.addDomainMarker(im, Layer.BACKGROUND); } } LegendTitle legend = chart.getLegend(); legend.setBackgroundPaint(new Color(229, 229, 229)); legend.setFrame( new LineBorder(new Color(213, 213, 213), new BasicStroke(1.0f), legend.getFrame().getInsets())); // only for non-logarithmic axes // range must be set after plot is created, otherwise nothing is drawn if (dataRange != null && !xAxisType.equals(AxisType.LOGARITHMIC)) { xAxis.setRange(dataRange.getLowerSeconds(), dataRange.getUpperSeconds()); } return chart; }
From source file:org.ietr.preesm.mapper.ui.stats.PerformancePlotter.java
/** * Creates a chart in order to plot the speed-ups. * // w ww . ja v a 2s. c o m * @return A chart. */ private JFreeChart createChart(String title) { // Creating display domain NumberAxis horizontalAxis = new NumberAxis("Number of operators"); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(horizontalAxis); // Creating the best speedups subplot this.speedups = new DefaultXYDataset(); final NumberAxis xAxis = new NumberAxis("speedups"); xAxis.setAutoRangeIncludesZero(false); XYSplineRenderer renderer = new XYSplineRenderer(); final XYPlot subplot = new XYPlot(this.speedups, null, xAxis, renderer); subplot.setBackgroundPaint(Color.white); subplot.setDomainGridlinePaint(Color.lightGray); subplot.setRangeGridlinePaint(Color.lightGray); plot.add(subplot); plot.setForegroundAlpha(0.5f); final JFreeChart chart = new JFreeChart(title, plot); chart.setBorderPaint(Color.white); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); return chart; }
From source file:opendial.gui.stateviewer.DistributionViewer.java
/** * Constructs a chart panel for the continuous distribution. * /*from ww w .j av a 2 s . c o m*/ * @param distrib the continuous distribution * @return the generated chart panel * @throws DialException if the distribution could not be displayed */ private ChartPanel generatePanel(ContinuousDistribution distrib) throws DialException { final String variableName = distrib.getVariable(); List<XYSeries> series = extractSeries(distrib.getFunction()); CombinedDomainXYPlot combined = new CombinedDomainXYPlot(new NumberAxis("Value")); for (XYSeries serie : series) { JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Value", // domain axis label "Density", // range axis label new XYSeriesCollection(serie), // data PlotOrientation.VERTICAL, // orientation (distrib.getFunction().getDimensionality() > 1), // include legend true, // tooltips? false); // URLs? XYPlot plot = (XYPlot) chart.getPlot(); combined.add(plot); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.white); } return new ChartPanel(new JFreeChart("Probability distribution P(" + variableName + ")", JFreeChart.DEFAULT_TITLE_FONT, combined, true), false); }