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 |
|
|
|
|
| 46.6% |
Uncovered Elements: 39 (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 |
3 |
public GSplitFrame(GAlignFrame top, GAlignFrame bottom)... |
59 |
|
{ |
60 |
3 |
setFrameIcon(null); |
61 |
3 |
setName("jalview-splitframe"); |
62 |
3 |
this.topFrame = top; |
63 |
3 |
this.bottomFrame = bottom; |
64 |
|
|
65 |
3 |
hideTitleBars(); |
66 |
|
|
67 |
3 |
addSplitPane(); |
68 |
|
} |
69 |
|
|
70 |
|
|
71 |
|
|
72 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
73 |
3 |
protected void addSplitPane()... |
74 |
|
{ |
75 |
3 |
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, topFrame, |
76 |
|
bottomFrame); |
77 |
3 |
splitPane.setVisible(true); |
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
|
82 |
|
|
83 |
3 |
int topFrameHeight = topFrame.getHeight(); |
84 |
3 |
splitPane.setDividerSize(DIVIDER_SIZE); |
85 |
3 |
if (topFrameHeight == 0) |
86 |
|
{ |
87 |
0 |
setRelativeDividerLocation(0.5d); |
88 |
|
} |
89 |
|
else |
90 |
|
{ |
91 |
3 |
int dividerPosition = topFrameHeight + DIVIDER_SIZE / 2; |
92 |
3 |
splitPane.setDividerLocation(dividerPosition); |
93 |
|
} |
94 |
3 |
splitPane.setResizeWeight(0.5d); |
95 |
3 |
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 |
3 |
protected void hideTitleBars()... |
106 |
|
{ |
107 |
3 |
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 |
3 |
((BasicInternalFrameUI) topFrame.getUI()).setNorthPane(null); |
117 |
3 |
((BasicInternalFrameUI) bottomFrame.getUI()).setNorthPane(null); |
118 |
|
} |
119 |
|
} |
120 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
121 |
154 |
public GAlignFrame getTopFrame()... |
122 |
|
{ |
123 |
154 |
return topFrame; |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
126 |
145 |
public GAlignFrame getBottomFrame()... |
127 |
|
{ |
128 |
145 |
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
202 |
2 |
public void setRelativeDividerLocation(double r)... |
203 |
|
{ |
204 |
2 |
this.dividerRatio = r; |
205 |
2 |
splitPane.setDividerLocation(r); |
206 |
|
} |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
@return |
212 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
213 |
3 |
protected void setDividerLocation(int p)... |
214 |
|
{ |
215 |
3 |
splitPane.setDividerLocation(p); |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
221 |
|
@return |
222 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
223 |
3 |
protected int getDividerLocation()... |
224 |
|
{ |
225 |
3 |
return splitPane.getDividerLocation(); |
226 |
|
} |
227 |
|
} |