1 7 package org.ejtools.graph; 8 9 import java.awt.BorderLayout ; 10 import java.awt.Color ; 11 12 import javax.swing.JFrame ; 13 14 import org.ejtools.graph.renderer.TriAxisLayoutRenderer; 15 16 23 public class Test 24 { 25 26 public Test() 27 { 28 super(); 29 } 30 31 32 38 public static void main(String [] args) 39 throws Exception 40 { 41 Track t1 = new Track("Toto"); 42 t1.setColor(Color.blue); 43 Track t2 = new Track("Tata"); 44 t2.setColor(Color.red); 45 46 CompositeTrack ct = new CompositeTrack(); 47 ct.addTrack(t1); 48 ct.addTrack(t2); 49 50 TriAxisLayoutRenderer cg = new TriAxisLayoutRenderer(); 51 cg.setGraphElement(ct); 52 53 56 66 100 cg.setVisible(true); 101 102 JFrame frame = new JFrame ("Test"); 103 frame.getContentPane().setLayout(new BorderLayout ()); 104 frame.getContentPane().add(cg, BorderLayout.CENTER); 105 frame.setSize(600, 400); 106 107 frame.show(); 108 109 double i = 0; 110 double scale = 1.0d; 111 while (i < 50) 112 { 113 System.out.println(i); 114 t1.addValue(Math.cos(i * 10 * Math.PI / 180) * 20); 115 t2.addValue(Math.sin(i * 10 * Math.PI / 180) * 20); 116 Thread.sleep(200); 117 cg.repaint(); 118 i++; 119 if ((i % 20) == 0) 120 { 121 scale = scale / 1.5; 122 cg.setHorizontalScale(scale); 123 } 124 } 125 126 System.exit(0); 127 } 128 } 129 | Popular Tags |