1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.jbgui; |
22 |
|
|
23 |
|
import jalview.util.Platform; |
24 |
|
|
25 |
|
import java.awt.Component; |
26 |
|
import java.awt.MouseInfo; |
27 |
|
import java.awt.Point; |
28 |
|
import java.awt.Rectangle; |
29 |
|
|
30 |
|
import javax.swing.JInternalFrame; |
31 |
|
import javax.swing.JSplitPane; |
32 |
|
import javax.swing.plaf.basic.BasicInternalFrameUI; |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 71 (71) |
Complexity: 19 |
Complexity Density: 0.43 |
|
34 |
|
public class GSplitFrame extends JInternalFrame |
35 |
|
{ |
36 |
|
protected static final int DIVIDER_SIZE = 5; |
37 |
|
|
38 |
|
private static final long serialVersionUID = 1L; |
39 |
|
|
40 |
|
private GAlignFrame topFrame; |
41 |
|
|
42 |
|
private GAlignFrame bottomFrame; |
43 |
|
|
44 |
|
private JSplitPane splitPane; |
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
|
private double dividerRatio; |
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
@param |
56 |
|
@param |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
58 |
0 |
public GSplitFrame(GAlignFrame top, GAlignFrame bottom)... |
59 |
|
{ |
60 |
0 |
this.topFrame = top; |
61 |
0 |
this.bottomFrame = bottom; |
62 |
|
|
63 |
0 |
hideTitleBars(); |
64 |
|
|
65 |
0 |
addSplitPane(); |
66 |
|
} |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
71 |
0 |
protected void addSplitPane()... |
72 |
|
{ |
73 |
0 |
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame, |
74 |
|
bottomFrame); |
75 |
0 |
splitPane.setVisible(true); |
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
0 |
int topFrameHeight = topFrame.getHeight(); |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
{ |
88 |
0 |
splitPane.setDividerSize(DIVIDER_SIZE); |
89 |
0 |
if (topFrameHeight == 0) |
90 |
|
{ |
91 |
0 |
setRelativeDividerLocation(0.5d); |
92 |
|
} |
93 |
|
else |
94 |
|
{ |
95 |
0 |
int dividerPosition = topFrameHeight + DIVIDER_SIZE / 2; |
96 |
0 |
splitPane.setDividerLocation(dividerPosition); |
97 |
|
} |
98 |
0 |
splitPane.setResizeWeight(0.5d); |
99 |
|
} |
100 |
0 |
add(splitPane); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
@see |
107 |
|
|
108 |
|
|
109 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
110 |
0 |
protected void hideTitleBars()... |
111 |
|
{ |
112 |
0 |
if (new Platform().isAMac()) |
113 |
|
{ |
114 |
|
|
115 |
0 |
topFrame.putClientProperty("JInternalFrame.isPalette", true); |
116 |
|
|
117 |
0 |
bottomFrame.putClientProperty("JInternalFrame.isPalette", true); |
118 |
|
} |
119 |
|
else |
120 |
|
{ |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
{ |
125 |
0 |
((BasicInternalFrameUI) topFrame.getUI()).setNorthPane(null); |
126 |
0 |
((BasicInternalFrameUI) bottomFrame.getUI()).setNorthPane(null); |
127 |
|
} |
128 |
|
} |
129 |
|
} |
130 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
131 |
0 |
public GAlignFrame getTopFrame()... |
132 |
|
{ |
133 |
0 |
return topFrame; |
134 |
|
} |
135 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
136 |
0 |
public GAlignFrame getBottomFrame()... |
137 |
|
{ |
138 |
0 |
return bottomFrame; |
139 |
|
} |
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
@return |
145 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
146 |
0 |
protected GAlignFrame getFrameAtMouse()... |
147 |
|
{ |
148 |
0 |
Point loc = MouseInfo.getPointerInfo().getLocation(); |
149 |
|
|
150 |
0 |
if (isIn(loc, splitPane.getTopComponent())) |
151 |
|
{ |
152 |
0 |
return getTopFrame(); |
153 |
|
} |
154 |
0 |
else if (isIn(loc, splitPane.getBottomComponent())) |
155 |
|
{ |
156 |
0 |
return getBottomFrame(); |
157 |
|
} |
158 |
0 |
return null; |
159 |
|
} |
160 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
161 |
0 |
private boolean isIn(Point loc, Component comp)... |
162 |
|
{ |
163 |
0 |
if (!comp.isVisible()) |
164 |
|
{ |
165 |
0 |
return false; |
166 |
|
} |
167 |
0 |
Point p = comp.getLocationOnScreen(); |
168 |
0 |
Rectangle r = new Rectangle(p.x, p.y, comp.getWidth(), |
169 |
|
comp.getHeight()); |
170 |
0 |
return r.contains(loc); |
171 |
|
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
177 |
0 |
public void setComplementVisible(Object alignFrame, boolean show)... |
178 |
|
{ |
179 |
|
|
180 |
|
|
181 |
|
|
182 |
0 |
if (show) |
183 |
|
{ |
184 |
0 |
setRelativeDividerLocation(dividerRatio); |
185 |
|
} |
186 |
|
else |
187 |
|
{ |
188 |
0 |
this.dividerRatio = splitPane.getDividerLocation() |
189 |
|
/ (double) (splitPane.getHeight() |
190 |
|
- splitPane.getDividerSize()); |
191 |
|
} |
192 |
|
|
193 |
0 |
if (alignFrame == this.topFrame) |
194 |
|
{ |
195 |
0 |
this.bottomFrame.setVisible(show); |
196 |
|
} |
197 |
0 |
else if (alignFrame == this.bottomFrame) |
198 |
|
{ |
199 |
0 |
this.topFrame.setVisible(show); |
200 |
|
} |
201 |
|
|
202 |
0 |
validate(); |
203 |
|
} |
204 |
|
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
@param |
211 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
212 |
0 |
public void setRelativeDividerLocation(double r)... |
213 |
|
{ |
214 |
0 |
this.dividerRatio = r; |
215 |
|
|
216 |
|
|
217 |
|
|
218 |
|
{ |
219 |
0 |
splitPane.setDividerLocation(r); |
220 |
|
} |
221 |
|
} |
222 |
|
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
|
@return |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
228 |
0 |
protected void setDividerLocation(int p)... |
229 |
|
{ |
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
{ |
234 |
0 |
splitPane.setDividerLocation(p); |
235 |
|
} |
236 |
|
} |
237 |
|
|
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
@return |
242 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
243 |
0 |
protected int getDividerLocation()... |
244 |
|
{ |
245 |
0 |
return splitPane.getDividerLocation(); |
246 |
|
} |
247 |
|
} |