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