List of usage examples for org.jfree.chart.plot CombinedDomainXYPlot CombinedDomainXYPlot
public CombinedDomainXYPlot(ValueAxis domainAxis)
From source file:grafix.graficos.ConstrutorGrafico.java
public JFreeChart criarJFreeChart() { //*debug*/ System.out.println("[PROFILE] criarJFreeChart() - " + janela.getAcao().getCodAcao()); DateAxis domainAxis = getEixoHorizontal(); CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(domainAxis); adicionarPlots(cplot);//from w ww . jav a 2s . c om configurarEixoHorizontal(domainAxis); JFreeChart chart = new JFreeChart(cplot); configurarGrafico(chart); return chart; }
From source file:de.berlios.statcvs.xml.chart.AbstractCombinedChart.java
/** * @param settings//from ww w . j a v a2 s.c om * @param defaultFilename * @param defaultSubtitle */ public AbstractCombinedChart(ReportSettings settings, String defaultFilename, String defaultSubtitle) { super(settings, defaultFilename, defaultSubtitle); ValueAxis domainAxis = new DateAxis(I18n.tr("Date")); domainAxis.setVerticalTickLabels(true); combinedPlot = new CombinedDomainXYPlot(domainAxis); combinedPlot.setGap(10); combinedPlot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(settings.getProjectName(), JFreeChart.DEFAULT_TITLE_FONT, combinedPlot, false); setChart(chart); }
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:br.prof.salesfilho.oci.image.GraphicBuilder.java
public void createCombinedChart(Map<String, double[]> mapSeries, String legendTitle) { XYSeriesCollection xds;//ww w .j a v a 2 s . c om final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis(legendTitle)); plot.setGap(10.0); for (Map.Entry<String, double[]> entrySet : mapSeries.entrySet()) { String serieName = entrySet.getKey(); double[] values = entrySet.getValue(); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); final XYSeries series = new XYSeries(serieName); for (int i = 0; i < values.length; i++) { series.add(i, Precision.round(values[i], 2)); renderer.setSeriesVisible(i, true, true); renderer.setSeriesShapesVisible(i, true); } xds = new XYSeriesCollection(); xds.addSeries(series); final NumberAxis rangeAxis = new NumberAxis(serieName); final XYPlot subplot = new XYPlot(xds, null, rangeAxis, renderer); subplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.add(subplot); } this.chart = new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chartPanel.setChart(chart); }
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 w w . j a v a2 s .c om*/ 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:net.pickapack.chart.LinePlotFrame.java
/** * Create a line plot frame./*from ww w . j a va 2 s . c o m*/ * * @param linePlot the line plot * @param width the width * @param height the height */ public LinePlotFrame(LinePlot linePlot, int width, int height) { super(linePlot.getTitle()); this.linePlot = linePlot; this.numSubPlots = linePlot.getSubLinePlots().size(); CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.dataSets = new ArrayList<TimeSeriesCollection>(); this.dataSinks = new ArrayList<Map<SubLinePlotLine, Function<Double>>>(); for (SubLinePlot subLinePlot : linePlot.getSubLinePlots()) { TimeSeriesCollection dataSetsPerSubPlot = new TimeSeriesCollection(); this.dataSets.add(dataSetsPerSubPlot); HashMap<SubLinePlotLine, Function<Double>> dataSinksPerSubPlot = new HashMap<SubLinePlotLine, Function<Double>>(); this.dataSinks.add(dataSinksPerSubPlot); for (SubLinePlotLine subLinePlotLine : subLinePlot.getLines()) { TimeSeries timeSeries = new TimeSeries(subLinePlotLine.getTitle()); dataSetsPerSubPlot.addSeries(timeSeries); dataSinksPerSubPlot.put(subLinePlotLine, subLinePlotLine.getGetValueCallback()); } NumberAxis rangeAxis = new NumberAxis(subLinePlot.getTitleY()); rangeAxis.setAutoRangeIncludesZero(false); XYPlot subplot = new XYPlot(dataSetsPerSubPlot, null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); } JFreeChart chart = new JFreeChart(linePlot.getTitle(), plot); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(3600000.0); JPanel content = new JPanel(new BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); DataSink dataSink = new DataSink(); new Thread(dataSink).start(); }
From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java
/** * Creates a new status frame./*ww w .ja v a2 s. c o m*/ * * @param groundTruthYLabel The y-axis label for the ground truth signal. * @param analyzerYLabel The units output by the analyzer. * @param setpointYLabel The units of the controller setpoint. * @param outputYLabel The units output by the controller. */ public SimulatorStatusFrame(String groundTruthYLabel, String analyzerYLabel, String setpointYLabel, String outputYLabel) { String seriesLabel = ""; String yLabel = ""; CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(new NumberAxis("Simulation Outputs")); Font yLabelFont = new Font("Dialog", Font.PLAIN, 10); datasets = new XYSeriesCollection[4]; for (int i = 0; i < SUBPLOT_COUNT; i++) { switch (i) { case 0: seriesLabel = "True density"; yLabel = groundTruthYLabel; break; case 1: seriesLabel = "Analyzer output"; yLabel = analyzerYLabel; break; case 2: seriesLabel = "Setpoint"; yLabel = setpointYLabel; break; case 3: seriesLabel = "Controller output"; yLabel = outputYLabel; break; } XYSeries timeseries = new XYSeries(seriesLabel); datasets[i] = new XYSeriesCollection(timeseries); NumberAxis numberaxis = new NumberAxis(yLabel); numberaxis.setAutoRangeIncludesZero(false); numberaxis.setNumberFormatOverride(new DecimalFormat("###0.00")); XYPlot xyplot = new XYPlot(datasets[i], null, numberaxis, new StandardXYItemRenderer()); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.getRangeAxis().setLabelFont(yLabelFont); combineddomainxyplot.add(xyplot); } JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, combineddomainxyplot, true); jfreechart.setBorderPaint(Color.black); jfreechart.setBorderVisible(true); jfreechart.setBackgroundPaint(Color.white); combineddomainxyplot.setBackgroundPaint(Color.lightGray); combineddomainxyplot.setDomainGridlinePaint(Color.white); combineddomainxyplot.setRangeGridlinePaint(Color.white); ValueAxis valueaxis = combineddomainxyplot.getDomainAxis(); valueaxis.setAutoRange(true); // Number of frames to display valueaxis.setFixedAutoRange(2000D); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(800, 500)); chartpanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); chartpanel.setVisible(true); JPanel jPanel = new JPanel(); jPanel.setLayout(new BorderLayout()); jPanel.add(chartpanel, BorderLayout.NORTH); setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); add(jPanel); pack(); setVisible(true); }
From source file:net.sf.mzmine.chartbasics.gui.javafx.demo.FXCombinedChartGestureDemo.java
private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); // create subplot 2... final XYDataset data2 = createDataset(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0);/*from ww w . j a v a 2 s . c o m*/ // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.codehaus.mojo.chronos.chart.ChartUtil.java
static CombinedDomainXYPlot createCombinedPlot(DateAxis timeAxis, XYPlot xyplot1, XYPlot xyplot2) { CombinedDomainXYPlot combineddomainxyplot = new CombinedDomainXYPlot(timeAxis); combineddomainxyplot.setGap(GAP);// w w w. jav a2 s . c o m combineddomainxyplot.add(xyplot1, 2); combineddomainxyplot.add(xyplot2, 1); combineddomainxyplot.setOrientation(PlotOrientation.VERTICAL); return combineddomainxyplot; }
From source file:org.jtotus.gui.graph.GraphPrinter.java
private JFreeChart createChart(String title) { // valueAxis.setAutoRangeMinimumSize(1); DateAxis domain = new DateAxis("Date"); domain.setDateFormatOverride(new SimpleDateFormat("dd-MM-yyyy")); mainPlot = new CombinedDomainXYPlot(domain); mainPlot.setGap(4.0);/* ww w .j a v a 2 s . co m*/ //mainPlot.setOrientation(PlotOrientation.HORIZONTAL); mainPlot.setBackgroundPaint(Color.lightGray); mainPlot.setRangePannable(true); mainPlot.setDomainGridlinesVisible(true); mainPlot.setOutlineVisible(true); mainPlot.setDomainCrosshairVisible(true); mainPlot.setRangeMinorGridlinesVisible(true); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true); chart.setBackgroundPaint(Color.white); return chart; }