1 package org.catacomb.graph.gui;
2
3
4 import java.awt.Color;
5 import java.awt.GridLayout;
6 import java.awt.event.ComponentEvent;
7 import java.awt.event.ComponentListener;
8
9 import javax.swing.JSplitPane;
10 import javax.swing.border.EmptyBorder;
11
12
13 public class AboveBelowSplitPanel extends BasePanel implements ComponentListener {
14
15 static final long serialVersionUID = 1001;
16
17 AboveBelowSplitPanel follower;
18
19 JSplitPane jSplitPane;
20
21 boolean ignoreMoves = false;
22
23 boolean drawDivider = false;
24
25 BasePanel ctop;
26
27
28 VerticalAxisGraphDivider dependentDivider;
29
30 GraphColors gcols;
31
32 public AboveBelowSplitPanel(BasePanel c1, BasePanel c2, GraphColors gc) {
33 super();
34
35 gcols = gc;
36 ctop = c1;
37
38 boolean CONTINUOUS_LAYOUT = true;
39
40 setLayout(new GridLayout(1, 1, 0, 0));
41 jSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, CONTINUOUS_LAYOUT, c1, c2);
42
43
44 if (c2 instanceof CornerPanel) {
45 jSplitPane.setUI(new AboveBelowSplitAxisPanelUI(gc));
46 } else {
47 jSplitPane.setUI(new AboveBelowSplitPanelUI(gc));
48 }
49
50 jSplitPane.setBorder(new EmptyBorder(0, 0, 0, 0));
51 jSplitPane.setDividerSize(3);
52 add(jSplitPane);
53
54 if (DataDisplay.interactive) {
55 c1.addComponentListener(this);
56 }
57 }
58
59
60 public void setDependentDivider(VerticalAxisGraphDivider agd) {
61 dependentDivider = agd;
62 }
63
64
65
66 public void setBg(Color c) {
67 jSplitPane.setBackground(c);
68 }
69
70
71 public void setDividerSize(int n) {
72 jSplitPane.setDividerSize(n);
73 }
74
75
76 public void setResizeWeight(double d) {
77 jSplitPane.setResizeWeight(d);
78 }
79
80
81 public void componentHidden(ComponentEvent e) {
82 }
83
84
85 public void componentMoved(ComponentEvent e) {
86 }
87
88
89 public void componentResized(ComponentEvent e) {
90 if (ignoreMoves) {
91
92 } else {
93 sliderMoved();
94 }
95 }
96
97
98 public void componentShown(ComponentEvent e) {
99 }
100
101
102
103 public void applyLAF() {
104
105
106 }
107
108
109
110 public void setSplitPanelFollower(AboveBelowSplitPanel absp) {
111 follower = absp;
112
113 follower.follow(this);
114 }
115
116
117 public void sliderMoved() {
118 if (follower != null) {
119 follower.follow(this);
120 }
121
122
123 if (dependentDivider != null) {
124 dependentDivider.repaint();
125 }
126
127 }
128
129
130
131 public int getDividerLocation() {
132 int idl = jSplitPane.getDividerLocation();
133 if (idl < 0) {
134 idl = getHeight() - 36;
135 }
136
137 return idl;
138 }
139
140
141
142 public void setDividerLocation(int dloc) {
143 jSplitPane.setDividerLocation(dloc);
144 }
145
146
147 public void follow(AboveBelowSplitPanel absrc) {
148
149 ignoreMoves = true;
150
151 int srcloc = absrc.getDividerLocation();
152 int iloc = jSplitPane.getDividerLocation();
153 if (iloc != srcloc) {
154 jSplitPane.setDividerLocation(srcloc);
155 }
156
157 ignoreMoves = false;
158 }
159
160 }