List of usage examples for org.jfree.chart.axis NumberAxis setRange
public void setRange(double lower, double upper)
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();//from w w w. jav a 2s .c om 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:org.openimaj.demos.sandbox.PlotFlickrGeo.java
public static void main(String[] args) throws IOException { File inputcsv = new File("/Users/jsh2/Desktop/world-geo.csv"); List<float[]> data = new ArrayList<float[]>(10000000); //read in images BufferedReader br = new BufferedReader(new FileReader(inputcsv)); String line;//from www . jav a 2 s.c o m int i = 0; while ((line = br.readLine()) != null) { String[] parts = line.split(","); float longitude = Float.parseFloat(parts[0]); float latitude = Float.parseFloat(parts[1]); data.add(new float[] { longitude, latitude }); if (i++ % 10000 == 0) System.out.println(i); } System.out.println("Done reading"); float[][] dataArr = new float[2][data.size()]; for (i = 0; i < data.size(); i++) { dataArr[0][i] = data.get(i)[0]; dataArr[1][i] = data.get(i)[1]; } NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setRange(-180, 180); NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setRange(-90, 90); FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis); JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); final ApplicationFrame frame = new ApplicationFrame("Title"); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
From source file:org.openimaj.demos.sandbox.flickr.geo.PlotFlickrGeo.java
public static void main(String[] args) throws IOException { final File inputcsv = new File("/Volumes/SSD/training_latlng"); final List<double[]> data = new ArrayList<double[]>(10000000); // read in images final BufferedReader br = new BufferedReader(new FileReader(inputcsv)); String line;//w w w . j a v a 2s.c o m int i = 0; br.readLine(); while ((line = br.readLine()) != null) { final String[] parts = line.split(" "); final double longitude = Double.parseDouble(parts[2]); final double latitude = Double.parseDouble(parts[1]); data.add(new double[] { longitude, latitude }); if (longitude >= -0.1 && longitude < 0 && latitude > 50 && latitude < 54) System.out.println(parts[0] + " " + latitude + " " + longitude); // if (i++ % 10000 == 0) // System.out.println(i); } br.close(); System.out.println("Done reading"); final float[][] dataArr = new float[2][data.size()]; for (i = 0; i < data.size(); i++) { dataArr[0][i] = (float) data.get(i)[0]; dataArr[1][i] = (float) data.get(i)[1]; } final NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setRange(-180, 180); final NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setRange(-90, 90); final FastScatterPlot plot = new FastScatterPlot(dataArr, domainAxis, rangeAxis); final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); final ApplicationFrame frame = new ApplicationFrame("Title"); frame.setContentPane(chartPanel); frame.pack(); frame.setVisible(true); }
From source file:org.jfree.chart.demo.BubbleChartDemo2.java
private static JFreeChart createChart(XYZDataset xyzdataset) { JFreeChart jfreechart = ChartFactory.createBubbleChart("Bubble Chart Demo 2", "X", "Y", xyzdataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setRenderer(new XYBubbleRenderer(0)); xyplot.setForegroundAlpha(0.65F);/*from w w w . j ava 2s .c o m*/ XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(0, Color.blue); xyitemrenderer.setBaseItemLabelGenerator(new BubbleXYItemLabelGenerator()); xyitemrenderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); xyitemrenderer.setBaseItemLabelsVisible(true); xyitemrenderer .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); NumberAxis numberaxis = (NumberAxis) xyplot.getDomainAxis(); numberaxis.setRange(0.0D, 10D); NumberAxis numberaxis1 = (NumberAxis) xyplot.getRangeAxis(); numberaxis1.setRange(0.0D, 10D); return jfreechart; }
From source file:org.jfree.chart.demo.DeviationRendererDemo3.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart chart = ChartFactory.createXYLineChart("DeviationRenderer - Demo 3", "X", "Y", xydataset, PlotOrientation.VERTICAL, false, true, false); XYPlot plot = (XYPlot) chart.getPlot(); ///*from w w w .ja v a 2 s. c o m*/ DeviationRenderer renderer = new DeviationRenderer(false, false); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(0, new BasicStroke(3F, 1, 1)); renderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1)); renderer.setSeriesFillPaint(0, Color.red); renderer.setSeriesFillPaint(1, Color.orange); renderer.setSeriesFillPaint(2, Color.green); plot.setRenderer(renderer); // DateAxis domainAxis = new DateAxis("Date"); domainAxis.setLowerMargin(0.0D); domainAxis.setUpperMargin(0.0D); plot.setDomainAxis(domainAxis); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); valueAxis.setRange(-40D, 40D); valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(chart); return chart; }
From source file:org.jfree.chart.demo.CompassFormatDemo1.java
private static JFreeChart createChart() { XYDataset xydataset = createDirectionDataset(600); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Time", "Date", "Direction", xydataset, true, true, false);//w ww . j av a 2 s . c o m XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.getDomainAxis().setLowerMargin(0.0D); xyplot.getDomainAxis().setUpperMargin(0.0D); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); TickUnits tickunits = new TickUnits(); tickunits.add(new NumberTickUnit(180D, new CompassFormat())); tickunits.add(new NumberTickUnit(90D, new CompassFormat())); tickunits.add(new NumberTickUnit(45D, new CompassFormat())); tickunits.add(new NumberTickUnit(22.5D, new CompassFormat())); numberaxis.setStandardTickUnits(tickunits); xyplot.setRangeAxis(numberaxis); XYAreaRenderer xyarearenderer = new XYAreaRenderer(); NumberAxis numberaxis1 = new NumberAxis("Force"); numberaxis1.setRange(0.0D, 12D); xyarearenderer.setSeriesPaint(0, new Color(0, 0, 255, 128)); xyplot.setDataset(1, createForceDataset(600)); xyplot.setRenderer(1, xyarearenderer); xyplot.setRangeAxis(1, numberaxis1); xyplot.mapDatasetToRangeAxis(1, 1); return jfreechart; }
From source file:org.gephi.statistics.plugin.ChartUtils.java
public static void scaleChart(JFreeChart chart, XYSeries dSeries, boolean normalized) { XYPlot plot = (XYPlot) chart.getPlot(); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(1.0);/*from w ww.j a va2 s .c o m*/ domainAxis.setUpperMargin(1.0); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (normalized) { domainAxis.setRange(-0.05, 1.05); } else { domainAxis.setRange(dSeries.getMinX() - 1, dSeries.getMaxX() + 1); } NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(-0.1 * Math.sqrt(dSeries.getMaxY()), dSeries.getMaxY() + 0.1 * Math.sqrt(dSeries.getMaxY())); }
From source file:org.radargun.reporting.BarPlotGenerator.java
/** * @param operation Name of the plotted operation * @param ranges ranges[0] = min, ranges[ranges.length - 1] = max * @param counts counts[i] is number of entries with value >= ranges[i - 1] and < ranges[i] * @param reportDir/*ww w.j a va2 s . c om*/ * @param filename * @throws IOException */ public static void generate(String operation, long[] ranges, long[] counts, String reportDir, String filename) throws IOException { XYSeries series = new XYSeries(operation + " response times"); long totalCount = 0; for (long count : counts) { totalCount += count; } double left = Math.log10(ranges[0]); double right = Math.log10(ranges[ranges.length - 1]); for (int i = 0; i < counts.length; i++) { series.add(Math.log10(ranges[i]), (double) counts[i] / totalCount); } series.add(right, 0d); XYDataset dataset = new XYSeriesCollection(series); JFreeChart chart = ChartFactory.createXYStepAreaChart(operation + " response time histogram", "Response time", "Percentage", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis d = (NumberAxis) plot.getDomainAxis(); d.setRange(left, right); d.setStandardTickUnits(new HistoTickUnitSource()); plot.setDomainAxis(d); FileOutputStream output = new FileOutputStream(new File(reportDir + File.separator + filename)); ChartUtilities.writeChartAsPNG(output, chart, 1024, 768); output.close(); }
From source file:logica.LGraficaAltura.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;// w ww. j a v a2s . c o m JFreeChart chart = null; if (jRLinea.isSelected()) { // ejecuto linea XYSplineRenderer graficoLinea = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Datos"); XYPlot plot; graficoLinea.setSeriesPaint(0, Color.YELLOW); VGraficaAltura.getPanelLinea().removeAll(); for (int i = 0; i < VGraficaAltura.getjTable1().getRowCount(); i++) { float valor1 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 0))); float valor2 = Float.parseFloat(String.valueOf(VGraficaAltura.getjTable1().getValueAt(i, 1))); System.out.println("valores " + valor1 + " " + valor2); serie.add(valor1, valor2); } dataset.addSeries(serie); x.setLabel("MES"); y.setLabel("ALTURA"); plot = new XYPlot(dataset, x, y, graficoLinea); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(15, 30); chart = new JFreeChart(plot); chart.setTitle("grafico"); panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); VGraficaAltura.getPanelLinea().add(panel); VGraficaAltura.getPanelLinea().repaint(); } }
From source file:logica.LGraficapeso.java
public static void logicaBtnGraficar(JRadioButton jRLinea) { ChartPanel panel;//from www . j av a 2 s. c o m JFreeChart chart = null; if (jRLinea.isSelected()) { // ejecuto linea XYSplineRenderer graficoLinea = new XYSplineRenderer(); XYSeriesCollection dataset = new XYSeriesCollection(); ValueAxis x = new NumberAxis(); ValueAxis y = new NumberAxis(); XYSeries serie = new XYSeries("Datos"); XYPlot plot; graficoLinea.setSeriesPaint(0, Color.YELLOW); VGraficaPeso.getPanelLinea().removeAll(); for (int i = 0; i < VGraficaPeso.getjTable1().getRowCount(); i++) { float valor1 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 0))); float valor2 = Float.parseFloat(String.valueOf(VGraficaPeso.getjTable1().getValueAt(i, 1))); System.out.println("valores " + valor1 + " " + valor2); serie.add(valor1, valor2); } dataset.addSeries(serie); x.setLabel("MES"); y.setLabel("peso"); plot = new XYPlot(dataset, x, y, graficoLinea); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(10, 15); chart = new JFreeChart(plot); chart.setTitle("grafico"); panel = new ChartPanel(chart); panel.setBounds(5, 10, 410, 350); VGraficaPeso.getPanelLinea().add(panel); VGraficaPeso.getPanelLinea().repaint(); } }