1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import java.awt.Color; |
24 |
|
import java.awt.Cursor; |
25 |
|
import java.awt.Graphics; |
26 |
|
import java.awt.event.MouseEvent; |
27 |
|
import java.awt.event.MouseListener; |
28 |
|
import java.awt.event.MouseMotionListener; |
29 |
|
|
30 |
|
import javax.swing.JPanel; |
31 |
|
|
32 |
|
import jalview.api.AlignViewportI; |
33 |
|
import jalview.bin.Cache; |
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
@author |
39 |
|
@version |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 76 (76) |
Complexity: 23 |
Complexity Density: 0.47 |
|
41 |
|
public class IdwidthAdjuster extends JPanel |
42 |
|
implements MouseListener, MouseMotionListener |
43 |
|
{ |
44 |
|
public static final int MIN_ID_WIDTH = 20; |
45 |
|
|
46 |
|
int oldX = 0; |
47 |
|
|
48 |
|
AlignmentPanel ap; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
@param |
54 |
|
|
55 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
56 |
0 |
public IdwidthAdjuster(AlignmentPanel ap)... |
57 |
|
{ |
58 |
0 |
this.ap = ap; |
59 |
0 |
setBackground(Color.white); |
60 |
0 |
addMouseListener(this); |
61 |
0 |
addMouseMotionListener(this); |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
@param |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
0 |
@Override... |
70 |
|
public void mousePressed(MouseEvent evt) |
71 |
|
{ |
72 |
0 |
oldX = evt.getX(); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
|
81 |
|
@param |
82 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
83 |
0 |
@Override... |
84 |
|
public void mouseReleased(MouseEvent evt) |
85 |
|
{ |
86 |
0 |
repaint(); |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
0 |
final AlignViewportI viewport = ap.getAlignViewport(); |
92 |
0 |
if (viewport.getCodingComplement() != null) |
93 |
|
{ |
94 |
0 |
viewport.getCodingComplement().setIdWidth(viewport.getIdWidth()); |
95 |
0 |
SplitFrame sf = (SplitFrame) ap.alignFrame.getSplitViewContainer(); |
96 |
0 |
sf.repaint(); |
97 |
|
} |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
@param |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
0 |
@Override... |
106 |
|
public void mouseEntered(MouseEvent evt) |
107 |
|
{ |
108 |
0 |
repaint(); |
109 |
|
} |
110 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
111 |
0 |
@Override... |
112 |
|
public void mouseExited(MouseEvent evt) |
113 |
|
{ |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
|
|
120 |
|
@param |
121 |
|
|
|
|
| 0% |
Uncovered Elements: 31 (31) |
Complexity: 9 |
Complexity Density: 0.43 |
|
122 |
0 |
@Override... |
123 |
|
public void mouseDragged(MouseEvent evt) |
124 |
|
{ |
125 |
0 |
int mouseX = evt.getX(); |
126 |
0 |
final AlignViewportI viewport = ap.getAlignViewport(); |
127 |
0 |
int curwidth = viewport.getIdWidth(); |
128 |
0 |
int dif = mouseX - oldX; |
129 |
|
|
130 |
0 |
final int newWidth = curwidth + dif; |
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
0 |
if (newWidth < MIN_ID_WIDTH || newWidth > this.ap.getWidth()) |
136 |
|
{ |
137 |
0 |
return; |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
0 |
if (viewport.getWrapAlignment()) |
144 |
|
{ |
145 |
0 |
SeqCanvas sc = ap.getSeqPanel().seqCanvas; |
146 |
0 |
if (sc != null && sc.getWrappedCanvasWidth(sc.getWidth() - dif) < 1) |
147 |
|
{ |
148 |
0 |
return; |
149 |
|
} |
150 |
|
} |
151 |
|
|
152 |
0 |
oldX = evt.getX(); |
153 |
|
|
154 |
|
|
155 |
|
|
156 |
|
|
157 |
0 |
if (dif > 0 && mouseX < 0) |
158 |
|
{ |
159 |
0 |
return; |
160 |
|
} |
161 |
|
|
162 |
|
|
163 |
0 |
int curCol = viewport.getRanges().getStartRes() |
164 |
|
+ viewport.getRanges().getViewportWidth(); |
165 |
|
|
166 |
0 |
viewport.setIdWidth(newWidth); |
167 |
|
|
168 |
0 |
ap.validateAnnotationDimensions(false); |
169 |
0 |
if (viewport.getWrapAlignment()) |
170 |
|
{ |
171 |
0 |
viewport.getRanges().scrollToWrappedVisible( |
172 |
|
curCol - viewport.getRanges().getViewportWidth()); |
173 |
|
} |
174 |
0 |
ap.paintAlignment(true, false); |
175 |
|
|
176 |
0 |
ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true); |
177 |
|
} |
178 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 3 |
Complexity Density: 0.6 |
|
179 |
0 |
public void setWidth(int newWidth)... |
180 |
|
{ |
181 |
0 |
if (newWidth < MIN_ID_WIDTH |
182 |
|
|| ap.getIdPanel().getIdCanvas().isManuallyAdjusted()) |
183 |
|
{ |
184 |
0 |
return; |
185 |
|
} |
186 |
0 |
final AlignViewportI viewport = ap.getAlignViewport(); |
187 |
0 |
viewport.setIdWidth(newWidth); |
188 |
0 |
ap.paintAlignment(true, false); |
189 |
|
} |
190 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
191 |
0 |
public boolean manuallyAdjusted()... |
192 |
|
{ |
193 |
0 |
return ap.getIdPanel().getIdCanvas().isManuallyAdjusted(); |
194 |
|
} |
195 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
196 |
0 |
@Override... |
197 |
|
public void mouseMoved(MouseEvent evt) |
198 |
|
{ |
199 |
|
} |
200 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
201 |
0 |
@Override... |
202 |
|
public void mouseClicked(MouseEvent evt) |
203 |
|
{ |
204 |
|
} |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
@param |
210 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.2 |
|
211 |
0 |
@Override... |
212 |
|
public void paintComponent(Graphics g) |
213 |
|
{ |
214 |
0 |
int width = getWidth(); |
215 |
0 |
int height = getHeight(); |
216 |
0 |
g.setColor(Color.white); |
217 |
0 |
g.fillRect(0, 0, width, height); |
218 |
|
|
219 |
0 |
if (!Cache.getDefault(AnnotationLabels.RESIZE_MARGINS_MARK_PREF, false)) |
220 |
|
|
221 |
|
|
222 |
|
{ |
223 |
0 |
int spacer = Math.max(2, AnnotationLabels.HEIGHT_ADJUSTER_HEIGHT / 4); |
224 |
0 |
g.setColor(Color.LIGHT_GRAY); |
225 |
0 |
g.drawLine(width - 3 * spacer, 0, width - 3 * spacer, height / 2); |
226 |
0 |
g.drawLine(width - spacer, 0, width - spacer, height / 2); |
227 |
|
} |
228 |
|
|
229 |
0 |
setCursor(Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR)); |
230 |
|
} |
231 |
|
} |