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 |
|
|
|
|
| 45.8% |
Uncovered Elements: 39 (72) |
Complexity: 19 |
Complexity Density: 0.42 |
|
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
58 |
3 |
public GSplitFrame(GAlignFrame top, GAlignFrame bottom)... |
59 |
|
{ |
60 |
3 |
setName("jalview-splitframe"); |
61 |
3 |
this.topFrame = top; |
62 |
3 |
this.bottomFrame = bottom; |
63 |
|
|
64 |
3 |
hideTitleBars(); |
65 |
|
|
66 |
3 |
addSplitPane(); |
67 |
|
} |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
72 |
3 |
protected void addSplitPane()... |
73 |
|
{ |
74 |
3 |
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame, |
75 |
|
bottomFrame); |
76 |
3 |
splitPane.setVisible(true); |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
3 |
int topFrameHeight = topFrame.getHeight(); |
83 |
3 |
splitPane.setDividerSize(DIVIDER_SIZE); |
84 |
3 |
if (topFrameHeight == 0) |
85 |
|
{ |
86 |
0 |
setRelativeDividerLocation(0.5d); |
87 |
|
} |
88 |
|
else |
89 |
|
{ |
90 |
3 |
int dividerPosition = topFrameHeight + DIVIDER_SIZE / 2; |
91 |
3 |
splitPane.setDividerLocation(dividerPosition); |
92 |
|
} |
93 |
3 |
splitPane.setResizeWeight(0.5d); |
94 |
3 |
add(splitPane); |
95 |
|
} |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
@see |
101 |
|
|
102 |
|
|
103 |
|
|
|
|
| 57.1% |
Uncovered Elements: 3 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
104 |
3 |
protected void hideTitleBars()... |
105 |
|
{ |
106 |
3 |
if (Platform.isAMacAndNotJS()) |
107 |
|
{ |
108 |
|
|
109 |
0 |
topFrame.putClientProperty("JInternalFrame.isPalette", true); |
110 |
|
|
111 |
0 |
bottomFrame.putClientProperty("JInternalFrame.isPalette", true); |
112 |
|
} |
113 |
|
else |
114 |
|
{ |
115 |
3 |
((BasicInternalFrameUI) topFrame.getUI()).setNorthPane(null); |
116 |
3 |
((BasicInternalFrameUI) bottomFrame.getUI()).setNorthPane(null); |
117 |
|
} |
118 |
|
} |
119 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
120 |
109 |
public GAlignFrame getTopFrame()... |
121 |
|
{ |
122 |
109 |
return topFrame; |
123 |
|
} |
124 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
125 |
100 |
public GAlignFrame getBottomFrame()... |
126 |
|
{ |
127 |
100 |
return bottomFrame; |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
@return |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
135 |
0 |
protected GAlignFrame getFrameAtMouse()... |
136 |
|
{ |
137 |
0 |
Point loc = MouseInfo.getPointerInfo().getLocation(); |
138 |
|
|
139 |
0 |
if (isIn(loc, splitPane.getTopComponent())) |
140 |
|
{ |
141 |
0 |
return getTopFrame(); |
142 |
|
} |
143 |
0 |
else if (isIn(loc, splitPane.getBottomComponent())) |
144 |
|
{ |
145 |
0 |
return getBottomFrame(); |
146 |
|
} |
147 |
0 |
return null; |
148 |
|
} |
149 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
150 |
0 |
private boolean isIn(Point loc, Component comp)... |
151 |
|
{ |
152 |
0 |
if (!comp.isVisible()) |
153 |
|
{ |
154 |
0 |
return false; |
155 |
|
} |
156 |
0 |
Point p = comp.getLocationOnScreen(); |
157 |
0 |
Rectangle r = new Rectangle(p.x, p.y, comp.getWidth(), |
158 |
|
comp.getHeight()); |
159 |
0 |
return r.contains(loc); |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
|
|
164 |
|
|
165 |
|
|
|
|
| 0% |
Uncovered Elements: 14 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
166 |
0 |
public void setComplementVisible(Object alignFrame, boolean show)... |
167 |
|
{ |
168 |
|
|
169 |
|
|
170 |
|
|
171 |
0 |
if (show) |
172 |
|
{ |
173 |
0 |
setRelativeDividerLocation(dividerRatio); |
174 |
|
} |
175 |
|
else |
176 |
|
{ |
177 |
0 |
this.dividerRatio = splitPane.getDividerLocation() |
178 |
|
/ (double) (splitPane.getHeight() |
179 |
|
- splitPane.getDividerSize()); |
180 |
|
} |
181 |
|
|
182 |
0 |
if (alignFrame == this.topFrame) |
183 |
|
{ |
184 |
0 |
this.bottomFrame.setVisible(show); |
185 |
|
} |
186 |
0 |
else if (alignFrame == this.bottomFrame) |
187 |
|
{ |
188 |
0 |
this.topFrame.setVisible(show); |
189 |
|
} |
190 |
|
|
191 |
0 |
validate(); |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
|
@param |
200 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
201 |
2 |
public void setRelativeDividerLocation(double r)... |
202 |
|
{ |
203 |
2 |
this.dividerRatio = r; |
204 |
2 |
splitPane.setDividerLocation(r); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
@return |
211 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
212 |
3 |
protected void setDividerLocation(int p)... |
213 |
|
{ |
214 |
3 |
splitPane.setDividerLocation(p); |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
@return |
221 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
222 |
3 |
protected int getDividerLocation()... |
223 |
|
{ |
224 |
3 |
return splitPane.getDividerLocation(); |
225 |
|
} |
226 |
|
} |