KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > graph > renderer > TriAxisLayoutRenderer


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.renderer;
8
9 import java.awt.GridBagConstraints JavaDoc;
10 import java.text.DecimalFormat JavaDoc;
11 import java.text.SimpleDateFormat JavaDoc;
12
13 import javax.swing.JComponent JavaDoc;
14
15 import org.ejtools.graph.Axis;
16 import org.ejtools.graph.GraphElement;
17 import org.ejtools.graph.GraphRenderer;
18 import org.ejtools.graph.LabelElement;
19
20 /**
21  * @author Laurent Etiemble
22  * @version $Revision: 1.8 $
23  * @todo Javadoc to complete
24  */

25 public class TriAxisLayoutRenderer extends GridBagLayoutRenderer
26 {
27    /** Constructor for TriAxisGraph. */
28    public TriAxisLayoutRenderer()
29    {
30       super();
31
32       GridBagConstraints JavaDoc constraints = new GridBagConstraints JavaDoc();
33
34       GraphRenderer rd = new GridGraphRenderer(new SimpleDateFormat JavaDoc("HH:mm:ss"), new DecimalFormat JavaDoc("0"));
35       constraints.gridx = 1;
36       constraints.gridy = 1;
37       constraints.fill = GridBagConstraints.BOTH;
38       constraints.weightx = 1.0;
39       constraints.weighty = 1.0;
40       this.addRenderer(rd, constraints);
41
42       Axis axis = new HorizontalAxis(new SimpleDateFormat JavaDoc("HH:mm:ss"), Axis.BOTTOM);
43       constraints.gridx = 1;
44       constraints.gridy = 2;
45       constraints.fill = GridBagConstraints.HORIZONTAL;
46       constraints.weightx = 0.0;
47       constraints.weighty = 0.0;
48       this.addRenderer(axis, constraints);
49
50       axis = new VerticalAxis(new DecimalFormat JavaDoc("0"), Axis.LEFT);
51       constraints.gridx = 0;
52       constraints.gridy = 1;
53       constraints.fill = GridBagConstraints.VERTICAL;
54       constraints.weightx = 0.0;
55       constraints.weighty = 0.0;
56       this.addRenderer(axis, constraints);
57
58       axis = new VerticalAxis(new DecimalFormat JavaDoc("0"), Axis.RIGHT);
59       constraints.gridx = 2;
60       constraints.gridy = 1;
61       constraints.fill = GridBagConstraints.VERTICAL;
62       constraints.weightx = 0.0;
63       constraints.weighty = 0.0;
64       this.addRenderer(axis, constraints);
65    }
66
67
68    /**
69     * @param element The new graphElement value
70     */

71    public void setGraphElement(GraphElement element)
72    {
73       super.setGraphElement(element);
74
75       if (element instanceof LabelElement)
76       {
77          JComponent JavaDoc component = ((LabelElement) this.element).getComponent();
78
79          GridBagConstraints JavaDoc constraints = new GridBagConstraints JavaDoc();
80          constraints.gridx = 0;
81          constraints.gridy = 0;
82          constraints.gridwidth = 3;
83          constraints.fill = GridBagConstraints.HORIZONTAL;
84          constraints.weightx = 0.0;
85          constraints.weighty = 0.0;
86          this.add(component, constraints);
87       }
88    }
89 }
90
Popular Tags