List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:CorrelationLambdaTest.java
@Test public void crossCorrelationGraphicTest() { CategoryTableXYDataset serie = new CategoryTableXYDataset(); serie.setNotify(false);/*from w w w .j a va 2s.c om*/ 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:edu.cmu.sv.modelinference.eventtool.EventVisualizer.java
private void visualizeFeatures(ClassificationResult classes, Map<EventClass, Color> clusterColors, List<Range<Integer>> violations, int timeStepSize, DefaultXYDataset rawDataSet, DefaultXYDataset featuresDataSet) { //Get chart on which we will plot the features and violations DataChart c = new DataChart("Features chart"); JFreeChart chart = c.chart(""); //Plot violations XYPlot plot = chart.getXYPlot(); plot.setDataset(0, rawDataSet);/*from w w w . j a v a2 s .c o m*/ plot.setRenderer(0, new ClassificationXYRenderer(classes, timeStepSize, clusterColors)); plot.setDataset(1, featuresDataSet); plot.setRenderer(1, new XYLineAndShapeRenderer()); setViolationMarkers(violations, plot); c.pack(); RefineryUtilities.centerFrameOnScreen(c); c.setVisible(true); }
From source file:SyntheticData.XYLineChart.java
public XYLineChart(String applicationTitle, String chartTitle, String xaxislabel, String yaxislabel, XYSeriesCollection dataset) throws IOException { super(applicationTitle); JFreeChart xylinechart = ChartFactory.createXYLineChart(chartTitle, xaxislabel, yaxislabel, dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel cpanel = new ChartPanel(xylinechart); cpanel.setPreferredSize(new java.awt.Dimension(500, 500)); final XYPlot xyplot = xylinechart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.blue); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); xyplot.setRenderer(renderer);// w w w .j ava2 s.c o m setContentPane(cpanel); File saveImageFile = new File("" + applicationTitle + ".jpg"); ChartUtilities.saveChartAsJPEG(saveImageFile, xylinechart, 1920, 1080); }
From source file:com.intel.stl.ui.configuration.view.MTUByVLBarChartPanel.java
@Override public void initComponents() { dataset = new XYSeriesCollection(); JFreeChart chart = ComponentFactory.createXYBarChart(K0342_PORT_VL_TITLE.getValue(), K1068_MTU.getValue(), dataset, (XYItemLabelGenerator) null); XYPlot plot = chart.getXYPlot(); plot.setDomainPannable(true);/* ww w . j ava 2 s .co m*/ plot.setRangePannable(true); final String vlLabel = "<html>" + K0342_PORT_VL_TITLE.getValue() + ": "; final String mtuLabel = "<br>" + K1068_MTU.getValue() + ": "; XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarAlignmentFactor(0); renderer.setMargin(0.2); renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int arg1, int arg2) { int vlNum = (int) dataset.getXValue(arg1, arg2); int mtuCount = (int) dataset.getYValue(arg1, arg2); return vlLabel + vlNum + mtuLabel + mtuCount + "</html>"; } }); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(PREFERRED_CHART_SIZE); propsPanel.add(chartPanel); }
From source file:de.kletterfreak98.xmass.ui.WeightChart.java
public WeightChart(String title, TimeSeries values) { super(title); setIconImage(//w ww . java 2 s. com new ImageIcon(getClass().getClassLoader().getResource("de/kletterfreak98/xmass/resources/fav.png")) .getImage()); final String chartTitle = strings.getString("weightcourse"); final XYDataset dataset = new TimeSeriesCollection(values); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, strings.getString("date"), strings.getString("weightinkg"), dataset, false, true, false); final XYPlot plot = chart.getXYPlot(); plot.setDataset(1, new TimeSeriesCollection(values)); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setShapesFilled(true); } final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); SimpleDateFormat sdf; if (Main.settings.getLang().equals(Locale.GERMANY)) { sdf = new SimpleDateFormat("dd.MM.yyyy"); axis.setDateFormatOverride(sdf); } else { sdf = new SimpleDateFormat("MM/dd/yyyy"); axis.setDateFormatOverride(sdf); } final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); JPanel panel = new JPanel(); JButton close = new JButton(strings.getString("close")); close.setPreferredSize(new Dimension(close.getWidth(), 30)); close.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); } }); panel.setLayout(new BorderLayout()); panel.add(chartPanel, BorderLayout.CENTER); panel.add(close, BorderLayout.SOUTH); panel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(panel); setUndecorated(true); }
From source file:org.jfree.chart.demo.XYAreaChartDemo2.java
/** * Creates a chart./*from w ww .j av a 2s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYAreaChart("XY Area Chart Demo 2", "Time", "Value", dataset, PlotOrientation.VERTICAL, true, // legend true, // tool tips false // URLs ); final XYPlot plot = chart.getXYPlot(); final ValueAxis domainAxis = new DateAxis("Time"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); plot.setDomainAxis(domainAxis); plot.setForegroundAlpha(0.5f); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("#,##0.00"))); return chart; }
From source file:ws.moor.bt.grapher.ChartBuilder.java
public JFreeChart getChart() { JFreeChart chart = ChartFactory.createTimeSeriesChart(chartName, timeAxisLabel, valueAxisLabel, timeSeries, showLegend && (timeSeries.getSeriesCount() > 1), false, false); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getRenderer().setSeriesPaint(0, Color.black); plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f)); plot.getRenderer().setSeriesPaint(1, Color.black); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesPaint(2, Color.black); plot.getRenderer().setSeriesStroke(2, new BasicStroke(0.1f)); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); return chart; }
From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.domain.stadistics.graphics.implement.Grafica.java
@Override public void updateChartForHourOfDay(JFreeChart hourOfDayChart, List<HoraDelDiaEstadistica> horaDelDiaEstadisticas) { XYDataset dataset = createDataForHoursOfDay(horaDelDiaEstadisticas); XYPlot xYPlot = hourOfDayChart.getXYPlot(); xYPlot.setDataset(dataset);//from w w w .ja v a2 s .c o m }
From source file:com.tencent.wstt.apt.chart.MemoryRealTimeChart.java
@Override public JFreeChart createChart() { final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "kB", dataset, true, true, false); //??// w ww. j a v a 2s . c o m chart.getTitle().setFont(new Font("", Font.BOLD, 20)); XYPlot xyPlot = (XYPlot) chart.getXYPlot(); ValueAxis domainAxis = xyPlot.getDomainAxis(); ValueAxis rangeAxis = xyPlot.getRangeAxis(); domainAxis.setLabelFont(new Font("", Font.BOLD, 14)); domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); rangeAxis.setLabelFont(new Font("", Font.BOLD, 14)); rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); //rangeAxis.setAutoRange(true); //rangeAxis.setAutoTickUnitSelection(true); return chart; }
From source file:edu.gcsc.vrl.jfreechart.TrajectoryPlotter.java
public JFreeChart lineChart( @ParamInfo(name = "Trajectories", style = "array", options = "serialization=false") Trajectory[] trajectories) { TitledXYSeriesCollection dataset = new TitledXYSeriesCollection(); // set title if available if (trajectories.length > 0 && trajectories[0] != null) { dataset.setTitle(trajectories[0].getTitle()); dataset.setxAxisLabel(trajectories[0].getxAxisLabel()); dataset.setyAxisLabel(trajectories[0].getyAxisLabel()); dataset.setxAxisLogarithmic(trajectories[0].isxAxisLogarithmic()); dataset.setyAxisLogarithmic(trajectories[0].isyAxisLogarithmic()); }//from w w w. ja va2 s . c o m for (Trajectory t : trajectories) { dataset.addSeries(new TitledXYSeries(t)); } final JFreeChart chart = ChartFactory.createXYLineChart(dataset.getTitle(), dataset.getxAxisLabel(), dataset.getyAxisLabel(), dataset, PlotOrientation.VERTICAL, true, true, false); if (dataset.isxAxisLogarithmic()) { chart.getXYPlot().setDomainAxis(new LogarithmicAxis(dataset.getxAxisLabel())); } if (dataset.isyAxisLogarithmic()) { chart.getXYPlot().setRangeAxis(new LogarithmicAxis(dataset.getyAxisLabel())); } return chart; }