|
@@ -44,84 +44,74 @@ import javax.swing.JPanel;
|
44
|
44
|
* colour visually.
|
45
|
45
|
* @author chris
|
46
|
46
|
*/
|
47
|
|
-public final class ColourPickerPanel extends JPanel implements MouseListener, MouseMotionListener {
|
48
|
|
-
|
49
|
|
- /** ActionEvent ID for when a hex colour is selected. */
|
50
|
|
- public static final int ACTION_HEX = 10001;
|
51
|
|
- /** ActionEvent ID for when an irc colour is selected. */
|
52
|
|
- public static final int ACTION_IRC = 10002;
|
53
|
|
-
|
|
47
|
+public final class ColourPickerPanel extends JPanel implements MouseListener,
|
|
48
|
+ MouseMotionListener {
|
|
49
|
+
|
54
|
50
|
/**
|
55
|
51
|
* A version number for this class. It should be changed whenever the class
|
56
|
52
|
* structure is changed (or anything else that would prevent serialized
|
57
|
53
|
* objects being unserialized with the new class).
|
58
|
54
|
*/
|
59
|
55
|
private static final long serialVersionUID = 1;
|
60
|
|
-
|
|
56
|
+ /** ActionEvent ID for when a hex colour is selected. */
|
|
57
|
+ public static final int ACTION_HEX = 10001;
|
|
58
|
+ /** ActionEvent ID for when an irc colour is selected. */
|
|
59
|
+ public static final int ACTION_IRC = 10002;
|
61
|
60
|
/** The width of each IRC colour patch. */
|
62
|
61
|
private static final int IRC_WIDTH = 9;
|
63
|
62
|
/** The height of each IRC colour patch. */
|
64
|
63
|
private static final int IRC_HEIGHT = 16;
|
65
|
|
-
|
66
|
64
|
/** The width of the hex colour patch. */
|
67
|
65
|
private static final int HEX_WIDTH = 125;
|
68
|
66
|
/** The height of the hex colour patch. */
|
69
|
67
|
private static final int HEX_HEIGHT = 125;
|
70
|
|
-
|
71
|
68
|
/** The size of borders to use. */
|
72
|
69
|
private static final int BORDER_SIZE = 7;
|
73
|
70
|
/** The size of slider to use. */
|
74
|
71
|
private static final int SLIDER_WIDTH = 10;
|
75
|
72
|
/** The height of the preview area. */
|
76
|
73
|
private static final int PREVIEW_HEIGHT = 20;
|
77
|
|
-
|
78
|
74
|
/** Whether to show IRC colours. */
|
79
|
75
|
private final boolean showIrc;
|
80
|
|
-
|
81
|
76
|
/** Whether to show hex colours. */
|
82
|
77
|
private final boolean showHex;
|
83
|
|
-
|
84
|
78
|
/** The y-coord of the start of the IRC colours block. */
|
85
|
79
|
private int ircOffset;
|
86
|
|
-
|
87
|
80
|
/** The y-coord of the start of the hex colours block. */
|
88
|
81
|
private int hexOffset;
|
89
|
|
-
|
90
|
82
|
/** The y-coord of the start of the preview block. */
|
91
|
83
|
private int previewOffset;
|
92
|
|
-
|
93
|
84
|
/** The saturation to use. */
|
94
|
85
|
private float saturation = (float) 1.0;
|
95
|
|
-
|
96
|
86
|
/** The colour to show in the preview window. */
|
97
|
87
|
private Color preview;
|
98
|
|
-
|
99
|
88
|
/** Rectangle we use to indicate that only the preview should be drawn. */
|
100
|
89
|
private Rectangle previewRect;
|
101
|
|
-
|
102
|
90
|
/** A list of registered actionlisteners. */
|
103
|
|
- private final List<ActionListener> listeners = new ArrayList<ActionListener>();
|
104
|
|
-
|
|
91
|
+ private final List<ActionListener> listeners =
|
|
92
|
+ new ArrayList<ActionListener>();
|
|
93
|
+
|
105
|
94
|
/**
|
106
|
95
|
* Creates a new instance of ColourPickerPanel.
|
107
|
96
|
* @param newShowIrc Whether to show IRC colours or not
|
108
|
97
|
* @param newShowHex Whether to show hex colours or not
|
109
|
98
|
*/
|
110
|
|
- public ColourPickerPanel(final boolean newShowIrc, final boolean newShowHex) {
|
|
99
|
+ public ColourPickerPanel(final boolean newShowIrc,
|
|
100
|
+ final boolean newShowHex) {
|
111
|
101
|
super();
|
112
|
|
-
|
|
102
|
+
|
113
|
103
|
this.showIrc = newShowIrc;
|
114
|
104
|
this.showHex = newShowHex;
|
115
|
|
-
|
116
|
|
- final int height = 65 + (showIrc ? 30 : 0) + (showHex ? 145 : 0)
|
117
|
|
- + (showHex & showIrc ? 10 : 0);
|
118
|
|
-
|
|
105
|
+
|
|
106
|
+ final int height = 65 + (showIrc ? 30 : 0) + (showHex ? 145 : 0) + (showHex & showIrc
|
|
107
|
+ ? 10 : 0);
|
|
108
|
+
|
119
|
109
|
setPreferredSize(new Dimension(160, height));
|
120
|
|
-
|
|
110
|
+
|
121
|
111
|
addMouseListener(this);
|
122
|
112
|
addMouseMotionListener(this);
|
123
|
113
|
}
|
124
|
|
-
|
|
114
|
+
|
125
|
115
|
/**
|
126
|
116
|
* Creates a new instance of ColourPickerPanel, showing both IRC and Hex
|
127
|
117
|
* colours.
|
|
@@ -129,98 +119,113 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
129
|
119
|
public ColourPickerPanel() {
|
130
|
120
|
this(true, true);
|
131
|
121
|
}
|
132
|
|
-
|
|
122
|
+
|
133
|
123
|
/** {@inheritDoc} */
|
|
124
|
+ @Override
|
134
|
125
|
public void paint(final Graphics g) {
|
135
|
126
|
int offset = 20;
|
136
|
|
-
|
|
127
|
+
|
137
|
128
|
if (previewRect == null || !previewRect.equals(g.getClipBounds())) {
|
138
|
129
|
g.setColor(getBackground());
|
139
|
|
-
|
|
130
|
+
|
140
|
131
|
g.fillRect(0, 0, getWidth(), getHeight());
|
141
|
|
-
|
|
132
|
+
|
142
|
133
|
g.setColor(Color.BLACK);
|
143
|
|
-
|
|
134
|
+
|
144
|
135
|
if (showIrc) {
|
145
|
136
|
g.drawString("IRC Colours", BORDER_SIZE, offset);
|
146
|
|
-
|
|
137
|
+
|
147
|
138
|
offset += BORDER_SIZE;
|
148
|
|
-
|
|
139
|
+
|
149
|
140
|
ircOffset = offset;
|
150
|
|
-
|
|
141
|
+
|
151
|
142
|
for (int i = 0; i < 16; i++) {
|
152
|
143
|
g.setColor(ColourManager.getColour(i));
|
153
|
|
- g.fillRect(i * IRC_WIDTH + BORDER_SIZE, offset, IRC_WIDTH, IRC_HEIGHT);
|
|
144
|
+ g.fillRect(i * IRC_WIDTH + BORDER_SIZE, offset, IRC_WIDTH,
|
|
145
|
+ IRC_HEIGHT);
|
154
|
146
|
g.setColor(Color.BLACK);
|
155
|
|
- g.drawRect(i * IRC_WIDTH + BORDER_SIZE, offset, IRC_WIDTH, IRC_HEIGHT);
|
|
147
|
+ g.drawRect(i * IRC_WIDTH + BORDER_SIZE, offset, IRC_WIDTH,
|
|
148
|
+ IRC_HEIGHT);
|
156
|
149
|
}
|
157
|
|
-
|
|
150
|
+
|
158
|
151
|
offset += IRC_HEIGHT + 20;
|
159
|
152
|
}
|
160
|
|
-
|
|
153
|
+
|
161
|
154
|
if (showHex) {
|
162
|
155
|
g.drawString("Hex Colours", BORDER_SIZE, offset);
|
163
|
|
-
|
|
156
|
+
|
164
|
157
|
offset += BORDER_SIZE;
|
165
|
|
-
|
|
158
|
+
|
166
|
159
|
hexOffset = offset;
|
167
|
|
-
|
|
160
|
+
|
168
|
161
|
for (int i = HEX_WIDTH; i > 0; i--) {
|
169
|
162
|
for (int j = HEX_HEIGHT; j > 0; j--) {
|
170
|
|
- g.setColor(new Color(Color.HSBtoRGB((float) i / HEX_WIDTH, saturation, (float) j / HEX_HEIGHT)));
|
171
|
|
- g.drawLine(BORDER_SIZE + i, offset + HEX_HEIGHT - j, BORDER_SIZE + i, offset + HEX_HEIGHT - j);
|
|
163
|
+ g.setColor(new Color(Color.HSBtoRGB((float) i /
|
|
164
|
+ HEX_WIDTH, saturation, (float) j / HEX_HEIGHT)));
|
|
165
|
+ g.drawLine(BORDER_SIZE + i, offset + HEX_HEIGHT - j,
|
|
166
|
+ BORDER_SIZE + i, offset + HEX_HEIGHT - j);
|
172
|
167
|
}
|
173
|
168
|
}
|
174
|
|
-
|
|
169
|
+
|
175
|
170
|
g.setColor(Color.BLACK);
|
176
|
171
|
g.drawRect(BORDER_SIZE, offset, HEX_HEIGHT, HEX_WIDTH);
|
177
|
|
-
|
|
172
|
+
|
178
|
173
|
g.drawRect(BORDER_SIZE * 2 + HEX_WIDTH, offset, 10, HEX_HEIGHT);
|
179
|
|
-
|
|
174
|
+
|
180
|
175
|
for (int i = 1; i < HEX_HEIGHT; i++) {
|
181
|
|
- g.setColor(new Color(Color.HSBtoRGB(0, (float) i / HEX_HEIGHT, 1)));
|
|
176
|
+ g.setColor(new Color(Color.HSBtoRGB(0, (float) i /
|
|
177
|
+ HEX_HEIGHT, 1)));
|
182
|
178
|
g.drawLine(BORDER_SIZE * 2 + HEX_WIDTH + 1, offset + i,
|
183
|
|
- BORDER_SIZE * 2 + HEX_WIDTH + SLIDER_WIDTH - 1, offset + i);
|
|
179
|
+ BORDER_SIZE * 2 + HEX_WIDTH + SLIDER_WIDTH - 1,
|
|
180
|
+ offset + i);
|
184
|
181
|
}
|
185
|
|
-
|
|
182
|
+
|
186
|
183
|
final Polygon arrow = new Polygon();
|
187
|
|
-
|
188
|
|
- arrow.addPoint(HEX_WIDTH + BORDER_SIZE * 2 + 4, offset + Math.round(saturation * HEX_HEIGHT));
|
189
|
|
- arrow.addPoint(HEX_WIDTH + BORDER_SIZE * 2 + 13, offset + Math.round(saturation * HEX_HEIGHT) + 5);
|
190
|
|
- arrow.addPoint(HEX_WIDTH + BORDER_SIZE * 2 + 13, offset + Math.round(saturation * HEX_HEIGHT) - 5);
|
191
|
|
-
|
|
184
|
+
|
|
185
|
+ arrow.addPoint(HEX_WIDTH + BORDER_SIZE * 2 + 4, offset +
|
|
186
|
+ Math.round(saturation * HEX_HEIGHT));
|
|
187
|
+ arrow.addPoint(HEX_WIDTH + BORDER_SIZE * 2 + 13, offset +
|
|
188
|
+ Math.round(saturation * HEX_HEIGHT) + 5);
|
|
189
|
+ arrow.addPoint(HEX_WIDTH + BORDER_SIZE * 2 + 13, offset +
|
|
190
|
+ Math.round(saturation * HEX_HEIGHT) - 5);
|
|
191
|
+
|
192
|
192
|
g.setColor(Color.BLACK);
|
193
|
193
|
g.fillPolygon(arrow);
|
194
|
|
-
|
|
194
|
+
|
195
|
195
|
offset += HEX_HEIGHT + 20;
|
196
|
196
|
}
|
197
|
|
-
|
|
197
|
+
|
198
|
198
|
g.drawString("Preview", BORDER_SIZE, offset);
|
199
|
|
-
|
|
199
|
+
|
200
|
200
|
offset += BORDER_SIZE;
|
201
|
|
-
|
|
201
|
+
|
202
|
202
|
previewOffset = offset;
|
203
|
|
-
|
|
203
|
+
|
204
|
204
|
if (previewRect == null) {
|
205
|
|
- previewRect = new Rectangle(0, previewOffset, getWidth(), PREVIEW_HEIGHT);
|
|
205
|
+ previewRect = new Rectangle(0, previewOffset, getWidth(),
|
|
206
|
+ PREVIEW_HEIGHT);
|
206
|
207
|
}
|
207
|
208
|
} else {
|
208
|
209
|
offset = previewOffset;
|
209
|
210
|
}
|
210
|
|
-
|
211
|
|
- g.drawRect(BORDER_SIZE, offset, getWidth() - BORDER_SIZE * 2, PREVIEW_HEIGHT);
|
212
|
|
-
|
|
211
|
+
|
|
212
|
+ g.drawRect(BORDER_SIZE, offset, getWidth() - BORDER_SIZE * 2,
|
|
213
|
+ PREVIEW_HEIGHT);
|
|
214
|
+
|
213
|
215
|
if (preview == null) {
|
214
|
216
|
g.setColor(getBackground());
|
215
|
|
- g.fillRect(BORDER_SIZE + 1, offset + 1, getWidth() - BORDER_SIZE * 2 - 1, PREVIEW_HEIGHT - 1);
|
|
217
|
+ g.fillRect(BORDER_SIZE + 1, offset + 1,
|
|
218
|
+ getWidth() - BORDER_SIZE * 2 - 1, PREVIEW_HEIGHT - 1);
|
216
|
219
|
g.setColor(Color.BLACK);
|
217
|
|
- g.drawLine(BORDER_SIZE, offset, getWidth() - BORDER_SIZE, offset + PREVIEW_HEIGHT);
|
|
220
|
+ g.drawLine(BORDER_SIZE, offset, getWidth() - BORDER_SIZE, offset +
|
|
221
|
+ PREVIEW_HEIGHT);
|
218
|
222
|
} else {
|
219
|
223
|
g.setColor(preview);
|
220
|
|
- g.fillRect(BORDER_SIZE + 1, offset + 1, getWidth() - BORDER_SIZE * 2 - 1, PREVIEW_HEIGHT - 1);
|
|
224
|
+ g.fillRect(BORDER_SIZE + 1, offset + 1,
|
|
225
|
+ getWidth() - BORDER_SIZE * 2 - 1, PREVIEW_HEIGHT - 1);
|
221
|
226
|
}
|
222
|
227
|
}
|
223
|
|
-
|
|
228
|
+
|
224
|
229
|
/**
|
225
|
230
|
* Retrieves the hex colour beneath the mouse. It is assumed that this
|
226
|
231
|
* method is only called if the mouse is within the hex area.
|
|
@@ -230,10 +235,11 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
230
|
235
|
private Color getHexColour(final MouseEvent e) {
|
231
|
236
|
final int i = e.getX() - BORDER_SIZE;
|
232
|
237
|
final int j = HEX_HEIGHT - (e.getY() - hexOffset);
|
233
|
|
-
|
234
|
|
- return new Color(Color.HSBtoRGB((float) i / HEX_WIDTH, saturation, (float) j / HEX_HEIGHT));
|
|
238
|
+
|
|
239
|
+ return new Color(Color.HSBtoRGB((float) i / HEX_WIDTH, saturation,
|
|
240
|
+ (float) j / HEX_HEIGHT));
|
235
|
241
|
}
|
236
|
|
-
|
|
242
|
+
|
237
|
243
|
/**
|
238
|
244
|
* Retrieves the irc colour beneath the mouse. It is assumed that this
|
239
|
245
|
* method is only called if the mouse is within the irc colour area.
|
|
@@ -242,10 +248,10 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
242
|
248
|
*/
|
243
|
249
|
private Color getIrcColour(final MouseEvent e) {
|
244
|
250
|
final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
|
245
|
|
-
|
|
251
|
+
|
246
|
252
|
return ColourManager.getColour(i);
|
247
|
253
|
}
|
248
|
|
-
|
|
254
|
+
|
249
|
255
|
/**
|
250
|
256
|
* Adds an action listener to this object. Action events are generated (and
|
251
|
257
|
* passed to all action listeners) when the user selects a colour. The two
|
|
@@ -256,7 +262,7 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
256
|
262
|
public void addActionListener(final ActionListener listener) {
|
257
|
263
|
listeners.add(listener);
|
258
|
264
|
}
|
259
|
|
-
|
|
265
|
+
|
260
|
266
|
/**
|
261
|
267
|
* Removes an action listener from this object.
|
262
|
268
|
* @param listener The listener to be removed
|
|
@@ -264,7 +270,7 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
264
|
270
|
public void removeActionListener(final ActionListener listener) {
|
265
|
271
|
listeners.remove(listener);
|
266
|
272
|
}
|
267
|
|
-
|
|
273
|
+
|
268
|
274
|
/**
|
269
|
275
|
* Throws a new action event to all listeners.
|
270
|
276
|
* @param id The id of the action
|
|
@@ -272,12 +278,12 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
272
|
278
|
*/
|
273
|
279
|
private void throwAction(final int id, final String message) {
|
274
|
280
|
final ActionEvent event = new ActionEvent(this, id, message);
|
275
|
|
-
|
|
281
|
+
|
276
|
282
|
for (ActionListener listener : listeners) {
|
277
|
283
|
listener.actionPerformed(event);
|
278
|
284
|
}
|
279
|
285
|
}
|
280
|
|
-
|
|
286
|
+
|
281
|
287
|
/**
|
282
|
288
|
* Converts the specified integer (in the range 0-255) into a hex string.
|
283
|
289
|
* @param value The integer to convert
|
|
@@ -285,79 +291,115 @@ public final class ColourPickerPanel extends JPanel implements MouseListener, Mo
|
285
|
291
|
*/
|
286
|
292
|
private String toHex(final int value) {
|
287
|
293
|
final char[] chars = {
|
288
|
|
- '0', '1', '2', '3', '4', '5', '6', '7',
|
|
294
|
+ '0', '1', '2', '3', '4', '5', '6', '7',
|
289
|
295
|
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
|
290
|
296
|
};
|
291
|
|
-
|
|
297
|
+
|
292
|
298
|
return ("" + chars[value / 16]) + chars[value % 16];
|
293
|
299
|
}
|
294
|
|
-
|
295
|
|
- /** {@inheritDoc} */
|
|
300
|
+
|
|
301
|
+ /**
|
|
302
|
+ * {@inheritDoc}
|
|
303
|
+ *
|
|
304
|
+ * @param e Mouse event
|
|
305
|
+ */
|
|
306
|
+ @Override
|
296
|
307
|
public void mouseClicked(final MouseEvent e) {
|
297
|
|
- if (showIrc && e.getY() > ircOffset
|
298
|
|
- && e.getY() < ircOffset + IRC_HEIGHT && e.getX() > BORDER_SIZE
|
299
|
|
- && e.getX() < BORDER_SIZE + 16 * IRC_WIDTH) {
|
300
|
|
-
|
|
308
|
+ if (showIrc && e.getY() > ircOffset && e.getY() < ircOffset + IRC_HEIGHT &&
|
|
309
|
+ e.getX() > BORDER_SIZE && e.getX() < BORDER_SIZE + 16 *
|
|
310
|
+ IRC_WIDTH) {
|
|
311
|
+
|
301
|
312
|
final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
|
302
|
|
-
|
|
313
|
+
|
303
|
314
|
throwAction(ACTION_IRC, "" + i);
|
304
|
|
-
|
305
|
|
- } else if (showHex
|
306
|
|
- && e.getY() > hexOffset && e.getY() < hexOffset + HEX_HEIGHT) {
|
307
|
|
-
|
|
315
|
+
|
|
316
|
+ } else if (showHex && e.getY() > hexOffset && e.getY() < hexOffset +
|
|
317
|
+ HEX_HEIGHT) {
|
|
318
|
+
|
308
|
319
|
if (e.getX() > BORDER_SIZE && e.getX() < BORDER_SIZE + HEX_WIDTH) {
|
309
|
|
-
|
|
320
|
+
|
310
|
321
|
final Color color = getHexColour(e);
|
311
|
|
-
|
312
|
|
- throwAction(ACTION_HEX, toHex(color.getRed()) + toHex(color.getGreen()) + toHex(color.getBlue()));
|
313
|
|
-
|
314
|
|
- } else if (e.getX() > BORDER_SIZE * 2 + HEX_WIDTH
|
315
|
|
- && e.getX() < BORDER_SIZE * 3 + HEX_WIDTH + SLIDER_WIDTH) {
|
|
322
|
+
|
|
323
|
+ throwAction(ACTION_HEX, toHex(color.getRed()) +
|
|
324
|
+ toHex(color.getGreen()) + toHex(color.getBlue()));
|
|
325
|
+
|
|
326
|
+ } else if (e.getX() > BORDER_SIZE * 2 + HEX_WIDTH && e.getX() <
|
|
327
|
+ BORDER_SIZE * 3 + HEX_WIDTH + SLIDER_WIDTH) {
|
316
|
328
|
saturation = (float) (e.getY() - hexOffset) / 125;
|
317
|
329
|
repaint();
|
318
|
330
|
}
|
319
|
331
|
}
|
320
|
332
|
}
|
321
|
|
-
|
322
|
|
- /** {@inheritDoc} */
|
|
333
|
+
|
|
334
|
+ /**
|
|
335
|
+ * {@inheritDoc}
|
|
336
|
+ *
|
|
337
|
+ * @param e Mouse event
|
|
338
|
+ */
|
|
339
|
+ @Override
|
323
|
340
|
public void mousePressed(final MouseEvent e) {
|
324
|
|
- // Do nothing
|
|
341
|
+ // Do nothing
|
325
|
342
|
}
|
326
|
|
-
|
327
|
|
- /** {@inheritDoc} */
|
|
343
|
+
|
|
344
|
+ /**
|
|
345
|
+ * {@inheritDoc}
|
|
346
|
+ *
|
|
347
|
+ * @param e Mouse event
|
|
348
|
+ */
|
|
349
|
+ @Override
|
328
|
350
|
public void mouseReleased(final MouseEvent e) {
|
329
|
|
- // Do nothing
|
|
351
|
+ // Do nothing
|
330
|
352
|
}
|
331
|
|
-
|
332
|
|
- /** {@inheritDoc} */
|
|
353
|
+
|
|
354
|
+ /**
|
|
355
|
+ * {@inheritDoc}
|
|
356
|
+ *
|
|
357
|
+ * @param e Mouse event
|
|
358
|
+ */
|
|
359
|
+ @Override
|
333
|
360
|
public void mouseEntered(final MouseEvent e) {
|
334
|
|
- // Do nothing
|
|
361
|
+ // Do nothing
|
335
|
362
|
}
|
336
|
|
-
|
337
|
|
- /** {@inheritDoc} */
|
|
363
|
+
|
|
364
|
+ /**
|
|
365
|
+ * {@inheritDoc}
|
|
366
|
+ *
|
|
367
|
+ * @param e Mouse event
|
|
368
|
+ */
|
|
369
|
+ @Override
|
338
|
370
|
public void mouseExited(final MouseEvent e) {
|
339
|
|
- // Do nothing
|
|
371
|
+ // Do nothing
|
340
|
372
|
}
|
341
|
|
-
|
342
|
|
- /** {@inheritDoc} */
|
|
373
|
+
|
|
374
|
+ /**
|
|
375
|
+ * {@inheritDoc}
|
|
376
|
+ *
|
|
377
|
+ * @param e Mouse event
|
|
378
|
+ */
|
|
379
|
+ @Override
|
343
|
380
|
public void mouseDragged(final MouseEvent e) {
|
344
|
|
- // Do nothing
|
|
381
|
+ // Do nothing
|
345
|
382
|
}
|
346
|
|
-
|
347
|
|
- /** {@inheritDoc} */
|
|
383
|
+
|
|
384
|
+ /**
|
|
385
|
+ * {@inheritDoc}
|
|
386
|
+ *
|
|
387
|
+ * @param e Mouse event
|
|
388
|
+ */
|
|
389
|
+ @Override
|
348
|
390
|
public void mouseMoved(final MouseEvent e) {
|
349
|
|
- if (showIrc && e.getY() > ircOffset
|
350
|
|
- && e.getY() < ircOffset + IRC_HEIGHT && e.getX() > BORDER_SIZE
|
351
|
|
- && e.getX() < BORDER_SIZE + 16 * IRC_WIDTH) {
|
|
391
|
+ if (showIrc && e.getY() > ircOffset && e.getY() < ircOffset + IRC_HEIGHT &&
|
|
392
|
+ e.getX() > BORDER_SIZE && e.getX() < BORDER_SIZE + 16 *
|
|
393
|
+ IRC_WIDTH) {
|
352
|
394
|
preview = getIrcColour(e);
|
353
|
|
- } else if (showHex && e.getY() > hexOffset
|
354
|
|
- && e.getY() < hexOffset + HEX_HEIGHT && e.getX() > BORDER_SIZE
|
355
|
|
- && e.getX() < BORDER_SIZE + HEX_WIDTH) {
|
|
395
|
+ } else if (showHex && e.getY() > hexOffset && e.getY() < hexOffset +
|
|
396
|
+ HEX_HEIGHT && e.getX() > BORDER_SIZE && e.getX() < BORDER_SIZE +
|
|
397
|
+ HEX_WIDTH) {
|
356
|
398
|
preview = getHexColour(e);
|
357
|
399
|
} else {
|
358
|
400
|
preview = null;
|
359
|
401
|
}
|
360
|
|
-
|
|
402
|
+
|
361
|
403
|
repaint(previewRect);
|
362
|
404
|
}
|
363
|
405
|
}
|