private void plotTradeBubblesOnChart(ArrayList<Integer> toPlot, String p, int k, int j) { final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0); final XYPlot plot = (XYPlot) main_plot; final TimeSeries series = new TimeSeries(p); ///* for(Integer i: toPlot) { switch(j) { case 0: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getOpen()); break; case 1: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getHigh()); break; case 2: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getLow()); break; case 3: series.add(new Minute(new Date(chartDatas.get(i).getStartTimeStamp())),chartDatas.get(i).getClose()); break; } } /* for (int i = 0; i < defaultHighLowDataset.getSeriesCount(); i++) { series.add(new Minute(defaultHighLowDataset.getXDate(0, i)),plot[i]); } */ XYDataset dataSet = new TimeSeriesCollection(series); plot.setDataset(k, dataSet); XYItemRenderer ir = new XYShapeRenderer(); //ir.s plot.setRenderer(k, ir); }
private void plotSeperate(XYDataset dataset, String p) { NumberAxis rangeAxis1 = new NumberAxis(p); rangeAxis1.setAutoRangeIncludesZero(false); // override default rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars DecimalFormat format = new DecimalFormat("0"); rangeAxis1.setNumberFormatOverride(format); final ValueAxis timeAxis = new DateAxis("Date"); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis1, null); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator( new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#") ) ); plot.setRenderer(0, renderer1); final CombinedDomainXYPlot cplot1 = (CombinedDomainXYPlot)this.candlestickChart.getPlot(); if (plot != null) cplot1.add(plot, 1); // weight is 1. }
public void raster(Collection<Spike> spikes,String title) { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); // Build a plot for each layer for (int i=0; i<net.nLayers(); i++) plot.add(layerRaster(spikes,net.lay(i)),1); JFreeChart chart= new JFreeChart("Raster: "+title,JFreeChart.DEFAULT_TITLE_FONT, plot,true); // Put it in a frame! JFrame fr=new JFrame(); fr.getContentPane().add(new ChartPanel(chart)); fr.setSize(1200,1000); fr.setVisible(true); }
public ChartPanel createGeneralChartPanel() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Generations")); plot.setGap(10.0); for (int i = 0; i < this.gCtrl.getNumOfSelectedObjectives(); i++) { XYPlot subp = this.createSubplot(i); this.subplots.add(subp); plot.add(subp); } plot.setOrientation(PlotOrientation.VERTICAL); LegendItemCollection chartLegend = new LegendItemCollection(); chartLegend.add(new LegendItem("Population range", null, null, null, new Rectangle(10, 10), blue)); chartLegend.add(new LegendItem("Generation average", null, null, null, new Rectangle(10, 1), stroke1, blue1)); chartLegend.add(new LegendItem("Absolute best", null, null, null, new Rectangle(10, 1), stroke2, blue2)); plot.setFixedLegendItems(chartLegend); return new ChartPanel(new JFreeChart("", plot)); }
/** * Check that only one chart change event is generated by a change to a * subplot. */ public void testNotification() { CombinedDomainXYPlot plot = createPlot(); JFreeChart chart = new JFreeChart(plot); chart.addChangeListener(this); XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); assertEquals(1, this.events.size()); // a redraw should NOT trigger another change event BufferedImage image = new BufferedImage(200, 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); this.events.clear(); chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); assertTrue(this.events.isEmpty()); }
public void slideChart(int increment, Rectangle2D plotarea) { CombinedDomainXYPlot combinedDomainXYPlot = (CombinedDomainXYPlot) jFreeChart.getXYPlot(); @SuppressWarnings("unchecked") List<XYPlot> subplots = combinedDomainXYPlot.getSubplots(); if (subplots.size() != 2) { return; } else { int upChartweight = subplots.get(0).getWeight(); int newUpChartWeight = upChartweight-increment; if (newUpChartWeight <= 0 || newUpChartWeight >= CHARTS_TOTAL_WEIGHT) return; subplots.get(0).setWeight(newUpChartWeight); int lowChartweight = subplots.get(1).getWeight(); int newLowChartWeight = lowChartweight+increment; if (newLowChartWeight <= 0 || newLowChartWeight >= CHARTS_TOTAL_WEIGHT) return; subplots.get(1).setWeight(newLowChartWeight); indicPlotWeight = newLowChartWeight; resetVerticalLines(plotarea); } }
public Boolean isSlidingArea(double chartY, double mouseY) { CombinedDomainXYPlot combinedDomainXYPlot = (CombinedDomainXYPlot) jFreeChart.getXYPlot(); @SuppressWarnings("unchecked") List<XYPlot> subplots = combinedDomainXYPlot.getSubplots(); double xAxisDim = 20; if (subplots.size() != 2) { return false; } else { double mousePos = mouseY/(chartY-xAxisDim); double slidingArea = (double)subplots.get(0).getWeight()/(double)CHARTS_TOTAL_WEIGHT; if (slidingArea + .01 >= mousePos && mousePos >= slidingArea - .01) { return true; } } return false; }
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); } 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; }
private void plotIndicatorOnChart(Double[] toPlot, String p, int k) { final Plot main_plot = (Plot)((CombinedDomainXYPlot)this.candlestickChart.getPlot()).getSubplots().get(0); final XYPlot plot = (XYPlot) main_plot; plot.setDataset(k, createIndicatorPlot(p,toPlot)); XYItemRenderer ir = new XYLineAndShapeRenderer(true,false); plot.setRenderer(k, ir); }
private JFreeChart createCandlestickChart(OHLCDataset priceOHLCDataset) { final String title = "Chart"; final ValueAxis timeAxis = new DateAxis("Date"); final NumberAxis valueAxis = new NumberAxis("Price"); valueAxis.setAutoRangeIncludesZero(false); valueAxis.setUpperMargin(0.0); valueAxis.setLowerMargin(0.0); XYPlot plot = new XYPlot(priceOHLCDataset, timeAxis, valueAxis, null); final CandlestickRenderer candlestickRenderer = new CandlestickRenderer(); plot.setRenderer(candlestickRenderer); //plot.getRangeAxis().setAutoRange(true); // Give good width when zoom in, but too slow in calculation. ((CandlestickRenderer)plot.getRenderer()).setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(timeAxis); cplot.add(plot, 3); cplot.setGap(8.0); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, cplot, true); applyChartTheme(chart); // Handle zooming event. chart.addChangeListener(this.getChartChangeListner()); return chart; }
/** * Returns the plot at the specified position in this chart dialog. * * @param index index of the plot to return * @return the plot at the specified position in this chart dialog */ public XYPlot getPlot(int index) { final JFreeChart chart = this.chartPanel.getChart(); final CombinedDomainXYPlot cplot = (CombinedDomainXYPlot) chart.getPlot(); final XYPlot plot = (XYPlot) cplot.getSubplots().get(index); return plot; }
/** * This is a test to replicate the bug report 987080. */ public void testRemoveSubplot() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(); XYPlot plot1 = new XYPlot(); XYPlot plot2 = new XYPlot(); plot.add(plot1); plot.add(plot2); // remove plot2, but plot1 is removed instead plot.remove(plot2); List plots = plot.getSubplots(); assertTrue(plots.get(0) == plot1); }
/** * Tests the equals() method. */ public void testEquals() { CombinedDomainXYPlot plot1 = createPlot(); CombinedDomainXYPlot plot2 = createPlot(); assertTrue(plot1.equals(plot2)); assertTrue(plot2.equals(plot1)); }
/** * Creates a sample plot. * * @return A sample plot. */ private CombinedDomainXYPlot createPlot() { // create subplot 1... XYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis("Range 1"); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... XYDataset data2 = createDataset2(); XYItemRenderer renderer2 = new StandardXYItemRenderer(); NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); return plot; }
/** * Creates a combined chart. * * @return the combined chart. */ private static JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis( "Range 1" ); final XYPlot subplot1 = new XYPlot( data1, null, rangeAxis1, renderer1 ); subplot1.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT ); final XYTextAnnotation annotation = new XYTextAnnotation( "Hello!", 50.0, 10000.0 ); annotation.setFont( new Font( "SansSerif", Font.PLAIN, 9 ) ); annotation.setRotationAngle( Math.PI / 4.0 ); subplot1.addAnnotation( annotation ); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis( "Range 2" ); rangeAxis2.setAutoRangeIncludesZero( false ); final XYPlot subplot2 = new XYPlot( data2, null, rangeAxis2, renderer2 ); subplot2.setRangeAxisLocation( AxisLocation.TOP_OR_LEFT ); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot( new NumberAxis( "Domain" ) ); plot.setGap( 10.0 ); // 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 ); }
/** * Sole constructor. */ public BSCombinedChart() { super( null, null, new CombinedDomainXYPlot(), CREATE_LEGEND ); // Energy plot... { _energyPlot = new BSEnergyPlot(); _energyPlot.setDomainAxis( null ); } // Wave Function plot... { _bottomPlot = new BSBottomPlot(); _bottomPlot.setDomainAxis( null ); } // Common X axis... BSPositionAxis positionAxis = new BSPositionAxis(); // Parent plot configuration... { CombinedDomainXYPlot plot = (CombinedDomainXYPlot) getPlot(); // Misc properties plot.setDomainAxis( positionAxis ); plot.setGap( CHART_SPACING ); plot.setOrientation( PlotOrientation.VERTICAL ); // Add the subplots, energy plot is twice the size of wave function plot. plot.add( _energyPlot, 2 ); plot.add( _bottomPlot, 1 ); } }
private static JFreeChart createCombinedChart() { // create subplot 1... final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis( "Range 1" ); final XYPlot subplot1 = new XYPlot( createDataset1(), null, rangeAxis1, renderer1 ); subplot1.setRangeAxisLocation( AxisLocation.BOTTOM_OR_LEFT ); final XYTextAnnotation annotation = new XYTextAnnotation( "Hello!", 50.0, 10000.0 ); annotation.setFont( new Font( "SansSerif", Font.PLAIN, 9 ) ); annotation.setRotationAngle( Math.PI / 4.0 ); subplot1.addAnnotation( annotation ); // create subplot 2... final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis( "Range 2" ); rangeAxis2.setAutoRangeIncludesZero( false ); final XYPlot subplot2 = new XYPlot( createDataset2(), null, rangeAxis2, renderer2 ); subplot2.setRangeAxisLocation( AxisLocation.TOP_OR_LEFT ); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot( new NumberAxis( "Domain" ) ); plot.setGap( 10.0 ); // 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 ); }
private ChartPanel getChartPanel() { if (chartPanel == null) { CombinedDomainXYPlot combinedDomainXYPlot = getCombinedDomainXYPlot(); JFreeChart jFreeChart = new JFreeChart(filename, JFreeChart.DEFAULT_TITLE_FONT, combinedDomainXYPlot, false); ChartUtilities.applyCurrentTheme(jFreeChart); // customise the title position and font TextTitle t = jFreeChart.getTitle(); t.setHorizontalAlignment(HorizontalAlignment.CENTER); t.setPaint(Color.DARK_GRAY); t.setFont(new Font("Arial", Font.BOLD, 12)); t.setPadding(10, 10, 5, 10); chartPanel = new ChartPanel(jFreeChart); chartPanel.setMinimumDrawWidth(0); chartPanel.setMinimumDrawHeight(0); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMouseWheelEnabled(true); LogTableModel logTableModel = (LogTableModel) logTable.getModel(); NavigationTableController<Integer> navigationTableController; navigationTableController = new NavigationTableController<Integer>(logTableModel); navigationTableController.addCustomJTable(logTable); chartPanel.addChartMouseListener( new CombinedDomainXYPlotMouseListener(chartPanel, logTableModel, navigationTableController)); chartPanel.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY, 1)); } return chartPanel; }
/** * Creates a combined chart. * * @return The combined chart. */ private JFreeChart createCombinedChart(DataSequence tsOne, DataSequence tsTwo, ArrayList<Anomaly> anomalyList) { // create subplot 1. final XYDataset data1 = createDataset(tsOne, "Original"); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Original Value"); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // plot anomalies on subplot 1. addAnomalies(subplot1, anomalyList); // create subplot 2. final XYDataset data2 = createDataset(tsTwo, "Forecast"); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Forecast Value"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot. final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Time")); plot.setGap(10.0); // add the subplots. plot.add(subplot1, 1); plot.add(subplot2, 1); // Add anomaly score time-series. addAnomalyTS(plot, tsOne, tsTwo); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot. return new JFreeChart("EGADS GUI", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
/** * Compute the time-series of anomalies. */ public void addAnomalyTS(CombinedDomainXYPlot plot, DataSequence observedSeries, DataSequence expectedSeries) { // Compute the time-series of errors. HashMap<String, ArrayList<Float>> allErrors = aes.initAnomalyErrors(observedSeries, expectedSeries); Float sDAutoSensitivity = (float) 0.0; Float amntAutoSensitivity = (float) 0.0; if (config.getProperty("AUTO_SENSITIVITY_ANOMALY_PCNT") != null) { amntAutoSensitivity = new Float(config.getProperty("AUTO_SENSITIVITY_ANOMALY_PCNT")); } if (config.getProperty("AUTO_SENSITIVITY_SD") != null) { sDAutoSensitivity = new Float(config.getProperty("AUTO_SENSITIVITY_SD")); } String errorDebug = ""; for (int i = 0; i < (aes.getIndexToError().keySet()).size(); i++) { Float[] fArray = (allErrors.get(aes.getIndexToError().get(i))).toArray(new Float[(allErrors.get(aes.getIndexToError().get(i))).size()]); XYDataset data1 = createDataset(fArray, aes.getIndexToError().get(i)); XYItemRenderer renderer1 = new StandardXYItemRenderer(); NumberAxis rangeAxis1 = new NumberAxis(aes.getIndexToError().get(i)); XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); // Get threshold. Float d = AutoSensitivity.getLowDensitySensitivity(fArray, sDAutoSensitivity, amntAutoSensitivity); subplot1.addRangeMarker(new ValueMarker(d)); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.add(subplot1, 1); errorDebug += aes.getIndexToError().get(i) + ": " + d + " "; } System.out.println(errorDebug); }
/** * Creates new form BookReporterResultFrame */ public BookReporterResultFrame() { initComponents(); exportDialog = new BookReporterChartExportDialog(this, true); plot = new CombinedDomainXYPlot(); chart = new JFreeChart(plot); colors = new HashMap<String, Paint>(); tags = null; chart.setBackgroundPaint(Color.WHITE); ChartPanel chartPanel = new ChartPanel(chart); chartPanelContainer.add(chartPanel); }
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; }
/** * Creates a combined chart. * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // 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); }
public static void setColors(ChartPanel panel, Color[] colors) { Plot plot = panel.getChart().getPlot(); if (plot instanceof XYPlot) { setColors((XYPlot)plot, colors); return; } CombinedDomainXYPlot plotCombined = (CombinedDomainXYPlot)plot; java.util.List list = (plotCombined).getSubplots(); for (int i = 0; i < list.size(); i++) setColors((XYPlot)list.get(i), colors); }
private JFreeChart createChart() { final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); final ClusteredXYBarRenderer barRenderer = new ClusteredXYBarRenderer(); final GradientPaint black = new GradientPaint(0.0f, 0.0f, Color.black, 0.0f, 0.0f, Color.black); final TimeSeries seriests = new TimeSeries("Series"); final TimeSeries seasonalts = new TimeSeries("Seasonal"); final TimeSeries trendts = new TimeSeries("Trend"); final TimeSeries remainderts = new TimeSeries("Remainder"); final TimeSeries[] tsArray = new TimeSeries[]{seriests, seasonalts, trendts}; final String[] labels = new String[]{"Series", "Seasonal", "Trend"}; for (int i = 0; i < series.length; i++) { final Date d = new Date((long) times[i]); RegularTimePeriod rtp = RegularTimePeriod.createInstance(this.timePeriod, d, TimeZone.getDefault()); seriests.addOrUpdate(rtp, series[i]); seasonalts.addOrUpdate(rtp, seasonal[i]); trendts.addOrUpdate(rtp, trend[i]); remainderts.addOrUpdate(rtp, remainder[i]); } plot.setGap(10.0); renderer.setSeriesPaint(0, black); barRenderer.setSeriesPaint(0, black); plot.setOrientation(PlotOrientation.VERTICAL); for (int i = 0; i < tsArray.length; i++) { final XYDataset ts = new TimeSeriesCollection(tsArray[i]); final XYPlot p = new XYPlot(ts, new DateAxis(labels[i]), new NumberAxis(labels[i]), renderer); plot.add(p); } final XYDataset rts = new TimeSeriesCollection(remainderts); final XYDataset sts = new TimeSeriesCollection(seriests); final XYDataset tts = new TimeSeriesCollection(trendts); final XYPlot rplot = new XYPlot(rts, new DateAxis(), new NumberAxis("Remainder"), barRenderer); final XYPlot seriesAndTrend = new XYPlot(sts, new DateAxis(), new NumberAxis("S & T"), renderer); seriesAndTrend.setDataset(1, tts); seriesAndTrend.setRenderer(1, renderer); plot.add(rplot); plot.add(seriesAndTrend); return new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
public XYPlot getPlot() { final JFreeChart chart = this.chartPanel.getChart(); final CombinedDomainXYPlot cplot = (CombinedDomainXYPlot) chart.getPlot(); final XYPlot plot = (XYPlot) cplot.getSubplots().get(0); return plot; }
/** * Returns the number of plots in this chart dialog. * * @return the number of plots in this chart dialog */ public int getPlotSize() { final JFreeChart chart = this.chartPanel.getChart(); final CombinedDomainXYPlot cplot = (CombinedDomainXYPlot) chart.getPlot(); return cplot.getSubplots().size(); }
/** * Confirm that the constructor will accept a null axis. */ public void testConstructor1() { CombinedDomainXYPlot plot = new CombinedDomainXYPlot(null); assertEquals(null, plot.getDomainAxis()); }
JFreeChart ChartMeds(Integer demographicNo,String patientName, String chartTitle,String[] drugs) { MiscUtils.getLogger().debug("In ChartMeds"); org.jfree.data.time.TimeSeriesCollection dataset = new org.jfree.data.time.TimeSeriesCollection(); JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Days", "MEDS", dataset, true, true, true); XYPlot plot = chart.getXYPlot(); // plot.getDomainAxis().setAutoRange(true); // Range rang = plot.getDataRange(plot.getRangeAxis()); // // log.debug("LEN " + plot.getDomainAxis().getLowerBound() + " ddd " + plot.getDomainAxis().getUpperMargin() + " eee " + plot.getDomainAxis().getLowerMargin()); // plot.getDomainAxis().setUpperMargin(plot.getDomainAxis().getUpperMargin()*6); // plot.getDomainAxis().setLowerMargin(plot.getDomainAxis().getLowerMargin()*6); // plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin()*1.7); // // plot.getDomainAxis().setUpperMargin(0.9); // plot.getDomainAxis().setLowerMargin(0.9); // plot.getRangeAxis().setUpperMargin(plot.getRangeAxis().getUpperMargin() * 4); XYTaskDataset drugDataset = getDrugDataSet( demographicNo,drugs); SymbolAxis yAxis = new SymbolAxis("Meds", getDrugSymbol(demographicNo,drugs)); yAxis.setGridBandsVisible(false); XYBarRenderer xyrenderer = new XYBarRenderer(); xyrenderer.setUseYInterval(true); xyrenderer.setBarPainter(new StandardXYBarPainter()); //XYPlot xyplot = new XYPlot(drugDataset, xAxis, yAxis, xyrenderer); XYPlot xyplot = new XYPlot(drugDataset, plot.getDomainAxis(), yAxis, xyrenderer); xyplot.getDomainAxis().setUpperMargin(0.9); xyplot.getDomainAxis().setLowerMargin(0.9); CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(new DateAxis("Date/Time")); cplot.add(xyplot); chart = new JFreeChart(chartTitle,cplot); chart.setBackgroundPaint(Color.white); return chart; }