List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:DynamicDataDemo.java
/** * Creates a sample chart.//from w w w. j a v a 2s. co m * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset, String title, String xcoor, String ycoor) { final JFreeChart result = ChartFactory.createTimeSeriesChart(title, xcoor, ycoor, dataset, true, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(60000.0); // 60 seconds axis = plot.getRangeAxis(); axis.setRange(0.0, 500.0); return result; }
From source file:LowPassFilterTest.java
@Test public void test() throws InterruptedException { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);//w w w . j a v a 2 s. c om double step = 1.0 / discretization; double startPosition = step * framePosition; //100 ? - 100 , 50 ? - 50 , 25 ?- 25 double[] data = math.convolve( math.HammingWindow(testData.get1DPolyharmSignal(4, 200, frameWidth, discretization), frameWidth), math.lpf(60, step, 1024)); // double[] data = math.convolve(testData.get1DSignal(100, 200, frameWidth, discretization), math.lpf(70, step, 128)); // double[] data = math.convolve(testData.get1DSignal(100, 200, 32768, 10000), math.lpf(70, 1./10000, 32)); // double[] data = testData.get1DSignal(100, 200, frameWidth, discretization); // double[] data = math.lpf(70, step,128); for (int i = 0; i < data.length; i++) { serie.add(startPosition, data[i], ""); startPosition += step; } JFreeChart chart = ChartFactory.createXYLineChart("", "t,c", "g, /c^2", serie); chart.removeLegend(); chart.setAntiAlias(false); XYPlot plot = chart.getXYPlot(); //plot.setRangeGridlinePaint(Color.BLACK); org.jfree.chart.axis.ValueAxis yAxis = plot.getRangeAxis(); org.jfree.chart.axis.ValueAxis xAxis = plot.getDomainAxis(); double start = framePosition * 1.0 / discretization; double max = start + frameWidth * 1.0 / discretization; xAxis.setRange(start, max); ChartPanel chartPanel = new ChartPanel(chart); JPanel p = new JPanel(new BorderLayout()); p.removeAll(); p.add(chartPanel); p.validate(); //1. Create the frame. JFrame frame = new JFrame("FrameDemo"); //2. Optional: What happens when the frame closes? frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //3. Create components and put them in the frame. //...create emptyLabel... frame.getContentPane().add(new Label("olol"), BorderLayout.CENTER); frame.getContentPane().add(p, BorderLayout.CENTER); //4. Size the frame. frame.pack(); //5. Show it. frame.setVisible(true); }
From source file:mls.FramePlot.java
private JFreeChart createChartVarianza(final XYDataset datasetVarianza) { final JFreeChart result = ChartFactory.createXYLineChart("Varianza campionaria", "n", "vc", datasetVarianza, PlotOrientation.VERTICAL, false, true, false); final XYPlot plot = result.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true);/*from w ww. j av a 2s .co m*/ axis.setFixedAutoRange(1500); axis = plot.getRangeAxis(); axis.setAutoRange(true); axis.setRange(10, 100); plot.getRenderer().setSeriesPaint(0, Color.MAGENTA); return result; }
From source file:br.com.criativasoft.opendevice.samples.ui.SimpleChart.java
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart(TITLE, "mm:ss", "Value", dataset, true, true, false);/*from www .ja v a2 s. c om*/ final XYPlot plot = result.getXYPlot(); plot.setBackgroundPaint(Color.white); ValueAxis domain = plot.getDomainAxis(); domain.setAutoRange(true); ValueAxis range = plot.getRangeAxis(); range.setRange(0, MINMAX); range.setAutoRangeMinimumSize(20); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); for (int i = 0; i < SERIES; i++) { renderer.setSeriesStroke(i, new BasicStroke(2.0f)); } return result; }
From source file:org.webcat.grader.graphs.BoxAndWhiskerChart.java
@Override protected JFreeChart generateChart(WCChartTheme chartTheme) { setChartHeight(36);/*from w w w . j av a2 s. co m*/ JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, yAxisLabel(), boxAndWhiskerXYDataset(), false); chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL); chart.setPadding(new RectangleInsets(0, 6, 0, 6)); XYPlot plot = chart.getXYPlot(); plot.setInsets(RectangleInsets.ZERO_INSETS); plot.setOutlineVisible(false); plot.setBackgroundPaint(new Color(0, 0, 0, 0)); XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer(); renderer.setAutoPopulateSeriesOutlinePaint(true); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setVisible(false); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(-0.5, assignmentOffering.assignment().submissionProfile().availablePoints() + 0.5); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); Font oldFont = rangeAxis.getTickLabelFont(); rangeAxis.setTickLabelFont(oldFont.deriveFont(oldFont.getSize2D() * 0.8f)); return chart; }
From source file:org.jfree.chart.demo.ChartTiming3.java
/** * Runs the test.//ww w. ja v a 2 s.co m */ public void run() { this.finished = false; // create a dataset... final XYSeries series = new XYSeries("Random Data"); for (int i = 0; i < 1440; i++) { final double x = Math.random(); final double y = Math.random(); series.add(x, y); } final XYDataset data = new XYSeriesCollection(series); // create a scatter chart... final boolean withLegend = true; final JFreeChart chart = ChartFactory.createScatterPlot("Scatter plot timing", "X", "Y", data, PlotOrientation.VERTICAL, withLegend, false, false); final XYPlot plot = chart.getXYPlot(); plot.setRenderer(new XYDotRenderer()); final BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_INT_RGB); final Graphics2D g2 = image.createGraphics(); final Rectangle2D chartArea = new Rectangle2D.Double(0, 0, 400, 300); // set up the timer... final Timer timer = new Timer(10000, this); timer.setRepeats(false); int count = 0; timer.start(); while (!this.finished) { chart.draw(g2, chartArea, null, null); System.out.println("Charts drawn..." + count); if (!this.finished) { count++; } } System.out.println("DONE"); }
From source file:playground.thibautd.utils.charts.ChartsAxisUnifier.java
public void addChart(final JFreeChart chart) { charts.add(chart);// w w w. ja v a 2 s . com if (unifyX) { Plot plot = chart.getPlot(); if (plot instanceof XYPlot) { ValueAxis axis = chart.getXYPlot().getDomainAxis(); Range range = axis.getRange(); lowerX = Math.min(lowerX, range.getLowerBound()); upperX = Math.max(upperX, range.getUpperBound()); } } if (unifyY) { Plot plot = chart.getPlot(); ValueAxis axis; if (plot instanceof XYPlot) { axis = chart.getXYPlot().getRangeAxis(); } else if (plot instanceof CategoryPlot) { axis = chart.getCategoryPlot().getRangeAxis(); } else { return; } Range range = axis.getRange(); lowerY = Math.min(lowerY, range.getLowerBound()); upperY = Math.max(upperY, range.getUpperBound()); } }
From source file:Business.Chart.ChartHeartRate.java
public ChartHeartRate(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) { super(applicationTitle); series = new TimeSeries("Heart Rate"); this.workRequest = workRequest; this.chartTitle = chartTitle; final XYDataset dataset = createDatasetHeartRate(workRequest); final JFreeChart chart = createChart(dataset); //final XYDataset dataset1 = createDatasetBloodPressure(workRequest ); //final JFreeChart chart1 = createChart1( dataset1 ); final XYPlot plot = chart.getXYPlot(); HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest; int age = hos1.getPerson().getAge(); int a = hos1.getPerson().getAboveHeartRateMarker(age); int b = hos1.getPerson().getBelowHeartRateMarker(age); ValueMarker valueMarker = new ValueMarker(a); valueMarker.setLabel("ALERT"); valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker.setPaint(Color.blue); ValueMarker valueMarker1 = new ValueMarker(b); valueMarker1.setLabel("ALERT"); valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker1.setPaint(Color.BLUE); plot.addRangeMarker(valueMarker);//from w ww. j a v a 2 s . c o m plot.addRangeMarker(valueMarker1); //ChartFrame frame = new ChartFrame("series chart", chart); // frame.setVisible(true); // frame.setSize(450, 350); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 370)); chartPanel.setMouseZoomable(true, false); setContentPane(chartPanel); getContentPane().repaint(); }
From source file:loadmaprenderer.ResultDisplayChart.java
private JFreeChart makeChart(XYDataset dataset, String chartTitle, String dataTitle) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, "Year", dataTitle, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.BLUE); plot.setRangeGridlinePaint(Color.BLUE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer);// w w w . j a va2 s. c o m NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); Double range = dataLine.getMaxY() - dataLine.getMinY(); if (Math.abs(range) < 0.1) range = dataLine.getMaxY(); rangeAxis.setRange(dataLine.getMinY() - range * 0.1, dataLine.getMaxY() + range * 0.1); return chart; }
From source file:Business.Chart.ChartBloodPressure.java
public ChartBloodPressure(final String applicationTitle, String chartTitle, HospitalWorkRequest workRequest) { super(applicationTitle); series6 = new TimeSeries("Blood Pressure"); this.workRequest = workRequest; this.chartTitle = chartTitle; final XYDataset dataset6 = createDatasetBloodPressure(workRequest); final JFreeChart chart6 = createChart(dataset6); //final XYDataset dataset1 = createDatasetBloodPressure(workRequest ); //final JFreeChart chart1 = createChart1( dataset1 ); final XYPlot plot = chart6.getXYPlot(); HospitalWorkRequest hos1 = (HospitalWorkRequest) workRequest; int age = hos1.getPerson().getAge(); int a = hos1.getPerson().getAboveBPMarker(age); int b = hos1.getPerson().getBelowBPMarker(age); ValueMarker valueMarker = new ValueMarker(a); valueMarker.setLabel("ALERT"); valueMarker.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker.setPaint(Color.blue); ValueMarker valueMarker1 = new ValueMarker(b); valueMarker1.setLabel("ALERT"); valueMarker1.setLabelTextAnchor(TextAnchor.TOP_CENTER); valueMarker1.setPaint(Color.BLUE); plot.addRangeMarker(valueMarker);//from w ww. jav a 2 s . c o m plot.addRangeMarker(valueMarker1); //ChartFrame frame = new ChartFrame("series chart", chart); // frame.setVisible(true); // frame.setSize(450, 350); final ChartPanel chartPanel6 = new ChartPanel(chart6); chartPanel6.setPreferredSize(new java.awt.Dimension(560, 370)); chartPanel6.setMouseZoomable(true, false); setContentPane(chartPanel6); getContentPane().repaint(); }