diff --git a/jzy3d-tutorials/src/main/java/org/jzy3d/demos/chart2d/Chart2dDemo.java b/jzy3d-tutorials/src/main/java/org/jzy3d/demos/chart2d/Chart2dDemo.java index ce261992..a59bc723 100644 --- a/jzy3d-tutorials/src/main/java/org/jzy3d/demos/chart2d/Chart2dDemo.java +++ b/jzy3d-tutorials/src/main/java/org/jzy3d/demos/chart2d/Chart2dDemo.java @@ -25,37 +25,67 @@ import org.jzy3d.plot3d.primitives.axes.layout.renderers.PitchTickRenderer; import org.jzy3d.ui.LookAndFeel; /** - * Showing a pair of 2d charts to represent pitch and amplitude variation of an audio signal + * Showing a pair of 2d charts to represent pitch and amplitude variation of an + * audio signal. + * + * When using large number of samples, run program with VM argument : -Xmx1024m * * @author Martin Pernollet */ public class Chart2dDemo { - public static float duration = 15f; + public static float duration = 60f; + /** milisecond distance between two generated samples*/ + public static int interval = 50; public static int maxfreq = 880; public static int nOctave = 5; - + public static void main(String[] args) throws Exception { PitchAmpliControlCharts log = new PitchAmpliControlCharts(duration, maxfreq, nOctave); new TimeChartWindow(log.getCharts()); - - start(); - - while(elapsed() charts) throws IOException { LookAndFeel.apply(); String lines = "[300px]"; String columns = "[500px,grow]"; setLayout(new MigLayout("", columns, lines)); - int k=0; - for(Chart c: charts){ - addChart(c, k++); + int k = 0; + for (Chart c : charts) { + addChart(c, k++); } windowExitListener(); this.pack(); @@ -108,14 +139,14 @@ public class Chart2dDemo { setVisible(true); } - public void addChart(Chart chart, int id){ + public void addChart(Chart chart, int id) { JPanel chartPanel = new JPanel(new BorderLayout()); Border b = BorderFactory.createLineBorder(java.awt.Color.black); chartPanel.setBorder(b); chartPanel.add((java.awt.Component) chart.getCanvas(), BorderLayout.CENTER); - add(chartPanel, "cell 0 "+id+", grow"); + add(chartPanel, "cell 0 " + id + ", grow"); } - + public void windowExitListener() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { @@ -125,7 +156,7 @@ public class Chart2dDemo { }); } } - + /** Simple timer */ protected static long start;