List of usage examples for org.jfree.chart.plot XYPlot setDomainCrosshairVisible
public void setDomainCrosshairVisible(boolean flag)
From source file:pl.dpbz.poid.zadanie3.Main.java
public static void main(String args[]) throws UnsupportedAudioFileException, IOException { //Zassanie pliku File f = new File("ExampleSounds/artificial/easy/100Hz.wav"); Integer[] ints = WaveToSamplesConverter.convertWaveToIntSamples(f); double samplingFrequency = WaveToSamplesConverter.getSamplingFrequency(f); //Zwyky sound, ktry nie potrzebuje zespolonych elementw Sound s = new Sound(ints, samplingFrequency); //Obliczenie czstotliwoci przy pomocy fazwki PhaseSpaceMultiDimensional pS = new PhaseSpaceMultiDimensional(s); pS.setupPhaseSpace();/* ww w .ja v a2 s .c o m*/ pS.computeFrequency(); System.out.println("Phase space " + pS.getFrequency()); //Zespolony dwik, ktry jest bardziej zoony ComplexSound cs = new ComplexSound(ints, samplingFrequency, 15); //To oblicza fouriera cs.setupElementsOfComplexSound(); //Tutaj obliczanie czstotliwoci przy pomocy fouriera CombFiltering cf = new CombFiltering(cs, samplingFrequency); cf.computeFrequency(); cf.drawComplexSound(); System.out.println("Comb Filtering " + cf.getFrequency()); //Przy sekwencjach nie ma majstrowania przy ustawieniach, uytkownik // zmiennie moe podawa tylko liczb prbek, reszt jak czstotliwo prbkowania // i audio format pobiera si z otwieranego pliku //Test sekwencji na fazie File file = new File("ExampleSounds/seq/DWK_violin.wav"); Integer[] seqInte = WaveToSamplesConverter.convertWaveToIntSamples(file); System.out.println("Samples overview " + seqInte.length); double seqSamplingFrequency = WaveToSamplesConverter.getSamplingFrequency(file); int samplesPerPart = 3000; SamplesToWaveConverter conv = new PhaseSpaceSampleConverter(seqSamplingFrequency, samplesPerPart, WaveToSamplesConverter.getAudioFormat(file)); conv.setupFrequenciesFromSamples(seqInte); System.out.println("Zapisuj"); conv.saveGeneratedSamples("XDPhase.wav"); //Test sekwencji na grzebieniu SamplesToWaveConverter conv2 = new CombFilteringSampleConverter(seqSamplingFrequency, samplesPerPart, WaveToSamplesConverter.getAudioFormat(file)); conv2.setupFrequenciesFromSamples(seqInte); System.out.println("Zapisuj"); conv2.saveGeneratedSamples("XDComb.wav"); //Rysowanie wykresu sygnau dwikowego final XYSeries dist = new XYSeries("P0"); int index = 0; for (Integer i : ints) { dist.add(index / samplingFrequency, i); index++; } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(dist); JFreeChart chart = ChartFactory.createXYLineChart(f.getName(), "index", "Distance", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) chart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis domain = (NumberAxis) xyPlot.getRangeAxis(); domain.setRange(-32768, 32768); ChartDrawer.drawChart(chart); System.out.println("FINISHED"); }
From source file:de.codesourcery.eve.skills.ui.ChartTest.java
public static void main(String[] args) { TimeSeries s1 = new TimeSeries("L&G European Index Trust"); s1.add(new Day(1, 2, 2001), 181.8); s1.add(new Month(3, 2001), 167.3); s1.add(new Month(4, 2001), 153.8); s1.add(new Month(5, 2001), 167.6); s1.add(new Month(6, 2001), 158.8); s1.add(new Month(7, 2001), 148.3); s1.add(new Month(8, 2001), 153.9); s1.add(new Month(9, 2001), 142.7); s1.add(new Month(10, 2001), 123.2); s1.add(new Month(11, 2001), 131.8); s1.add(new Month(12, 2001), 139.6); s1.add(new Month(1, 2002), 142.9); s1.add(new Month(2, 2002), 138.7); s1.add(new Month(3, 2002), 137.3); s1.add(new Month(4, 2002), 143.9); s1.add(new Month(5, 2002), 139.8); s1.add(new Month(6, 2002), 137.0); s1.add(new Month(7, 2002), 132.8); TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); s2.add(new Month(2, 2001), 129.6); s2.add(new Month(3, 2001), 123.2); s2.add(new Month(4, 2001), 117.2); s2.add(new Month(5, 2001), 124.1); s2.add(new Month(6, 2001), 122.6); s2.add(new Month(7, 2001), 119.2); s2.add(new Month(8, 2001), 116.5); s2.add(new Month(9, 2001), 112.7); s2.add(new Month(10, 2001), 101.5); s2.add(new Month(11, 2001), 106.1); s2.add(new Month(12, 2001), 110.3); s2.add(new Month(1, 2002), 111.7); s2.add(new Month(2, 2002), 111.0); s2.add(new Month(3, 2002), 109.6); s2.add(new Month(4, 2002), 113.2); s2.add(new Month(5, 2002), 111.6); s2.add(new Month(6, 2002), 108.8); s2.add(new Month(7, 2002), 101.6); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(s1);//ww w .ja va 2 s .c o m dataset.addSeries(s2); JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); 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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); // display chart ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setMouseZoomable(true, false); JFrame frame = new JFrame("test"); frame.setContentPane(chartPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:jprobix.ui.SPlotFinal.java
public static JPanel creteDemoPanel() { JFreeChart jfreechart = ChartFactory.createScatterPlot("Scatter plot demo", "X", "Y", samplexydataset2(), PlotOrientation.VERTICAL, true, true, false); Shape cross = ShapeUtilities.createDiagonalCross(3, 2); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setSeriesShape(5, cross);//from w ww.jav a2 s. com renderer.setSeriesPaint(0, Color.YELLOW); XYDotRenderer xydotrenderer = new XYDotRenderer(); xyPlot.setRenderer(xydotrenderer); xydotrenderer.setSeriesShape(0, cross); xyPlot.setDomainCrosshairVisible(true); xyPlot.setRangeCrosshairVisible(true); return new ChartPanel(jfreechart); }
From source file:DataCharts.LineGraph.java
public static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Customers by Month", "Months", "Customers", dataset); String fontName = "SansSerif"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle(" ", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(false);/* www . j av a 2 s. c o m*/ plot.setRangePannable(false); 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().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setDrawSeriesLineAsPath(false); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); } return chart; }
From source file:org.jfree.chart.demo.StackedXYAreaRendererDemo1.java
private static JFreeChart createChart(TableXYDataset tablexydataset) { JFreeChart jfreechart = ChartFactory.createStackedXYAreaChart("StackedXYAreaRendererDemo1", "X Value", "Y Value", tablexydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); StackedXYAreaRenderer stackedxyarearenderer = new StackedXYAreaRenderer(5); stackedxyarearenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xyplot.setRenderer(0, stackedxyarearenderer); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); stackedxyarearenderer.setShapePaint(Color.yellow); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.jfree.chart.demo.selection.SelectionDemo1.java
/** * Creates a chart.//from w w w. java2s .co m * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices", "Date", "Price Per Unit", dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setBaseShapesVisible(true); r.setBaseShapesFilled(true); r.setUseFillPaint(true); r.setSeriesFillPaint(0, r.lookupSeriesPaint(0)); r.setSeriesFillPaint(1, r.lookupSeriesPaint(1)); //add selection specific rendering IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white); //register plot as selection change listener ext.addChangeListener(plot); return chart; }
From source file:org.jfree.chart.demo.selection.SelectionDemo8.java
/** * Creates a chart./*w ww .j a v a 2 s . co m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset, DatasetSelectionExtension<XYCursor> ext) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Stock Prices", "Date", "Price Per Unit", dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setBaseShapesVisible(true); r.setBaseShapesFilled(true); r.setUseFillPaint(true); r.setSeriesFillPaint(0, r.lookupSeriesPaint(0)); r.setSeriesFillPaint(1, r.lookupSeriesPaint(1)); r.setDrawOutlines(true); //add selection specific rendering IRSUtilities.setSelectedItemFillPaint(r, ext, Color.white); //register plot as selection change listener ext.addChangeListener(plot); return chart; }
From source file:org.jfree.chart.demo.RelativeDateFormatDemo2.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("RelativeDateFormat Demo 2", "Date ", true, "Time To Complete", intervalxydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setDrawBarOutline(false); DateAxis dateaxis = new DateAxis(); RelativeDateFormat relativedateformat = new RelativeDateFormat(); relativedateformat.setShowZeroDays(false); relativedateformat.setSecondFormatter(new DecimalFormat("00")); dateaxis.setDateFormatOverride(relativedateformat); xyplot.setRangeAxis(dateaxis);/*from w ww. jav a 2 s . c o m*/ return jfreechart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo14.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Bug Report Submissions for Java", "Date", "Evaluation ID", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); }/* ww w .j av a 2s.co m*/ DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return jfreechart; }
From source file:org.jfree.chart.demo.RelativeDateFormatDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Exercise Chart", "Elapsed Time", "Beats Per Minute", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); }//from w w w . j ava 2 s .co m DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); Minute minute = new Minute(0, 9, 1, 10, 2006); RelativeDateFormat relativedateformat = new RelativeDateFormat(minute.getFirstMillisecond()); relativedateformat.setSecondFormatter(new DecimalFormat("00")); dateaxis.setDateFormatOverride(relativedateformat); return jfreechart; }