|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| Test.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* EJTools, the Enterprise Java Tools
|
|
| 3 |
*
|
|
| 4 |
* Distributable under LGPL license.
|
|
| 5 |
* See terms of license at www.gnu.org.
|
|
| 6 |
*/
|
|
| 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 |
/**
|
|
| 17 |
* Description of the Class
|
|
| 18 |
*
|
|
| 19 |
* @author Laurent Etiemble
|
|
| 20 |
* @version $Revision: 1.7 $
|
|
| 21 |
* @todo Javadoc to complete
|
|
| 22 |
*/
|
|
| 23 |
public class Test |
|
| 24 |
{
|
|
| 25 |
/** Constructor for Test. */
|
|
| 26 | 0 |
public Test()
|
| 27 |
{
|
|
| 28 | 0 |
super();
|
| 29 |
} |
|
| 30 |
|
|
| 31 |
|
|
| 32 |
/**
|
|
| 33 |
* The main program for the Test class
|
|
| 34 |
*
|
|
| 35 |
* @param args The command line arguments
|
|
| 36 |
* @exception Exception Description of the Exception
|
|
| 37 |
*/
|
|
| 38 | 0 |
public static void main(String[] args) |
| 39 |
throws Exception
|
|
| 40 |
{
|
|
| 41 | 0 |
Track t1 = new Track("Toto"); |
| 42 | 0 |
t1.setColor(Color.blue); |
| 43 | 0 |
Track t2 = new Track("Tata"); |
| 44 | 0 |
t2.setColor(Color.red); |
| 45 |
|
|
| 46 | 0 |
CompositeTrack ct = new CompositeTrack();
|
| 47 | 0 |
ct.addTrack(t1); |
| 48 | 0 |
ct.addTrack(t2); |
| 49 |
|
|
| 50 | 0 |
TriAxisLayoutRenderer cg = new TriAxisLayoutRenderer();
|
| 51 | 0 |
cg.setGraphElement(ct); |
| 52 |
|
|
| 53 |
// BorderGraph cg = new BorderGraph();
|
|
| 54 |
// cg.setGraphElement(t1);
|
|
| 55 |
|
|
| 56 |
// Renderer rd = new DefaultRenderer();
|
|
| 57 |
// Renderer rd = new GridRenderer(new SimpleDateFormat("HH:mm:ss.SSS"), new DecimalFormat("0"));
|
|
| 58 |
// cg.addRenderer(rd, BorderLayout.CENTER);
|
|
| 59 |
// Axis axis = new HorizontalAxis(new SimpleDateFormat("HH:mm:ss.SSS"), Axis.BOTTOM);
|
|
| 60 |
// cg.addRenderer(axis, BorderLayout.SOUTH);
|
|
| 61 |
// axis = new VerticalAxis(new DecimalFormat("0"), Axis.LEFT);
|
|
| 62 |
// cg.addRenderer(axis, BorderLayout.WEST);
|
|
| 63 |
// axis = new VerticalAxis(new DecimalFormat("0"), Axis.RIGHT);
|
|
| 64 |
// cg.addRenderer(axis, BorderLayout.EAST);
|
|
| 65 |
|
|
| 66 |
/*
|
|
| 67 |
* GridBagGraph cg = new GridBagGraph();
|
|
| 68 |
* cg.setGraphElement(ct);
|
|
| 69 |
* GridBagConstraints constraints = new GridBagConstraints();
|
|
| 70 |
* / Renderer rd = new DefaultRenderer();
|
|
| 71 |
* Renderer rd = new GridRenderer(new SimpleDateFormat("HH:mm:ss.SSS"), new DecimalFormat("0"));
|
|
| 72 |
* constraints.gridx = 1;
|
|
| 73 |
* constraints.gridy = 0;
|
|
| 74 |
* constraints.fill = GridBagConstraints.BOTH;
|
|
| 75 |
* constraints.weightx = 1.0;
|
|
| 76 |
* constraints.weighty = 1.0;
|
|
| 77 |
* cg.addRenderer(rd, constraints);
|
|
| 78 |
* Axis axis = new HorizontalAxis(new SimpleDateFormat("HH:mm:ss.SSS"), Axis.BOTTOM);
|
|
| 79 |
* constraints.gridx = 1;
|
|
| 80 |
* constraints.gridy = 1;
|
|
| 81 |
* constraints.fill = GridBagConstraints.HORIZONTAL;
|
|
| 82 |
* constraints.weightx = 0.0;
|
|
| 83 |
* constraints.weighty = 0.0;
|
|
| 84 |
* cg.addRenderer(axis, constraints);
|
|
| 85 |
* axis = new VerticalAxis(new DecimalFormat("0"), Axis.LEFT);
|
|
| 86 |
* constraints.gridx = 0;
|
|
| 87 |
* constraints.gridy = 0;
|
|
| 88 |
* constraints.fill = GridBagConstraints.VERTICAL;
|
|
| 89 |
* constraints.weightx = 0.0;
|
|
| 90 |
* constraints.weighty = 0.0;
|
|
| 91 |
* cg.addRenderer(axis, constraints);
|
|
| 92 |
* axis = new VerticalAxis(new DecimalFormat("0"), Axis.RIGHT);
|
|
| 93 |
* constraints.gridx = 2;
|
|
| 94 |
* constraints.gridy = 0;
|
|
| 95 |
* constraints.fill = GridBagConstraints.VERTICAL;
|
|
| 96 |
* constraints.weightx = 0.0;
|
|
| 97 |
* constraints.weighty = 0.0;
|
|
| 98 |
* cg.addRenderer(axis, constraints);
|
|
| 99 |
*/
|
|
| 100 | 0 |
cg.setVisible(true);
|
| 101 |
|
|
| 102 | 0 |
JFrame frame = new JFrame("Test"); |
| 103 | 0 |
frame.getContentPane().setLayout(new BorderLayout());
|
| 104 | 0 |
frame.getContentPane().add(cg, BorderLayout.CENTER); |
| 105 | 0 |
frame.setSize(600, 400); |
| 106 |
|
|
| 107 | 0 |
frame.show(); |
| 108 |
|
|
| 109 | 0 |
double i = 0;
|
| 110 | 0 |
double scale = 1.0d;
|
| 111 | 0 |
while (i < 50)
|
| 112 |
{
|
|
| 113 | 0 |
System.out.println(i); |
| 114 | 0 |
t1.addValue(Math.cos(i * 10 * Math.PI / 180) * 20); |
| 115 | 0 |
t2.addValue(Math.sin(i * 10 * Math.PI / 180) * 20); |
| 116 | 0 |
Thread.sleep(200); |
| 117 | 0 |
cg.repaint(); |
| 118 | 0 |
i++; |
| 119 | 0 |
if ((i % 20) == 0)
|
| 120 |
{
|
|
| 121 | 0 |
scale = scale / 1.5; |
| 122 | 0 |
cg.setHorizontalScale(scale); |
| 123 |
} |
|
| 124 |
} |
|
| 125 |
|
|
| 126 | 0 |
System.exit(0); |
| 127 |
} |
|
| 128 |
} |
|
| 129 |
|
|
||||||||||