List of usage examples for org.jfree.data.xy XYSeries XYSeries
public XYSeries(Comparable key)
From source file:max.hubbard.Factoring.Graphing.java
private static XYDataset createDataset(LinkedList<LinkedHashMap<Float, Integer>> list, String orig) { final XYSeries series1 = new XYSeries(orig); for (double i = -10; i < 11; i++) { float v = 0; for (LinkedHashMap<Float, Integer> map : list) { for (Float f : map.keySet()) { if (map.get(f) != 0) { v = v + f * (float) Math.pow(i, map.get(f)); } else { v = v + f;/* www . ja v a2 s . com*/ } } } series1.add(i, v); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); return dataset; }
From source file:org.eumetsat.metop.visat.AmsuInfoView.java
@Override protected XYSeries createSpectrumPlotXYSeries(final double[] radiances) { final XYSeries series = new XYSeries("Sample Values"); for (int i = 0; i < CHANNEL_FREQUENCIES.length; i++) { series.add(i + 1, BlackBody.temperatureAtFrequency(CHANNEL_FREQUENCIES[i], radiances[i] * 0.1)); }//from w w w. ja v a 2 s. c o m return series; }
From source file:org.jfree.chart.demo.XYSeriesDemo3.java
/** * Creates a sample dataset./*from www . j a v a 2s .c om*/ * * @return A sample dataset. */ private IntervalXYDataset createDataset() { final XYSeries series = new XYSeries("Random Data"); series.add(1.0, 400.2); series.add(5.0, 294.1); series.add(4.0, 100.0); series.add(12.5, 734.4); series.add(17.3, 453.2); series.add(21.2, 500.2); series.add(21.9, null); series.add(25.6, 734.4); series.add(30.0, 453.2); final XYSeriesCollection dataset = new XYSeriesCollection(series); return dataset; }
From source file:org.jfree.chart.demo.CyclicXYPlotDemo.java
/** * A demonstration application showing an XY plot, with a cyclic axis and renderer * * @param title the frame title.//from ww w .ja v a 2s. c om */ public CyclicXYPlotDemo(final String title) { super(title); this.series = new XYSeries("Random Data"); this.series.setMaximumItemCount(50); // Only 50 items are visible at the same time. // Keep more as a mean to test this. final XYSeriesCollection data = new XYSeriesCollection(this.series); final JFreeChart chart = ChartFactory.createXYLineChart("Cyclic XY Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setDomainAxis(new CyclicNumberAxis(10, 0)); plot.setRenderer(new CyclicXYItemRenderer()); final NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); axis.setAutoRangeMinimumSize(1.0); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(400, 300)); final JPanel content = new JPanel(new BorderLayout()); content.add(chartPanel, BorderLayout.CENTER); final JButton button1 = new JButton("Start"); button1.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { timer.start(); } }); final JButton button2 = new JButton("Stop"); button2.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { timer.stop(); } }); final JButton button3 = new JButton("Step by step"); button3.addActionListener(new ActionListener() { public void actionPerformed(final ActionEvent e) { CyclicXYPlotDemo.this.actionPerformed(null); } }); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); setContentPane(content); this.timer = new Timer(200, this); }
From source file:org.pf.midea.MainUI.java
private void showConstellationWindow(ConstellationPoint[] _map, String _name) { JFrame constellation = new JFrame(" ?? " + _name); constellation.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); XYSeriesCollection dots = new XYSeriesCollection(); XYSeries series = new XYSeries(_name); JFreeChart chart = ChartFactory.createScatterPlot("", "I", "Q", dots, PlotOrientation.VERTICAL, false, false, false);//from w w w . j av a 2 s. co m XYPlot xyPlot = chart.getXYPlot(); CustomXYToolTipGenerator tooltipsGenerator = new CustomXYToolTipGenerator(); ArrayList<String> tooltips = new ArrayList<>(); for (ConstellationPoint ccp : _map) { double I = ccp.getI(); double Q = ccp.getQ(); series.add(I, Q); tooltips.add(ccp.getCode().getStringSequence()); } tooltipsGenerator.addToolTipSeries(tooltips); xyPlot.getRenderer().setBaseToolTipGenerator(tooltipsGenerator); double maxX = StatisticsTools.round(Math.abs(series.getMaxX()), 3); double maxY = StatisticsTools.round(Math.abs(series.getMaxY()), 3); double minX = StatisticsTools.round(Math.abs(series.getMinX()), 3); double minY = StatisticsTools.round(Math.abs(series.getMinY()), 3); if (maxX != 0 || minX != 0) { double X = Math.max(minX, maxX); xyPlot.getDomainAxis().setRange(-1.1 * X, 1.1 * X); } else xyPlot.getDomainAxis().setRange(-1, 1); if (maxY != 0 || minY != 0) { double Y = Math.max(minY, maxY); xyPlot.getRangeAxis().setRange(-1.1 * Y, 1.1 * Y); } else xyPlot.getRangeAxis().setRange(-1, 1); dots.addSeries(series); xyPlot.setBackgroundPaint(Color.WHITE); xyPlot.setDomainGridlinePaint(Color.GRAY); xyPlot.setRangeGridlinePaint(Color.GRAY); xyPlot.getRenderer().setSeriesPaint(0, Color.BLACK); xyPlot.setDomainZeroBaselineVisible(true); xyPlot.setRangeZeroBaselineVisible(true); ChartPanel chartPanel = new ChartPanel(chart); JPanel nestedPanel = new JPanel(); nestedPanel.add(chartPanel, new CellConstraints()); constellation.add(nestedPanel); constellation.pack(); constellation.setLocationRelativeTo(null); constellation.setResizable(false); constellation.setVisible(true); }
From source file:org.drugis.addis.gui.ConvergencePlotsDialog.java
public ConvergencePlotsDialog(final JFrame main, MCMCSettings settings, final MCMCModel mcmcModel, final Parameter p) { super(main, p + " convergence diagnostics", false); d_rHatSeries = new XYSeries("R-Hat"); d_vHatSeries = new XYSeries("sqrt(vHat)"); d_wSeries = new XYSeries("sqrt(W)"); d_task = createTask(mcmcModel.getResults(), settings, p); super.add(new JScrollPane(createPanel())); mcmcModel.getResults().addResultsListener(new MCMCResultsListener() { public void resultsEvent(MCMCResultsEvent event) { fillDataSets();/*from w w w . j a v a 2 s. co m*/ } }); if (mcmcModel.getResults().getNumberOfSamples() > 0) { fillDataSets(); } }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo3.java
/** * creaets XYDataset// ww w . j av a 2 s . co m * @param isDemo true use the demo data, false use data from the JTable * @return XYDataset */ protected XYDataset createDataset(boolean isDemo) { if (isDemo) { XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < 4; i++) { XYSeries series = new XYSeries("S" + i); for (int j = 0; j < 4; j++) { series.add(j, Math.random() * 100); } dataset.addSeries(series); } return dataset; } else return super.createDataset(false); }
From source file:LineChartDemo6.java
/** * Creates a sample dataset.//from w w w .j a v a2 s . co m * * @return a sample dataset. */ private XYDataset createDataset() { final XYSeries series1 = new XYSeries("First"); series1.add(1.0, 1.0); series1.add(2.0, 4.0); series1.add(3.0, 3.0); series1.add(4.0, 5.0); series1.add(5.0, 5.0); series1.add(6.0, 7.0); series1.add(7.0, 7.0); series1.add(8.0, 8.0); final XYSeries series2 = new XYSeries("Second"); series2.add(1.0, 5.0); series2.add(2.0, 7.0); series2.add(3.0, 6.0); series2.add(4.0, 8.0); series2.add(5.0, 4.0); series2.add(6.0, 4.0); series2.add(7.0, 2.0); series2.add(8.0, 1.0); final XYSeries series3 = new XYSeries("Third"); series3.add(3.0, 4.0); series3.add(4.0, 3.0); series3.add(5.0, 2.0); series3.add(6.0, 3.0); series3.add(7.0, 6.0); series3.add(8.0, 3.0); series3.add(9.0, 4.0); series3.add(10.0, 3.0); final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series1); dataset.addSeries(series2); dataset.addSeries(series3); return dataset; }
From source file:org.owasp.benchmark.score.report.Scatter.java
private JFreeChart display(String title, int height, int width, OverallResults or) { JFrame f = new JFrame(title); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Note: this is a little weird, since each point is a separate series XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries("Scores"); for (OverallResult r : or.getResults()) { series.add(r.fpr * 100, r.tpr * 100); }//ww w. j a v a2s. com dataset.addSeries(series); chart = ChartFactory.createScatterPlot(title, "False Positive Rate", "True Positive Rate", dataset, PlotOrientation.VERTICAL, true, true, false); String fontName = "Arial"; DecimalFormat pctFormat = new DecimalFormat("0'%'"); theme = (StandardChartTheme) org.jfree.chart.StandardChartTheme.createJFreeTheme(); theme.setExtraLargeFont(new Font(fontName, Font.PLAIN, 24)); // title theme.setLargeFont(new Font(fontName, Font.PLAIN, 20)); // axis-title theme.setRegularFont(new Font(fontName, Font.PLAIN, 16)); theme.setSmallFont(new Font(fontName, Font.PLAIN, 12)); theme.setRangeGridlinePaint(Color.decode("#C0C0C0")); theme.setPlotBackgroundPaint(Color.white); theme.setChartBackgroundPaint(Color.white); theme.setGridBandPaint(Color.red); theme.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); theme.setBarPainter(new StandardBarPainter()); theme.setAxisLabelPaint(Color.decode("#666666")); theme.apply(chart); XYPlot xyplot = chart.getXYPlot(); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); NumberAxis domainAxis = (NumberAxis) xyplot.getDomainAxis(); xyplot.setOutlineVisible(true); rangeAxis.setRange(-9.99, 109.99); rangeAxis.setNumberFormatOverride(pctFormat); rangeAxis.setTickLabelPaint(Color.decode("#666666")); rangeAxis.setMinorTickCount(5); rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setAxisLineVisible(true); rangeAxis.setMinorTickMarksVisible(true); rangeAxis.setTickMarksVisible(true); rangeAxis.setLowerMargin(10); rangeAxis.setUpperMargin(10); xyplot.setRangeGridlineStroke(new BasicStroke()); xyplot.setRangeGridlinePaint(Color.lightGray); xyplot.setRangeMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setRangeMinorGridlinesVisible(true); domainAxis.setRange(-5, 105); domainAxis.setNumberFormatOverride(pctFormat); domainAxis.setTickLabelPaint(Color.decode("#666666")); domainAxis.setMinorTickCount(5); domainAxis.setTickUnit(new NumberTickUnit(10)); domainAxis.setAxisLineVisible(true); domainAxis.setTickMarksVisible(true); domainAxis.setMinorTickMarksVisible(true); domainAxis.setLowerMargin(10); domainAxis.setUpperMargin(10); xyplot.setDomainGridlineStroke(new BasicStroke()); xyplot.setDomainGridlinePaint(Color.lightGray); xyplot.setDomainMinorGridlinePaint(Color.decode("#DDDDDD")); xyplot.setDomainMinorGridlinesVisible(true); chart.setTextAntiAlias(true); chart.setAntiAlias(true); chart.removeLegend(); chart.setPadding(new RectangleInsets(20, 20, 20, 20)); xyplot.getRenderer().setSeriesPaint(0, Color.decode("#4572a7")); // // setup item labels // XYItemRenderer renderer = xyplot.getRenderer(); // Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 7.0f, 7.0f); // for ( int i = 0; i < dataset.getSeriesCount(); i++ ) { // renderer.setSeriesShape(i, circle); // renderer.setSeriesPaint(i, Color.blue); // String letter = "" + ((String)dataset.getSeries(i).getKey()).charAt(0); // StandardXYItemLabelGenerator generator = new StandardXYItemLabelGenerator(letter); // renderer.setSeriesItemLabelGenerator(i, generator); // renderer.setSeriesItemLabelsVisible(i, true); // ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER ); // renderer.setSeriesPositiveItemLabelPosition(i, position); // } makeDataLabels(or, xyplot); makeLegend(or, 57, 48, dataset, xyplot); // put legend inside plot // LegendTitle lt = new LegendTitle(xyplot); // lt.setItemFont(theme.getSmallFont()); // lt.setPosition(RectangleEdge.RIGHT); // lt.setItemFont(theme.getSmallFont()); // XYTitleAnnotation ta = new XYTitleAnnotation(.7, .55, lt, RectangleAnchor.TOP_LEFT); // ta.setMaxWidth(0.48); // xyplot.addAnnotation(ta); // draw guessing line Stroke dashed = new BasicStroke(1, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[] { 6, 3 }, 0); XYLineAnnotation guessing = new XYLineAnnotation(-5, -5, 105, 105, dashed, Color.red); xyplot.addAnnotation(guessing); XYPointerAnnotation worse = makePointer(75, 0, "Worse than guessing", TextAnchor.TOP_CENTER, 90); xyplot.addAnnotation(worse); XYPointerAnnotation better = makePointer(25, 100, "Better than guessing", TextAnchor.BOTTOM_CENTER, 270); xyplot.addAnnotation(better); XYTextAnnotation time = new XYTextAnnotation("Tool run time: " + or.getTime(), 12, -5.6); time.setTextAnchor(TextAnchor.TOP_LEFT); time.setFont(theme.getRegularFont()); time.setPaint(Color.red); xyplot.addAnnotation(time); XYTextAnnotation stroketext = new XYTextAnnotation(" Random Guess", 88, 107); stroketext.setTextAnchor(TextAnchor.CENTER_RIGHT); stroketext.setBackgroundPaint(Color.white); stroketext.setPaint(Color.red); stroketext.setFont(theme.getRegularFont()); xyplot.addAnnotation(stroketext); XYLineAnnotation strokekey = new XYLineAnnotation(58, 107, 68, 107, dashed, Color.red); xyplot.setBackgroundPaint(Color.white); xyplot.addAnnotation(strokekey); ChartPanel cp = new ChartPanel(chart, height, width, 400, 400, 1200, 1200, false, false, false, false, false, false); f.add(cp); f.pack(); f.setLocationRelativeTo(null); // f.setVisible(true); return chart; }
From source file:de.cebitec.readXplorer.plotting.CreatePlots.java
public synchronized static ChartPanel createInfPlot(Map<PersistentFeature, Pair<Double, Double>> data, String xName, String yName, XYToolTipGenerator toolTip) { XYSeriesCollection normal = new XYSeriesCollection(); XYSeriesCollection posInf = new XYSeriesCollection(); XYSeriesCollection negInf = new XYSeriesCollection(); XYSeries nor = new XYSeries("Normal"); XYSeries pos = new XYSeries("Positive Infinite"); XYSeries neg = new XYSeries("Negative Infinite"); for (Iterator<PersistentFeature> it = data.keySet().iterator(); it.hasNext();) { PersistentFeature key = it.next(); Pair<Double, Double> pair = data.get(key); Double X = pair.getFirst(); Double Y = pair.getSecond(); if (Y == Double.POSITIVE_INFINITY) { Y = 0d;//w ww . ja va 2 s . co m pos.add(new PlotDataItem(key, X, Y)); } if (Y == Double.NEGATIVE_INFINITY) { Y = 0d; neg.add(new PlotDataItem(key, X, Y)); } if (!Y.isInfinite() && !X.isInfinite()) { nor.add(new PlotDataItem(key, X, Y)); } } normal.addSeries(nor); posInf.addSeries(pos); negInf.addSeries(neg); JFreeChart chart = createCombinedChart(normal, posInf, negInf, xName, yName, toolTip); chart.removeLegend(); ChartPanel panel = new ChartPanel(chart, true, false, true, true, true); panel.setInitialDelay(0); panel.setMaximumDrawHeight(1080); panel.setMaximumDrawWidth(1920); panel.setMouseWheelEnabled(true); panel.setMouseZoomable(true); MouseActions mouseAction = new MouseActions(); panel.addChartMouseListener(mouseAction); ChartPanelOverlay overlay = new ChartPanelOverlay(mouseAction); panel.addOverlay(overlay); return panel; }