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