List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset)
From source file:de.hs.mannheim.modUro.reader.JCellCountDiagram.java
protected JFreeChart createChart(XYDataset dataset, List<String> cellTypes) { String title = "Cell count"; JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "n", // y-axis label dataset);/*from w w w .j a va 2s . c o m*/ String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); // plot.getRangeAxis().setRange(0.0, 1.01); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); // set the default stroke for all series int i = 0; for (String celltype : cellTypes) { r.setSeriesPaint(i, CellTypeColor.getColor(celltype)); i++; } r.setSeriesPaint(i, Color.BLACK); return xyLineChart; }
From source file:D1WaveletTransform.java
@Test public void test() throws InterruptedException, JWaveException { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);/*w w w . j av a2s . co m*/ double step = 1.0 / discretization; double startPosition = step * framePosition; //100 ? - 100 , 50 ? - 50 , 25 ?- 25 WaveletTransform t = new FastWaveletTransform((new Haar1())); double[] data = t.forward(testData.get1DSimpleSignal(1, 3, frameWidth, discretization), 128); // 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", "wave", 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:techtonic.PlotGraphListener.java
@Override public void actionPerformed(ActionEvent e) { Vector<String> v = new Vector<String>(Arrays.asList(trajectoryQuality)); Techtonic.setEnablejcbX_Axis(true);//from w w w . j a v a 2 s . co m Techtonic.setEnablejcbY_Axis(true); Techtonic.setjcbX_Axis(v); Techtonic.setjcbY_Axis(v); List<WitsmlTrajectoryStation> stationsAsList = Arrays .asList(new WitsmlTrajectoryStation[trajectory.getStations().size()]); for (WitsmlTrajectoryStation s : trajectory.getStations()) { stationsAsList.set(s.getStationNo(), s); } Techtonic.setEnablejcbX_Axis(true); Techtonic.setPropertyBtn(true); Techtonic.setEnablejcbY_Axis(true); Techtonic.setjcbX_Axis(v); Techtonic.setjcbY_Axis(v); Techtonic.setEnableRenderBtn(true); XYSeries series = new XYSeries(trajectory.getName()); String xu = ""; String yu = ""; // add data to Dataset (here assume data is in ArrayLists x and y int count = 1; for (WitsmlTrajectoryStation station : stationsAsList) { Value tvd = station.getTvd(); if (tvd == null) { continue; } xu = tvd.getUnit(); Value md = station.getNorth(); if (md == null) { continue; } yu = md.getUnit(); // System.out.println(count + " : ===>> tvd : "+tvd.getValue()+ "; md "+md.getValue()); series.add(md.getValue(), tvd.getValue()); count++; } XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(series); Techtonic.setCurrentStations(stationsAsList); // create a chart using the createYLineChart method... JFreeChart chart = ChartFactory.createXYLineChart(trajectory.getName(), // chart title xu, yu, // x and y axis labels data); // XYPlot plot = (XYPlot) chart.getPlot(); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // renderer.setSeriesLinesVisible(0, true); // renderer.setSeriesShapesVisible(1, true); // renderer.setSeriesLinesVisible(1, false); // renderer.setSeriesShapesVisible(1, true); // plot.setRenderer(renderer); ChartPanel cp = new ChartPanel(chart); // JFrame fr = new JFrame(); // fr.add(cp); // fr.pack(); // fr.setVisible(true); //cp.setMouseZoomable(true, true); // Techtonic.setTrajName(trajectory.getName()); Techtonic.setFreeChart(chart); Techtonic.setDisplayArea(cp); // chartPanel.setLayout(new java.awt.BorderLayout()); // chartPanel.add(cp,BorderLayout.CENTER); // chartPanel.validate(); // chartPanel.repaint();` }
From source file:edu.cmu.sv.modelinference.eventtool.charting.DataChart.java
private JFreeChart createChart(String yLabel) { //Create the chart final JFreeChart chart = ChartFactory.createXYLineChart("Chart", "Time", yLabel, null); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot();//from w w w . j av a2s . c om plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:CorrelationLambdaTest.java
@Test public void crossCorrelationGraphicTest() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);//from w w w .j a v a 2s.c o m double step = 1.0 / discretization; double startPosition = step * framePosition; //100 ? - 100 , 50 ? - 50 , 25 ?- 25 Transform t = new Transform(new FastWaveletTransform(new Haar1())); double[] signal = testData.get1DSimpleSignal(1.5, 500, 32768, 5000); double[] data = crossCorrelationCoefficient(signal, window); // 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", "wave", 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:de.hs.mannheim.modUro.diagram.JTimeSeriesDiagram.java
protected JFreeChart createChart(XYDataset dataset, String name) { String title = name;// w w w.j a va 2s . c o m JFreeChart xyLineChart = ChartFactory.createXYLineChart(title, // title "t", // x-axis label "f", // y-axis label dataset); String fontName = "Palatino"; xyLineChart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); XYPlot plot = (XYPlot) xyLineChart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLowerMargin(0.0); if (isMetric) { plot.getRangeAxis().setRange(0.0, 1.01); } plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); xyLineChart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); xyLineChart.getLegend().setFrame(BlockBorder.NONE); xyLineChart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return xyLineChart; }
From source file:techtonic.WellBoreListenerOnView.java
public void superImposGraph(List<WitsmlTrajectory> trajectorys) { int ct = 0;//from w w w. j a v a2 s. c o m XYSeriesCollection data = new XYSeriesCollection(); for (WitsmlTrajectory trajectory : trajectorys) { List<WitsmlTrajectoryStation> stationsAsList = Arrays .asList(new WitsmlTrajectoryStation[trajectory.getStations().size()]); for (WitsmlTrajectoryStation s : trajectory.getStations()) { stationsAsList.set(s.getStationNo(), s); } XYSeries series = new XYSeries(trajectory.getName()); // add data to Dataset (here assume data is in ArrayLists x and y for (WitsmlTrajectoryStation station : stationsAsList) { Value tvd = station.getTvd(); if (tvd == null) { continue; } Value md = station.getNorth(); if (md == null) { continue; } // System.out.println(count + " : ===>> tvd : "+tvd.getValue()+ "; md "+md.getValue()); series.add(md.getValue(), tvd.getValue()); } data.addSeries(series); ct++; } // create a chart using the createYLineChart method... JFreeChart chart = ChartFactory.createXYLineChart("Trajectory: True Vertical Depth Against North", // chart title "North", "Depth", // x and y axis labels data); // data ChartPanel cp = new ChartPanel(chart); // JFrame fr = new JFrame(); // fr.add(cp); // fr.pack(); // fr.setVisible(true); cp.setMouseZoomable(true, true); Techtonic.setFreeChart(chart); Techtonic.setDisplayArea(cp); }