1 |
iliev |
1785 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2146 |
* Copyright (C) 2005-2010 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1785 |
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.view.fantasia.basic; |
24 |
|
|
|
25 |
|
|
import java.awt.AlphaComposite; |
26 |
|
|
import java.awt.Color; |
27 |
iliev |
2146 |
import java.awt.Component; |
28 |
iliev |
1785 |
import java.awt.Dimension; |
29 |
|
|
import java.awt.GradientPaint; |
30 |
|
|
import java.awt.Graphics; |
31 |
|
|
import java.awt.Graphics2D; |
32 |
|
|
import java.awt.RenderingHints; |
33 |
|
|
|
34 |
|
|
import java.awt.event.MouseEvent; |
35 |
iliev |
2146 |
import java.awt.event.MouseListener; |
36 |
|
|
import java.awt.event.MouseMotionListener; |
37 |
iliev |
1785 |
|
38 |
|
|
import java.awt.geom.Arc2D; |
39 |
|
|
import java.awt.geom.Line2D; |
40 |
|
|
import java.awt.geom.Rectangle2D; |
41 |
|
|
import java.awt.geom.RoundRectangle2D; |
42 |
|
|
|
43 |
|
|
import javax.swing.ButtonModel; |
44 |
|
|
import javax.swing.DefaultButtonModel; |
45 |
|
|
import javax.swing.JSlider; |
46 |
|
|
|
47 |
|
|
import javax.swing.event.ChangeEvent; |
48 |
|
|
import javax.swing.event.ChangeListener; |
49 |
|
|
|
50 |
|
|
import javax.swing.plaf.basic.BasicSliderUI; |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* |
54 |
|
|
* @author Grigor Iliev |
55 |
|
|
*/ |
56 |
|
|
public class FantasiaFaderUI extends BasicSliderUI implements Trackable { |
57 |
|
|
private ButtonModel knobModel = new DefaultButtonModel(); |
58 |
|
|
private RolloverControlListener rolloverListener = |
59 |
|
|
new RolloverControlListener(this, knobModel); |
60 |
|
|
|
61 |
|
|
public |
62 |
|
|
FantasiaFaderUI(JSlider slider) { |
63 |
|
|
super(slider); |
64 |
|
|
slider.setOpaque(false); |
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
@Override |
68 |
|
|
protected void |
69 |
|
|
installListeners(JSlider slider) { |
70 |
|
|
super.installListeners(slider); |
71 |
|
|
|
72 |
|
|
rolloverListener = new RolloverControlListener(this, knobModel); |
73 |
|
|
slider.addMouseListener(rolloverListener); |
74 |
|
|
slider.addMouseMotionListener(rolloverListener); |
75 |
|
|
|
76 |
|
|
knobModel.addChangeListener(getHandler()); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
@Override |
80 |
|
|
protected void |
81 |
|
|
uninstallListeners(JSlider slider) { |
82 |
|
|
super.uninstallListeners(slider); |
83 |
|
|
slider.removeMouseListener(rolloverListener); |
84 |
|
|
slider.removeMouseMotionListener(rolloverListener); |
85 |
|
|
rolloverListener = null; |
86 |
|
|
|
87 |
|
|
knobModel.removeChangeListener(getHandler()); |
88 |
|
|
} |
89 |
|
|
|
90 |
|
|
@Override |
91 |
|
|
public void |
92 |
|
|
paintTrack(Graphics g) { |
93 |
|
|
Graphics2D g2 = (Graphics2D)g; |
94 |
|
|
|
95 |
|
|
if(slider.getOrientation() == JSlider.HORIZONTAL) { |
96 |
|
|
int cy = (trackRect.height / 2) - 3; |
97 |
|
|
int cw = trackRect.width; |
98 |
|
|
|
99 |
|
|
g.translate(trackRect.x, trackRect.y + cy); |
100 |
|
|
|
101 |
|
|
Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, cw - 1, 3); |
102 |
|
|
g2.setPaint(new Color(0x4b4b4b)); |
103 |
|
|
g2.fill(rect); |
104 |
|
|
|
105 |
|
|
FantasiaPainter.paintBoldInnerBorder(g2, 0, 0, cw - 1, 3); |
106 |
|
|
|
107 |
|
|
g.translate(-trackRect.x, -(trackRect.y + cy)); |
108 |
|
|
|
109 |
|
|
|
110 |
|
|
} else { |
111 |
|
|
int cx = (trackRect.width / 2) - 2; |
112 |
|
|
int ch = trackRect.height; |
113 |
|
|
|
114 |
|
|
g.translate(trackRect.x + cx, trackRect.y); |
115 |
|
|
|
116 |
|
|
Rectangle2D.Double rect = new Rectangle2D.Double(0, 0, 3, ch - 1); |
117 |
|
|
g2.setPaint(new Color(0x4b4b4b)); |
118 |
|
|
g2.fill(rect); |
119 |
|
|
|
120 |
|
|
FantasiaPainter.paintBoldInnerBorder(g2, 0, 0, 3, ch - 1); |
121 |
|
|
|
122 |
|
|
g.translate(-(trackRect.x + cx), -trackRect.y); |
123 |
|
|
|
124 |
|
|
|
125 |
|
|
} |
126 |
|
|
|
127 |
|
|
} |
128 |
|
|
|
129 |
|
|
Color c1 = new Color(0x888888); |
130 |
|
|
Color c2 = new Color(0x555555); |
131 |
|
|
Color c3 = new Color(0xf5f5f5); |
132 |
|
|
Color c4 = new Color(0.0f, 0.0f, 0.0f, 0.10f); |
133 |
|
|
Color c6 = new Color(0.0f, 0.0f, 0.0f, 0.50f); |
134 |
|
|
Color c8 = new Color(0.0f, 0.0f, 0.0f, 0.78f); |
135 |
|
|
|
136 |
|
|
Color c12 = new Color(1.0f, 1.0f, 1.0f, 0.02f); |
137 |
|
|
Color c14 = new Color(1.0f, 1.0f, 1.0f, 0.22f); |
138 |
|
|
Color c16 = new Color(1.0f, 1.0f, 1.0f, 0.50f); |
139 |
|
|
Color c18 = new Color(1.0f, 1.0f, 1.0f, 0.78f); |
140 |
|
|
|
141 |
|
|
public void |
142 |
|
|
paintHorizontalLine(Graphics2D g2, double cy, double x1, double x2, Color c) { |
143 |
|
|
float r = c.getRed(); |
144 |
|
|
r /= 255; |
145 |
|
|
float g = c.getGreen(); |
146 |
|
|
g /= 255; |
147 |
|
|
float b = c.getBlue(); |
148 |
|
|
b /= 255; |
149 |
|
|
|
150 |
|
|
GradientPaint gr = new GradientPaint ( |
151 |
|
|
(float)x1, (float)cy, new Color(r, g, b, 0.40f), |
152 |
|
|
(float)x1 + 3, (float)cy, c |
153 |
|
|
); |
154 |
|
|
|
155 |
|
|
Line2D.Double l; |
156 |
|
|
l = new Line2D.Double(x1, cy, x1 + 3, cy); |
157 |
|
|
|
158 |
|
|
g2.setPaint(gr); |
159 |
|
|
g2.draw(l); |
160 |
|
|
|
161 |
|
|
g2.setPaint(c); |
162 |
|
|
l = new Line2D.Double(x1 + 4, cy, x2 - 5, cy); |
163 |
|
|
g2.draw(l); |
164 |
|
|
|
165 |
|
|
gr = new GradientPaint ( |
166 |
|
|
(float)x2 - 4, (float)cy, c, |
167 |
|
|
(float)x2, (float)cy, new Color(r, g, b, 0.10f) |
168 |
|
|
); |
169 |
|
|
|
170 |
|
|
l = new Line2D.Double(x2 - 4, cy, x2, cy); |
171 |
|
|
g2.setPaint(gr); |
172 |
|
|
g2.draw(l); |
173 |
|
|
} |
174 |
|
|
|
175 |
|
|
public void |
176 |
|
|
paintVerticalLine(Graphics2D g2, double cx, double y1, double y2, Color c) { |
177 |
|
|
float r = c.getRed(); |
178 |
|
|
r /= 255; |
179 |
|
|
float g = c.getGreen(); |
180 |
|
|
g /= 255; |
181 |
|
|
float b = c.getBlue(); |
182 |
|
|
b /= 255; |
183 |
|
|
|
184 |
|
|
GradientPaint gr = new GradientPaint ( |
185 |
|
|
(float)cx, (float)y1, new Color(r, g, b, 0.40f), |
186 |
|
|
(float)cx, (float)y1 + 3, c |
187 |
|
|
); |
188 |
|
|
|
189 |
|
|
Line2D.Double l = new Line2D.Double(cx, y1, cx, y1 + 3); |
190 |
|
|
g2.setPaint(gr); |
191 |
|
|
g2.draw(l); |
192 |
|
|
|
193 |
|
|
g2.setPaint(c); |
194 |
|
|
l = new Line2D.Double(cx, y1 + 4, cx, y2 - 7); |
195 |
|
|
g2.draw(l); |
196 |
|
|
|
197 |
|
|
gr = new GradientPaint ( |
198 |
|
|
(float)cx, (float)y2 - 6, c, |
199 |
|
|
(float)cx, (float)y2, new Color(r, g, b, 0.00f) |
200 |
|
|
); |
201 |
|
|
|
202 |
|
|
l = new Line2D.Double(cx, y2 - 6, cx, y2); |
203 |
|
|
g2.setPaint(gr); |
204 |
|
|
g2.draw(l); |
205 |
|
|
} |
206 |
|
|
|
207 |
|
|
@Override |
208 |
|
|
public void |
209 |
|
|
paintThumb(Graphics g) { |
210 |
|
|
Graphics2D g2 = (Graphics2D)g; |
211 |
|
|
|
212 |
|
|
g2.setRenderingHint ( |
213 |
|
|
RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON |
214 |
|
|
); |
215 |
|
|
|
216 |
|
|
double h = thumbRect.getHeight(); |
217 |
|
|
double w = thumbRect.getWidth(); |
218 |
|
|
|
219 |
|
|
double x1 = thumbRect.x + 2; |
220 |
|
|
double y1 = thumbRect.y + 1; |
221 |
|
|
double x2 = thumbRect.x + w - 3; |
222 |
|
|
double y2 = thumbRect.y + h - 5; |
223 |
|
|
|
224 |
|
|
// body |
225 |
|
|
|
226 |
|
|
RoundRectangle2D.Double rect = new RoundRectangle2D.Double ( |
227 |
|
|
x1, y1, x2 - x1 + 1, y2 - y1 + 1, 8, 8 |
228 |
|
|
); |
229 |
|
|
|
230 |
|
|
Color color = knobModel.isRollover() ? new Color(0x999999) : c1; |
231 |
|
|
if(knobModel.isPressed()) color = new Color(0x777777); |
232 |
|
|
GradientPaint gr = new GradientPaint ( |
233 |
|
|
(float)x1, (float)y1, color, |
234 |
|
|
(float)x1, (float)y2, c2 |
235 |
|
|
); |
236 |
|
|
|
237 |
|
|
g2.setPaint(gr); |
238 |
|
|
g2.fill(rect); |
239 |
|
|
|
240 |
|
|
//border |
241 |
|
|
AlphaComposite ac = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.50f); |
242 |
|
|
g2.setComposite(ac); |
243 |
|
|
g2.setPaint(Color.BLACK); |
244 |
|
|
|
245 |
|
|
rect = new RoundRectangle2D.Double ( |
246 |
|
|
x1 - 1, y1 - 1, x2 - x1 + 2, y2 - y1 + 1, 6, 6 |
247 |
|
|
); |
248 |
|
|
g2.draw(rect); |
249 |
|
|
|
250 |
|
|
g2.setComposite(ac.derive(1.0f)); |
251 |
|
|
gr = new GradientPaint ( |
252 |
|
|
(float)x1, (float)y1 + 1, c14, (float)x1, (float)y1 + 3, c12 |
253 |
|
|
); |
254 |
|
|
|
255 |
|
|
g2.setPaint(gr); |
256 |
|
|
|
257 |
|
|
Arc2D.Double arc = new Arc2D.Double(x1, y1, x2 - x1, 4, 0, 180, Arc2D.OPEN); |
258 |
|
|
//g2.setPaint(Color.WHITE); |
259 |
|
|
g2.draw(arc); |
260 |
|
|
/////// |
261 |
|
|
|
262 |
|
|
|
263 |
|
|
// Shadow down |
264 |
|
|
gr = new GradientPaint ( |
265 |
|
|
(float)x1, (float)y2 - 4, c6, (float)x1, (float)y2 + 4, c4 |
266 |
|
|
); |
267 |
|
|
|
268 |
|
|
g2.setPaint(gr); |
269 |
|
|
|
270 |
|
|
g2.setComposite(ac.derive(0.70f)); |
271 |
|
|
arc = new Arc2D.Double(x1 - 1, y2 - 4, x2 - x1 + 3, 7, 180, 180, Arc2D.PIE); |
272 |
|
|
g2.fill(arc); |
273 |
|
|
|
274 |
|
|
g2.setPaint(Color.BLACK); |
275 |
|
|
g2.setComposite(ac.derive(0.07f)); |
276 |
|
|
arc = new Arc2D.Double(x1 - 1, y2 - 3, x2 - x1 + 2, 5, 180, 180, Arc2D.OPEN); |
277 |
|
|
g2.draw(arc); |
278 |
|
|
|
279 |
|
|
g2.setPaint(Color.BLACK); |
280 |
|
|
g2.setComposite(ac.derive(0.20f)); |
281 |
|
|
Line2D.Double l = new Line2D.Double(x1 + 3, y2 + 1, x2 - 3, y2 + 1); |
282 |
|
|
g2.draw(l); // right |
283 |
|
|
/////// |
284 |
|
|
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
g2.setPaint(c3); |
288 |
|
|
g2.setComposite(ac.derive(0.06f)); |
289 |
|
|
l = new Line2D.Double(x1 + 6, y1 - 1, x1 + 8, y1 - 1); |
290 |
|
|
g2.draw(l); |
291 |
|
|
|
292 |
|
|
|
293 |
|
|
|
294 |
|
|
if(slider.getOrientation() == JSlider.HORIZONTAL) { |
295 |
|
|
double cx = (int)thumbRect.x + w / 2; |
296 |
|
|
|
297 |
|
|
// center line |
298 |
|
|
g2.setComposite(ac.derive(1.0f)); |
299 |
|
|
paintVerticalLine(g2, cx, y1, y2, c3); |
300 |
|
|
|
301 |
|
|
// center down line |
302 |
|
|
g2.setComposite(ac.derive(0.30f)); |
303 |
|
|
paintVerticalLine(g2, cx - 1, y1, y2, Color.BLACK); |
304 |
|
|
/// |
305 |
|
|
|
306 |
|
|
// center up line |
307 |
|
|
g2.setPaint(Color.WHITE); |
308 |
|
|
g2.setComposite(ac.derive(0.10f)); |
309 |
|
|
paintVerticalLine(g2, cx + 1, y1, y2, Color.WHITE); |
310 |
|
|
} else { |
311 |
|
|
double cy = (int) thumbRect.y + h / 2 - 2; |
312 |
|
|
// center line |
313 |
|
|
g2.setComposite(ac.derive(1.0f)); |
314 |
|
|
paintHorizontalLine(g2, cy, x1, x2, c3); |
315 |
|
|
|
316 |
|
|
// center down line |
317 |
|
|
g2.setComposite(ac.derive(0.30f)); |
318 |
|
|
paintHorizontalLine(g2, cy - 1, x1, x2, Color.BLACK); |
319 |
|
|
/// |
320 |
|
|
|
321 |
|
|
// center up line |
322 |
|
|
g2.setPaint(Color.WHITE); |
323 |
|
|
g2.setComposite(ac.derive(0.10f)); |
324 |
|
|
paintHorizontalLine(g2, cy + 1, x1, x2, Color.WHITE); |
325 |
|
|
/// |
326 |
|
|
} |
327 |
|
|
|
328 |
|
|
// border shadow |
329 |
|
|
g2.setPaint(Color.BLACK); |
330 |
|
|
g2.setComposite(ac.derive(0.10f)); |
331 |
|
|
l = new Line2D.Double(x2, y1 + 1, x2, y2 - 2); |
332 |
|
|
g2.draw(l); // right |
333 |
|
|
|
334 |
|
|
|
335 |
|
|
g2.setComposite(ac.derive(0.06f)); |
336 |
|
|
l = new Line2D.Double(x1 - 2, y1 + 2, x1 - 2, y2 - 2); |
337 |
|
|
g2.draw(l);// left |
338 |
|
|
|
339 |
|
|
l = new Line2D.Double(x2 + 2, y1 + 2, x2 + 2, y2 - 2); |
340 |
|
|
g2.draw(l); // right |
341 |
|
|
/// |
342 |
|
|
} |
343 |
|
|
|
344 |
|
|
@Override |
345 |
|
|
public boolean |
346 |
|
|
isInside(MouseEvent e) { |
347 |
|
|
if(thumbRect == null) return false; |
348 |
|
|
return thumbRect.contains(e.getX(), e.getY()); |
349 |
|
|
} |
350 |
|
|
|
351 |
|
|
private final Handler handler = new Handler(); |
352 |
|
|
|
353 |
|
|
private Handler |
354 |
|
|
getHandler() { return handler; } |
355 |
|
|
|
356 |
|
|
private class Handler implements ChangeListener { |
357 |
|
|
@Override |
358 |
|
|
public void stateChanged(ChangeEvent e) { |
359 |
|
|
slider.repaint(thumbRect); |
360 |
|
|
} |
361 |
|
|
|
362 |
|
|
} |
363 |
|
|
|
364 |
|
|
|
365 |
|
|
@Override |
366 |
|
|
protected Dimension |
367 |
|
|
getThumbSize() { |
368 |
|
|
Dimension d = (Dimension)slider.getClientProperty("Fader.knobSize"); |
369 |
|
|
if(d != null) return d; |
370 |
|
|
return slider.getOrientation() == JSlider.VERTICAL ? |
371 |
|
|
new Dimension(27, 20) : new Dimension(17, 27); |
372 |
|
|
} |
373 |
|
|
} |
374 |
iliev |
2146 |
|
375 |
|
|
|
376 |
|
|
|
377 |
|
|
/* |
378 |
|
|
* Copyright (c) 2005-2009 Substance Kirill Grouchnikov. All Rights Reserved. |
379 |
|
|
* |
380 |
|
|
* Redistribution and use in source and binary forms, with or without |
381 |
|
|
* modification, are permitted provided that the following conditions are met: |
382 |
|
|
* |
383 |
|
|
* o Redistributions of source code must retain the above copyright notice, |
384 |
|
|
* this list of conditions and the following disclaimer. |
385 |
|
|
* |
386 |
|
|
* o Redistributions in binary form must reproduce the above copyright notice, |
387 |
|
|
* this list of conditions and the following disclaimer in the documentation |
388 |
|
|
* and/or other materials provided with the distribution. |
389 |
|
|
* |
390 |
|
|
* o Neither the name of Substance Kirill Grouchnikov nor the names of |
391 |
|
|
* its contributors may be used to endorse or promote products derived |
392 |
|
|
* from this software without specific prior written permission. |
393 |
|
|
* |
394 |
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
395 |
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
396 |
|
|
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
397 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
398 |
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
399 |
|
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
400 |
|
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
401 |
|
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
402 |
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
403 |
|
|
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
404 |
|
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
405 |
|
|
*/ |
406 |
|
|
|
407 |
|
|
/** @author Kirill Grouchnikov */ |
408 |
|
|
interface Trackable { public boolean isInside(MouseEvent me); } |
409 |
|
|
|
410 |
|
|
/** |
411 |
|
|
* Control listener for rollover effects. Tracks the mouse motion interaction |
412 |
|
|
* for the associated {@link org.jvnet.substance.utils.Trackable} control. This |
413 |
|
|
* class is <b>for internal use only</b>. |
414 |
|
|
* |
415 |
|
|
* @author Kirill Grouchnikov |
416 |
|
|
*/ |
417 |
|
|
class RolloverControlListener implements MouseListener, |
418 |
|
|
MouseMotionListener { |
419 |
|
|
/** |
420 |
|
|
* If the mouse pointer is currently inside the designated area (fetched |
421 |
|
|
* from the associated {@link #trackableUI}), <code>this</code> flag is |
422 |
|
|
* <code>true</code>. |
423 |
|
|
*/ |
424 |
|
|
private boolean isMouseInside; |
425 |
|
|
|
426 |
|
|
/** |
427 |
|
|
* Surrogate model for tracking control status. |
428 |
|
|
*/ |
429 |
|
|
private ButtonModel model; |
430 |
|
|
|
431 |
|
|
/** |
432 |
|
|
* Object that is queried for mouse events. This object is responsible for |
433 |
|
|
* handling the designated (hot-spot) area of the associated control. |
434 |
|
|
*/ |
435 |
|
|
private Trackable trackableUI; |
436 |
|
|
|
437 |
|
|
/** |
438 |
|
|
* Simple constructor. |
439 |
|
|
* |
440 |
|
|
* @param trackableUI |
441 |
|
|
* Object that is queried for mouse events. |
442 |
|
|
* @param model |
443 |
|
|
* Surrogate model for tracking control status. |
444 |
|
|
*/ |
445 |
|
|
public RolloverControlListener(Trackable trackableUI, ButtonModel model) { |
446 |
|
|
this.trackableUI = trackableUI; |
447 |
|
|
this.model = model; |
448 |
|
|
this.isMouseInside = false; |
449 |
|
|
} |
450 |
|
|
|
451 |
|
|
/* |
452 |
|
|
* (non-Javadoc) |
453 |
|
|
* |
454 |
|
|
* @see java.awt.event.MouseListener#mouseEntered(java.awt.event.MouseEvent) |
455 |
|
|
*/ |
456 |
|
|
public void mouseEntered(MouseEvent e) { |
457 |
|
|
Component component = (Component) e.getSource(); |
458 |
|
|
if (!component.isEnabled()) |
459 |
|
|
return; |
460 |
|
|
boolean isInside = this.trackableUI.isInside(e); |
461 |
|
|
// boolean isInsideChanged = (this.isMouseInside != isInside); |
462 |
|
|
this.isMouseInside = isInside; |
463 |
|
|
this.model.setRollover(isInside); |
464 |
|
|
this.model.setEnabled(component.isEnabled()); |
465 |
|
|
} |
466 |
|
|
|
467 |
|
|
/* |
468 |
|
|
* (non-Javadoc) |
469 |
|
|
* |
470 |
|
|
* @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent) |
471 |
|
|
*/ |
472 |
|
|
public void mouseExited(MouseEvent e) { |
473 |
|
|
Component component = (Component) e.getSource(); |
474 |
|
|
if (!component.isEnabled()) |
475 |
|
|
return; |
476 |
|
|
// boolean isInsideChanged = (this.isMouseInside != false); |
477 |
|
|
this.isMouseInside = false; |
478 |
|
|
this.model.setRollover(false); |
479 |
|
|
this.model.setEnabled(component.isEnabled()); |
480 |
|
|
} |
481 |
|
|
|
482 |
|
|
/* |
483 |
|
|
* (non-Javadoc) |
484 |
|
|
* |
485 |
|
|
* @see |
486 |
|
|
* java.awt.event.MouseListener#mouseReleased(java.awt.event.MouseEvent) |
487 |
|
|
*/ |
488 |
|
|
public void mouseReleased(MouseEvent e) { |
489 |
|
|
// System.out.println("mouse released [" + e.getX() + ":" + e.getY() + |
490 |
|
|
// "]"); |
491 |
|
|
Component component = (Component) e.getSource(); |
492 |
|
|
if (!component.isEnabled()) |
493 |
|
|
return; |
494 |
|
|
boolean isInside = this.trackableUI.isInside(e); |
495 |
|
|
// boolean isInsideChanged = (this.isMouseInside != isInside); |
496 |
|
|
this.isMouseInside = isInside; |
497 |
|
|
this.model.setRollover(this.isMouseInside); |
498 |
|
|
this.model.setPressed(false); |
499 |
|
|
this.model.setArmed(false); |
500 |
|
|
this.model.setSelected(false); |
501 |
|
|
this.model.setEnabled(component.isEnabled()); |
502 |
|
|
} |
503 |
|
|
|
504 |
|
|
/* |
505 |
|
|
* (non-Javadoc) |
506 |
|
|
* |
507 |
|
|
* @see java.awt.event.MouseListener#mousePressed(java.awt.event.MouseEvent) |
508 |
|
|
*/ |
509 |
|
|
public void mousePressed(MouseEvent e) { |
510 |
|
|
// System.out.println("mouse pressed [" + e.getX() + ":" + e.getY() + |
511 |
|
|
// "]"); |
512 |
|
|
Component component = (Component) e.getSource(); |
513 |
|
|
if (!component.isEnabled()) |
514 |
|
|
return; |
515 |
|
|
boolean isInside = this.trackableUI.isInside(e); |
516 |
|
|
// boolean isInsideChanged = (this.isMouseInside != isInside); |
517 |
|
|
this.isMouseInside = isInside; |
518 |
|
|
this.model.setRollover(this.isMouseInside); |
519 |
|
|
if (this.isMouseInside) { |
520 |
|
|
this.model.setPressed(true); |
521 |
|
|
this.model.setArmed(true); |
522 |
|
|
this.model.setSelected(true); |
523 |
|
|
} |
524 |
|
|
this.model.setEnabled(component.isEnabled()); |
525 |
|
|
} |
526 |
|
|
|
527 |
|
|
/* |
528 |
|
|
* (non-Javadoc) |
529 |
|
|
* |
530 |
|
|
* @see |
531 |
|
|
* java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent |
532 |
|
|
* ) |
533 |
|
|
*/ |
534 |
|
|
public void mouseDragged(MouseEvent e) { |
535 |
|
|
// System.out.println("mouse dragged [" + e.getX() + ":" + e.getY() + |
536 |
|
|
// "]"); |
537 |
|
|
Component component = (Component) e.getSource(); |
538 |
|
|
if (!component.isEnabled()) |
539 |
|
|
return; |
540 |
|
|
boolean isInside = this.trackableUI.isInside(e); |
541 |
|
|
// boolean isInsideChanged = (this.isMouseInside != isInside); |
542 |
|
|
this.isMouseInside = isInside; |
543 |
|
|
this.model.setEnabled(component.isEnabled()); |
544 |
|
|
} |
545 |
|
|
|
546 |
|
|
/* |
547 |
|
|
* (non-Javadoc) |
548 |
|
|
* |
549 |
|
|
* @see |
550 |
|
|
* java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent) |
551 |
|
|
*/ |
552 |
|
|
public void mouseMoved(MouseEvent e) { |
553 |
|
|
// System.out.println("mouse moved [" + e.getX() + ":" + e.getY() + |
554 |
|
|
// "]"); |
555 |
|
|
Component component = (Component) e.getSource(); |
556 |
|
|
if (!component.isEnabled()) |
557 |
|
|
return; |
558 |
|
|
boolean isInside = this.trackableUI.isInside(e); |
559 |
|
|
// System.out.println("inside"); |
560 |
|
|
// boolean isInsideChanged = (this.isMouseInside != isInside); |
561 |
|
|
this.isMouseInside = isInside; |
562 |
|
|
this.model.setRollover(isInside); |
563 |
|
|
this.model.setEnabled(component.isEnabled()); |
564 |
|
|
} |
565 |
|
|
|
566 |
|
|
/* |
567 |
|
|
* (non-Javadoc) |
568 |
|
|
* |
569 |
|
|
* @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent) |
570 |
|
|
*/ |
571 |
|
|
public void mouseClicked(MouseEvent e) { |
572 |
|
|
} |
573 |
|
|
} |