List of usage examples for org.jfree.chart.axis ValueAxis setFixedAutoRange
public void setFixedAutoRange(double length)
From source file:pharoslabut.logger.CompassLoggerGUI.java
/** * Creates a new demo.//from www. ja v a 2 s.co m * * @param title the frame title. */ public CompassLoggerGUI(final String title) { super(title); final XYDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60); // 60 seconds final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); // new Thread(new ChartUpdater(chart.getXYPlot())).start(); }
From source file:org.rioproject.examples.hospital.ui.PatientStatsPanel.java
private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataSet, Color color) { JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", dataSet, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.getRenderer().setSeriesPaint(0, color); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setRange(0, 150);//ww w. j a va2 s . com ValueAxis xAxis = plot.getDomainAxis(); xAxis.setAutoRange(true); xAxis.setFixedAutoRange(5 * MINUTE); return chart; }
From source file:edu.utexas.ece.pharos.proteus3.sensors.CompassChartGUI.java
/** * Creates a new demo./*from w w w . j av a 2 s . co m*/ * * @param title the frame title. */ public CompassChartGUI(final String title) { super(title); final XYDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60); // 60 seconds final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); // new Thread(new ChartUpdater(chart.getXYPlot())).start(); }
From source file:org.jfree.chart.demo.DynamicDataDemo2.java
/** * Constructs a new demonstration application. * * @param title the frame title.//from w w w .j a va 2s .c om */ public DynamicDataDemo2(final String title) { super(title); this.series1 = new TimeSeries("Random 1", Millisecond.class); this.series2 = new TimeSeries("Random 2", Millisecond.class); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Dynamic Data Demo 2", "Time", "Value", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds plot.setDataset(1, dataset2); final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(1, new DefaultXYItemRenderer()); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JButton button1 = new JButton("Add To Series 1"); button1.setActionCommand("ADD_DATA_1"); button1.addActionListener(this); final JButton button2 = new JButton("Add To Series 2"); button2.setActionCommand("ADD_DATA_2"); button2.addActionListener(this); final JButton button3 = new JButton("Add To Both"); button3.setActionCommand("ADD_BOTH"); button3.addActionListener(this); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(content); }
From source file:org.jfree.chart.demo.DynamicDataDemo3.java
/** * Constructs a new demonstration application. * * @param title the frame title./*from w ww . ja v a2s . c o m*/ */ public DynamicDataDemo3(final String title) { super(title); final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time")); this.datasets = new TimeSeriesCollection[SUBPLOT_COUNT]; for (int i = 0; i < SUBPLOT_COUNT; i++) { this.lastValue[i] = 100.0; final TimeSeries series = new TimeSeries("Random " + i, Millisecond.class); this.datasets[i] = new TimeSeriesCollection(series); final NumberAxis rangeAxis = new NumberAxis("Y" + i); rangeAxis.setAutoRangeIncludesZero(false); final XYPlot subplot = new XYPlot(this.datasets[i], null, rangeAxis, new StandardXYItemRenderer()); subplot.setBackgroundPaint(Color.lightGray); subplot.setDomainGridlinePaint(Color.white); subplot.setRangeGridlinePaint(Color.white); plot.add(subplot); } final JFreeChart chart = new JFreeChart("Dynamic Data Demo 3", plot); // chart.getLegend().setAnchor(Legend.EAST); chart.setBorderPaint(Color.black); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JPanel buttonPanel = new JPanel(new FlowLayout()); for (int i = 0; i < SUBPLOT_COUNT; i++) { final JButton button = new JButton("Series " + i); button.setActionCommand("ADD_DATA_" + i); button.addActionListener(this); buttonPanel.add(button); } final JButton buttonAll = new JButton("ALL"); buttonAll.setActionCommand("ADD_ALL"); buttonAll.addActionListener(this); buttonPanel.add(buttonAll); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(content); }
From source file:org.vrjuggler.perfmon.PerformanceMonitorGUI.java
private JFreeChart createTimeSeriesChart(TimeSeriesCollection dataset) { JFreeChart result = ChartFactory.createTimeSeriesChart("Performance Monitoring Statistics", "Time", "Sample", dataset, true, true, false); XYPlot plot = result.getXYPlot();// www . j a v a2 s . c o m ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setAutoRange(true); //axis.setRange( 0.0, 10.0 ); return result; }
From source file:com.xilinx.kintex7.DMATrendChart.java
public void makeChart() { series1 = new TimeSeries(seriesLabels[0]); series2 = new TimeSeries(seriesLabels[1]); series3 = new TimeSeries(seriesLabels[2]); dataset = new TimeSeriesCollection(); dataset.addSeries(series1);/* w w w. j av a2 s . c o m*/ dataset.addSeries(series2); dataset.addSeries(series3); chart = ChartFactory.createTimeSeriesChart(title, "Time", "Throughput(Gbps)", dataset, true, true, false); chart.setBackgroundPaint(bg); final XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(30000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(0.0, 30.0); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); //StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator("{1}", null, null); //renderer.setSeriesToolTipGenerator(0, tt); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); plot.setRenderer(renderer); final XYPlot plot1 = chart.getXYPlot(); ValueAxis axis1 = plot1.getDomainAxis(); axis1.setAutoRange(true); axis1.setFixedAutoRange(30000.0); // 60 seconds axis1 = plot.getRangeAxis(); axis1.setRange(0.0, 30.0); plot1.setRenderer(renderer); final XYPlot plot2 = chart.getXYPlot(); ValueAxis axis2 = plot1.getDomainAxis(); axis2.setAutoRange(true); axis2.setFixedAutoRange(30000.0); // 60 seconds axis2 = plot.getRangeAxis(); axis2.setRange(0.0, 30.0); plot2.setRenderer(renderer); }
From source file:serverrobot.DynamicGraph.java
public JFreeChart createChart(XYDataset dataset, String pos, double minRange, double maxRange) { final JFreeChart chart = ChartFactory.createTimeSeriesChart(pos, "Time (ms)", "Displacement", dataset, true, true, false);/*from w w w .j a v a 2 s. c om*/ final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(232, 232, 232)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); plot.getRenderer().setSeriesPaint(0, Color.BLUE); plot.getRenderer().setSeriesPaint(1, Color.RED); ValueAxis axis = plot.getDomainAxis(); //axis.setAutoRange(true); axis.setFixedAutoRange(20000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(minRange, maxRange); chart.setBackgroundPaint(Color.white); return chart; }
From source file:arduinoserialread.SerialRead.java
private void initGUI() { // init the frame frame.setTitle("Arduino Serial Read"); frame.setBounds(100, 100, 600, 500); frame.setMinimumSize(new Dimension(600, 500)); frame.setLocationRelativeTo(null);/*from w ww .j av a2 s . c o m*/ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // init control panel JPanel ctrlPanel = new JPanel(); ctrlPanel.setLayout(new FlowLayout()); // init the serial connection panel serialCOM = new SerialConnectionPanel(); ctrlPanel.add(serialCOM); frame.getContentPane().add(ctrlPanel, BorderLayout.SOUTH); // init the connection status ConnectionStatus connectionStatus = new ConnectionStatus(); ctrlPanel.add(connectionStatus); // init connect and disconnect button connect = new JButton("connect"); ctrlPanel.add(connect); disconnect = new JButton("disconnect"); ctrlPanel.add(disconnect); // init real time chart TimeSeries series = new TimeSeries("DATA"); DateAxis timeAxis = new DateAxis("Time"); dataset = new TimeSeriesCollection(series); NumberAxis rangeAxis = new NumberAxis("Data"); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setAutoRange(true); XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis, new StandardXYItemRenderer()); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.getRenderer().setSeriesPaint(0, new Color(0, 142, 192)); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setFixedAutoRange(30000.0); // 30 seconds // init the JFreeChart JFreeChart chart = new JFreeChart("Real-Time Data Chart", plot); chart.setBorderPaint(Color.lightGray); chart.setBorderVisible(true); chart.setBackgroundPaint(Color.white); chart.removeLegend(); // add real time chart to the frame ChartPanel chartPanel = new ChartPanel(chart); frame.getContentPane().add(chartPanel, BorderLayout.CENTER); }
From source file:ch.epfl.leb.sass.ijplugin.SimulatorStatusFrame.java
/** * Creates a new status frame./*from w ww .j av a 2 s . com*/ * * @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); }