|
1
|
|
|
|
2
|
|
|
|
3
|
|
|
|
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
package org.ejtools.graph.renderer;
|
|
8
|
|
|
|
9
|
|
import java.awt.GridBagConstraints;
|
|
10
|
|
import java.text.DecimalFormat;
|
|
11
|
|
import java.text.SimpleDateFormat;
|
|
12
|
|
|
|
13
|
|
import javax.swing.JComponent;
|
|
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
|
|
|
|
22
|
|
|
|
23
|
|
|
|
24
|
|
|
|
25
|
|
public class TriAxisLayoutRenderer extends GridBagLayoutRenderer
|
|
26
|
|
{
|
|
27
|
|
|
|
28
|
0
|
public TriAxisLayoutRenderer()
|
|
29
|
|
{
|
|
30
|
0
|
super();
|
|
31
|
|
|
|
32
|
0
|
GridBagConstraints constraints = new GridBagConstraints();
|
|
33
|
|
|
|
34
|
0
|
GraphRenderer rd = new GridGraphRenderer(new SimpleDateFormat("HH:mm:ss"), new DecimalFormat("0"));
|
|
35
|
0
|
constraints.gridx = 1;
|
|
36
|
0
|
constraints.gridy = 1;
|
|
37
|
0
|
constraints.fill = GridBagConstraints.BOTH;
|
|
38
|
0
|
constraints.weightx = 1.0;
|
|
39
|
0
|
constraints.weighty = 1.0;
|
|
40
|
0
|
this.addRenderer(rd, constraints);
|
|
41
|
|
|
|
42
|
0
|
Axis axis = new HorizontalAxis(new SimpleDateFormat("HH:mm:ss"), Axis.BOTTOM);
|
|
43
|
0
|
constraints.gridx = 1;
|
|
44
|
0
|
constraints.gridy = 2;
|
|
45
|
0
|
constraints.fill = GridBagConstraints.HORIZONTAL;
|
|
46
|
0
|
constraints.weightx = 0.0;
|
|
47
|
0
|
constraints.weighty = 0.0;
|
|
48
|
0
|
this.addRenderer(axis, constraints);
|
|
49
|
|
|
|
50
|
0
|
axis = new VerticalAxis(new DecimalFormat("0"), Axis.LEFT);
|
|
51
|
0
|
constraints.gridx = 0;
|
|
52
|
0
|
constraints.gridy = 1;
|
|
53
|
0
|
constraints.fill = GridBagConstraints.VERTICAL;
|
|
54
|
0
|
constraints.weightx = 0.0;
|
|
55
|
0
|
constraints.weighty = 0.0;
|
|
56
|
0
|
this.addRenderer(axis, constraints);
|
|
57
|
|
|
|
58
|
0
|
axis = new VerticalAxis(new DecimalFormat("0"), Axis.RIGHT);
|
|
59
|
0
|
constraints.gridx = 2;
|
|
60
|
0
|
constraints.gridy = 1;
|
|
61
|
0
|
constraints.fill = GridBagConstraints.VERTICAL;
|
|
62
|
0
|
constraints.weightx = 0.0;
|
|
63
|
0
|
constraints.weighty = 0.0;
|
|
64
|
0
|
this.addRenderer(axis, constraints);
|
|
65
|
|
}
|
|
66
|
|
|
|
67
|
|
|
|
68
|
|
|
|
69
|
|
|
|
70
|
|
|
|
71
|
0
|
public void setGraphElement(GraphElement element)
|
|
72
|
|
{
|
|
73
|
0
|
super.setGraphElement(element);
|
|
74
|
|
|
|
75
|
0
|
if (element instanceof LabelElement)
|
|
76
|
|
{
|
|
77
|
0
|
JComponent component = ((LabelElement) this.element).getComponent();
|
|
78
|
|
|
|
79
|
0
|
GridBagConstraints constraints = new GridBagConstraints();
|
|
80
|
0
|
constraints.gridx = 0;
|
|
81
|
0
|
constraints.gridy = 0;
|
|
82
|
0
|
constraints.gridwidth = 3;
|
|
83
|
0
|
constraints.fill = GridBagConstraints.HORIZONTAL;
|
|
84
|
0
|
constraints.weightx = 0.0;
|
|
85
|
0
|
constraints.weighty = 0.0;
|
|
86
|
0
|
this.add(component, constraints);
|
|
87
|
|
}
|
|
88
|
|
}
|
|
89
|
|
}
|
|
90
|
|
|