Browse Source

issue 1293: Layout tweaks

git-svn-id: http://svn.dmdirc.com/trunk@4133 00569f92-eb28-0410-84fd-f71c24880f
tags/0.6
Gregory Holmes 16 years ago
parent
commit
ee6cb04cf2

+ 14
- 15
src/com/dmdirc/ui/swing/components/ColourPickerDialog.java View File

33
  * Colour picker dialog.
33
  * Colour picker dialog.
34
  */
34
  */
35
 public final class ColourPickerDialog extends StandardDialog {
35
 public final class ColourPickerDialog extends StandardDialog {
36
-    
36
+
37
     /**
37
     /**
38
      * A version number for this class. It should be changed whenever the class
38
      * A version number for this class. It should be changed whenever the class
39
      * structure is changed (or anything else that would prevent serialized
39
      * structure is changed (or anything else that would prevent serialized
40
      * objects being unserialized with the new class).
40
      * objects being unserialized with the new class).
41
      */
41
      */
42
     private static final long serialVersionUID = 1;
42
     private static final long serialVersionUID = 1;
43
-    
44
     /** Colour chooser panel. */
43
     /** Colour chooser panel. */
45
     private ColourPickerPanel colourChooser;
44
     private ColourPickerPanel colourChooser;
46
-    
45
+
47
     /**
46
     /**
48
      * Creates a new instance of ColourPickerDialog.
47
      * Creates a new instance of ColourPickerDialog.
49
      */
48
      */
50
     public ColourPickerDialog() {
49
     public ColourPickerDialog() {
51
         this(true, true);
50
         this(true, true);
52
     }
51
     }
53
-    
52
+
54
     /**
53
     /**
55
      * Creates a new instance of ColourPickerDialog.
54
      * Creates a new instance of ColourPickerDialog.
56
      * @param showIRC show irc colours
55
      * @param showIRC show irc colours
58
      */
57
      */
59
     public ColourPickerDialog(final boolean showIRC, final boolean showHex) {
58
     public ColourPickerDialog(final boolean showIRC, final boolean showHex) {
60
         super((MainFrame) Main.getUI().getMainWindow(), false);
59
         super((MainFrame) Main.getUI().getMainWindow(), false);
61
-        
60
+
62
         colourChooser = new ColourPickerPanel(showIRC, showHex);
61
         colourChooser = new ColourPickerPanel(showIRC, showHex);
63
-        this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
64
-        this.add(colourChooser);
65
-        this.pack();
66
-        this.setResizable(false);
67
-        this.setFocusableWindowState(false);
62
+        
63
+        setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
64
+        add(colourChooser);
65
+        pack();
66
+        setResizable(false);
67
+        setFocusableWindowState(false);
68
     }
68
     }
69
-    
69
+
70
     /** 
70
     /** 
71
      * Creates and shows a new Colour picker dialog. 
71
      * Creates and shows a new Colour picker dialog. 
72
      * @return Colour picker dialog
72
      * @return Colour picker dialog
74
     public static ColourPickerDialog showColourPicker() {
74
     public static ColourPickerDialog showColourPicker() {
75
         return showColourPicker(true, true);
75
         return showColourPicker(true, true);
76
     }
76
     }
77
-    
77
+
78
     /** 
78
     /** 
79
      * Creates and shows a new Colour picker dialog. 
79
      * Creates and shows a new Colour picker dialog. 
80
      * @return Colour picker dialog
80
      * @return Colour picker dialog
81
      * @param showIRC show irc colours
81
      * @param showIRC show irc colours
82
      * @param showHex show hex colours
82
      * @param showHex show hex colours
83
      */
83
      */
84
-    public static ColourPickerDialog showColourPicker(final boolean showIRC, 
84
+    public static ColourPickerDialog showColourPicker(final boolean showIRC,
85
             final boolean showHex) {
85
             final boolean showHex) {
86
         final ColourPickerDialog cpd = new ColourPickerDialog(showIRC, showHex);
86
         final ColourPickerDialog cpd = new ColourPickerDialog(showIRC, showHex);
87
         cpd.setVisible(true);
87
         cpd.setVisible(true);
88
         return cpd;
88
         return cpd;
89
     }
89
     }
90
-    
90
+
91
     /** 
91
     /** 
92
      * Adds an actions listener to this dialog.
92
      * Adds an actions listener to this dialog.
93
      *
93
      *
96
     public void addActionListener(final ActionListener listener) {
96
     public void addActionListener(final ActionListener listener) {
97
         colourChooser.addActionListener(listener);
97
         colourChooser.addActionListener(listener);
98
     }
98
     }
99
-    
100
 }
99
 }

+ 164
- 122
src/com/dmdirc/ui/swing/components/ColourPickerPanel.java View File

44
  * colour visually.
44
  * colour visually.
45
  * @author chris
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
      * A version number for this class. It should be changed whenever the class
51
      * A version number for this class. It should be changed whenever the class
56
      * structure is changed (or anything else that would prevent serialized
52
      * structure is changed (or anything else that would prevent serialized
57
      * objects being unserialized with the new class).
53
      * objects being unserialized with the new class).
58
      */
54
      */
59
     private static final long serialVersionUID = 1;
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
     /** The width of each IRC colour patch. */
60
     /** The width of each IRC colour patch. */
62
     private static final int IRC_WIDTH = 9;
61
     private static final int IRC_WIDTH = 9;
63
     /** The height of each IRC colour patch. */
62
     /** The height of each IRC colour patch. */
64
     private static final int IRC_HEIGHT = 16;
63
     private static final int IRC_HEIGHT = 16;
65
-    
66
     /** The width of the hex colour patch. */
64
     /** The width of the hex colour patch. */
67
     private static final int HEX_WIDTH = 125;
65
     private static final int HEX_WIDTH = 125;
68
     /** The height of the hex colour patch. */
66
     /** The height of the hex colour patch. */
69
     private static final int HEX_HEIGHT = 125;
67
     private static final int HEX_HEIGHT = 125;
70
-    
71
     /** The size of borders to use. */
68
     /** The size of borders to use. */
72
     private static final int BORDER_SIZE = 7;
69
     private static final int BORDER_SIZE = 7;
73
     /** The size of slider to use. */
70
     /** The size of slider to use. */
74
     private static final int SLIDER_WIDTH = 10;
71
     private static final int SLIDER_WIDTH = 10;
75
     /** The height of the preview area. */
72
     /** The height of the preview area. */
76
     private static final int PREVIEW_HEIGHT = 20;
73
     private static final int PREVIEW_HEIGHT = 20;
77
-    
78
     /** Whether to show IRC colours. */
74
     /** Whether to show IRC colours. */
79
     private final boolean showIrc;
75
     private final boolean showIrc;
80
-    
81
     /** Whether to show hex colours. */
76
     /** Whether to show hex colours. */
82
     private final boolean showHex;
77
     private final boolean showHex;
83
-    
84
     /** The y-coord of the start of the IRC colours block. */
78
     /** The y-coord of the start of the IRC colours block. */
85
     private int ircOffset;
79
     private int ircOffset;
86
-    
87
     /** The y-coord of the start of the hex colours block. */
80
     /** The y-coord of the start of the hex colours block. */
88
     private int hexOffset;
81
     private int hexOffset;
89
-    
90
     /** The y-coord of the start of the preview block. */
82
     /** The y-coord of the start of the preview block. */
91
     private int previewOffset;
83
     private int previewOffset;
92
-    
93
     /** The saturation to use. */
84
     /** The saturation to use. */
94
     private float saturation = (float) 1.0;
85
     private float saturation = (float) 1.0;
95
-    
96
     /** The colour to show in the preview window. */
86
     /** The colour to show in the preview window. */
97
     private Color preview;
87
     private Color preview;
98
-    
99
     /** Rectangle we use to indicate that only the preview should be drawn. */
88
     /** Rectangle we use to indicate that only the preview should be drawn. */
100
     private Rectangle previewRect;
89
     private Rectangle previewRect;
101
-    
102
     /** A list of registered actionlisteners. */
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
      * Creates a new instance of ColourPickerPanel.
95
      * Creates a new instance of ColourPickerPanel.
107
      * @param newShowIrc Whether to show IRC colours or not
96
      * @param newShowIrc Whether to show IRC colours or not
108
      * @param newShowHex Whether to show hex colours or not
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
         super();
101
         super();
112
-        
102
+
113
         this.showIrc = newShowIrc;
103
         this.showIrc = newShowIrc;
114
         this.showHex = newShowHex;
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
         setPreferredSize(new Dimension(160, height));
109
         setPreferredSize(new Dimension(160, height));
120
-        
110
+
121
         addMouseListener(this);
111
         addMouseListener(this);
122
         addMouseMotionListener(this);
112
         addMouseMotionListener(this);
123
     }
113
     }
124
-    
114
+
125
     /**
115
     /**
126
      * Creates a new instance of ColourPickerPanel, showing both IRC and Hex
116
      * Creates a new instance of ColourPickerPanel, showing both IRC and Hex
127
      * colours.
117
      * colours.
129
     public ColourPickerPanel() {
119
     public ColourPickerPanel() {
130
         this(true, true);
120
         this(true, true);
131
     }
121
     }
132
-    
122
+
133
     /** {@inheritDoc} */
123
     /** {@inheritDoc} */
124
+    @Override
134
     public void paint(final Graphics g) {
125
     public void paint(final Graphics g) {
135
         int offset = 20;
126
         int offset = 20;
136
-        
127
+
137
         if (previewRect == null || !previewRect.equals(g.getClipBounds())) {
128
         if (previewRect == null || !previewRect.equals(g.getClipBounds())) {
138
             g.setColor(getBackground());
129
             g.setColor(getBackground());
139
-            
130
+
140
             g.fillRect(0, 0, getWidth(), getHeight());
131
             g.fillRect(0, 0, getWidth(), getHeight());
141
-            
132
+
142
             g.setColor(Color.BLACK);
133
             g.setColor(Color.BLACK);
143
-            
134
+
144
             if (showIrc) {
135
             if (showIrc) {
145
                 g.drawString("IRC Colours", BORDER_SIZE, offset);
136
                 g.drawString("IRC Colours", BORDER_SIZE, offset);
146
-                
137
+
147
                 offset += BORDER_SIZE;
138
                 offset += BORDER_SIZE;
148
-                
139
+
149
                 ircOffset = offset;
140
                 ircOffset = offset;
150
-                
141
+
151
                 for (int i = 0; i < 16; i++) {
142
                 for (int i = 0; i < 16; i++) {
152
                     g.setColor(ColourManager.getColour(i));
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
                     g.setColor(Color.BLACK);
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
                 offset += IRC_HEIGHT + 20;
151
                 offset += IRC_HEIGHT + 20;
159
             }
152
             }
160
-            
153
+
161
             if (showHex) {
154
             if (showHex) {
162
                 g.drawString("Hex Colours", BORDER_SIZE, offset);
155
                 g.drawString("Hex Colours", BORDER_SIZE, offset);
163
-                
156
+
164
                 offset += BORDER_SIZE;
157
                 offset += BORDER_SIZE;
165
-                
158
+
166
                 hexOffset = offset;
159
                 hexOffset = offset;
167
-                
160
+
168
                 for (int i = HEX_WIDTH; i > 0; i--) {
161
                 for (int i = HEX_WIDTH; i > 0; i--) {
169
                     for (int j = HEX_HEIGHT; j > 0; j--) {
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
                 g.setColor(Color.BLACK);
170
                 g.setColor(Color.BLACK);
176
                 g.drawRect(BORDER_SIZE, offset, HEX_HEIGHT, HEX_WIDTH);
171
                 g.drawRect(BORDER_SIZE, offset, HEX_HEIGHT, HEX_WIDTH);
177
-                
172
+
178
                 g.drawRect(BORDER_SIZE * 2 + HEX_WIDTH, offset, 10, HEX_HEIGHT);
173
                 g.drawRect(BORDER_SIZE * 2 + HEX_WIDTH, offset, 10, HEX_HEIGHT);
179
-                
174
+
180
                 for (int i = 1; i < HEX_HEIGHT; i++) {
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
                     g.drawLine(BORDER_SIZE * 2 + HEX_WIDTH + 1, offset + i,
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
                 final Polygon arrow = new Polygon();
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
                 g.setColor(Color.BLACK);
192
                 g.setColor(Color.BLACK);
193
                 g.fillPolygon(arrow);
193
                 g.fillPolygon(arrow);
194
-                
194
+
195
                 offset += HEX_HEIGHT + 20;
195
                 offset += HEX_HEIGHT + 20;
196
             }
196
             }
197
-            
197
+
198
             g.drawString("Preview", BORDER_SIZE, offset);
198
             g.drawString("Preview", BORDER_SIZE, offset);
199
-            
199
+
200
             offset += BORDER_SIZE;
200
             offset += BORDER_SIZE;
201
-            
201
+
202
             previewOffset = offset;
202
             previewOffset = offset;
203
-            
203
+
204
             if (previewRect == null) {
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
         } else {
208
         } else {
208
             offset = previewOffset;
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
         if (preview == null) {
215
         if (preview == null) {
214
             g.setColor(getBackground());
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
             g.setColor(Color.BLACK);
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
         } else {
222
         } else {
219
             g.setColor(preview);
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
      * Retrieves the hex colour beneath the mouse. It is assumed that this
230
      * Retrieves the hex colour beneath the mouse. It is assumed that this
226
      * method is only called if the mouse is within the hex area.
231
      * method is only called if the mouse is within the hex area.
230
     private Color getHexColour(final MouseEvent e) {
235
     private Color getHexColour(final MouseEvent e) {
231
         final int i = e.getX() - BORDER_SIZE;
236
         final int i = e.getX() - BORDER_SIZE;
232
         final int j = HEX_HEIGHT - (e.getY() - hexOffset);
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
      * Retrieves the irc colour beneath the mouse. It is assumed that this
244
      * Retrieves the irc colour beneath the mouse. It is assumed that this
239
      * method is only called if the mouse is within the irc colour area.
245
      * method is only called if the mouse is within the irc colour area.
242
      */
248
      */
243
     private Color getIrcColour(final MouseEvent e) {
249
     private Color getIrcColour(final MouseEvent e) {
244
         final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
250
         final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
245
-        
251
+
246
         return ColourManager.getColour(i);
252
         return ColourManager.getColour(i);
247
     }
253
     }
248
-    
254
+
249
     /**
255
     /**
250
      * Adds an action listener to this object. Action events are generated (and
256
      * Adds an action listener to this object. Action events are generated (and
251
      * passed to all action listeners) when the user selects a colour. The two
257
      * passed to all action listeners) when the user selects a colour. The two
256
     public void addActionListener(final ActionListener listener) {
262
     public void addActionListener(final ActionListener listener) {
257
         listeners.add(listener);
263
         listeners.add(listener);
258
     }
264
     }
259
- 
265
+
260
     /**
266
     /**
261
      * Removes an action listener from this object.
267
      * Removes an action listener from this object.
262
      * @param listener The listener to be removed
268
      * @param listener The listener to be removed
264
     public void removeActionListener(final ActionListener listener) {
270
     public void removeActionListener(final ActionListener listener) {
265
         listeners.remove(listener);
271
         listeners.remove(listener);
266
     }
272
     }
267
- 
273
+
268
     /**
274
     /**
269
      * Throws a new action event to all listeners.
275
      * Throws a new action event to all listeners.
270
      * @param id The id of the action
276
      * @param id The id of the action
272
      */
278
      */
273
     private void throwAction(final int id, final String message) {
279
     private void throwAction(final int id, final String message) {
274
         final ActionEvent event = new ActionEvent(this, id, message);
280
         final ActionEvent event = new ActionEvent(this, id, message);
275
- 
281
+
276
         for (ActionListener listener : listeners) {
282
         for (ActionListener listener : listeners) {
277
             listener.actionPerformed(event);
283
             listener.actionPerformed(event);
278
         }
284
         }
279
     }
285
     }
280
- 
286
+
281
     /**
287
     /**
282
      * Converts the specified integer (in the range 0-255) into a hex string.
288
      * Converts the specified integer (in the range 0-255) into a hex string.
283
      * @param value The integer to convert
289
      * @param value The integer to convert
285
      */
291
      */
286
     private String toHex(final int value) {
292
     private String toHex(final int value) {
287
         final char[] chars = {
293
         final char[] chars = {
288
-            '0', '1', '2', '3', '4', '5', '6', '7', 
294
+            '0', '1', '2', '3', '4', '5', '6', '7',
289
             '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
295
             '8', '9', 'A', 'B', 'C', 'D', 'E', 'F',
290
         };
296
         };
291
-        
297
+
292
         return ("" + chars[value / 16]) + chars[value % 16];
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
     public void mouseClicked(final MouseEvent e) {
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
             final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
312
             final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
302
-            
313
+
303
             throwAction(ACTION_IRC, "" + i);
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
             if (e.getX() > BORDER_SIZE && e.getX() < BORDER_SIZE + HEX_WIDTH) {
319
             if (e.getX() > BORDER_SIZE && e.getX() < BORDER_SIZE + HEX_WIDTH) {
309
-                
320
+
310
                 final Color color = getHexColour(e);
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
                 saturation = (float) (e.getY() - hexOffset) / 125;
328
                 saturation = (float) (e.getY() - hexOffset) / 125;
317
                 repaint();
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
     public void mousePressed(final MouseEvent e) {
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
     public void mouseReleased(final MouseEvent e) {
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
     public void mouseEntered(final MouseEvent e) {
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
     public void mouseExited(final MouseEvent e) {
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
     public void mouseDragged(final MouseEvent e) {
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
     public void mouseMoved(final MouseEvent e) {
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
             preview = getIrcColour(e);
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
             preview = getHexColour(e);
398
             preview = getHexColour(e);
357
         } else {
399
         } else {
358
             preview = null;
400
             preview = null;
359
         }
401
         }
360
-        
402
+
361
         repaint(previewRect);
403
         repaint(previewRect);
362
     }
404
     }
363
 }
405
 }

+ 7
- 8
src/com/dmdirc/ui/swing/dialogs/profiles/ProfileDetailPanel.java View File

95
      */
95
      */
96
     public ProfileDetailPanel(final ProfileListModel model) {
96
     public ProfileDetailPanel(final ProfileListModel model) {
97
         super();
97
         super();
98
-        
98
+
99
         this.model = model;
99
         this.model = model;
100
 
100
 
101
         initMainComponents();
101
         initMainComponents();
135
 
135
 
136
     /** Lays out the components in the panel. */
136
     /** Lays out the components in the panel. */
137
     private void layoutComponents() {
137
     private void layoutComponents() {
138
-        setLayout(new MigLayout("fill"));
138
+        setLayout(new MigLayout("fillx"));
139
 
139
 
140
         add(new JLabel("Name:"));
140
         add(new JLabel("Name:"));
141
         add(name, "growx, pushx, wrap");
141
         add(name, "growx, pushx, wrap");
150
         add(ident, "growx, pushx, wrap");
150
         add(ident, "growx, pushx, wrap");
151
 
151
 
152
         add(new JLabel("Alternate nicknames:"));
152
         add(new JLabel("Alternate nicknames:"));
153
-        add(new JScrollPane(altNicknames), "growx, pushx, wrap");
153
+        add(new JScrollPane(altNicknames), "grow, pushx, wrap");
154
 
154
 
155
         add(addButton, "skip 1, split 3, sg button, growx");
155
         add(addButton, "skip 1, split 3, sg button, growx");
156
         add(editButton, "sg button, growx");
156
         add(editButton, "sg button, growx");
344
     public void contentsChanged(final ListDataEvent e) {
344
     public void contentsChanged(final ListDataEvent e) {
345
         validateDetails();
345
         validateDetails();
346
     }
346
     }
347
-    
347
+
348
     /**
348
     /**
349
      * Ensures profile names are unique.
349
      * Ensures profile names are unique.
350
      */
350
      */
354
         @Override
354
         @Override
355
         public ValidationResponse validate(final String object) {
355
         public ValidationResponse validate(final String object) {
356
             for (Profile targetprofile : model) {
356
             for (Profile targetprofile : model) {
357
-                if (targetprofile != profile && targetprofile.getName().equalsIgnoreCase(object)) {
357
+                if (targetprofile != profile && targetprofile.getName().
358
+                        equalsIgnoreCase(object)) {
358
                     return new ValidationResponse("Profile names must be unique");
359
                     return new ValidationResponse("Profile names must be unique");
359
                 }
360
                 }
360
             }
361
             }
361
-            
362
+
362
             return super.validate(object);
363
             return super.validate(object);
363
         }
364
         }
364
-        
365
     }
365
     }
366
-    
367
 }
366
 }

+ 7
- 6
src/com/dmdirc/ui/swing/dialogs/profiles/ProfileManagerDialog.java View File

29
 import com.dmdirc.ui.swing.components.TextLabel;
29
 import com.dmdirc.ui.swing.components.TextLabel;
30
 import com.dmdirc.ui.swing.MainFrame;
30
 import com.dmdirc.ui.swing.MainFrame;
31
 import com.dmdirc.ui.swing.components.StandardDialog;
31
 import com.dmdirc.ui.swing.components.StandardDialog;
32
-
33
 import com.dmdirc.ui.swing.dialogs.NewServerDialog;
32
 import com.dmdirc.ui.swing.dialogs.NewServerDialog;
33
+
34
 import java.awt.event.ActionEvent;
34
 import java.awt.event.ActionEvent;
35
 import java.awt.event.ActionListener;
35
 import java.awt.event.ActionListener;
36
 import java.util.ArrayList;
36
 import java.util.ArrayList;
144
     private void layoutComponents() {
144
     private void layoutComponents() {
145
         getContentPane().setLayout(new MigLayout("fill, wmin 600, wmax 600"));
145
         getContentPane().setLayout(new MigLayout("fill, wmin 600, wmax 600"));
146
 
146
 
147
-        getContentPane().add(infoLabel, "wrap, growx, spanx 2");
148
-        getContentPane().add(new JScrollPane(profileList), "growy, wmin 200, wmax 200");
147
+        getContentPane().add(infoLabel, "wrap, spanx 2");
148
+        getContentPane().add(new JScrollPane(profileList),
149
+                "growy, wmin 200, wmax 200");
149
         getContentPane().add(details, "grow, wrap");
150
         getContentPane().add(details, "grow, wrap");
150
         getContentPane().add(addButton, "wrap, wmin 200, wmax 200");
151
         getContentPane().add(addButton, "wrap, wmin 200, wmax 200");
151
         getContentPane().add(deleteButton, "left, wmin 200, wmax 200");
152
         getContentPane().add(deleteButton, "left, wmin 200, wmax 200");
234
      */
235
      */
235
     private void addProfile() {
236
     private void addProfile() {
236
         final String nick = System.getProperty("user.name").replace(' ', '_');
237
         final String nick = System.getProperty("user.name").replace(' ', '_');
237
-        
238
+
238
         String name = "New Profile";
239
         String name = "New Profile";
239
         int i = 1;
240
         int i = 1;
240
-        
241
+
241
         while (model.contains(name)) {
242
         while (model.contains(name)) {
242
             name = "New Profile " + ++i;
243
             name = "New Profile " + ++i;
243
         }
244
         }
244
-        
245
+
245
         final Profile profile = new Profile(name, nick, nick);
246
         final Profile profile = new Profile(name, nick, nick);
246
         model.add(profile);
247
         model.add(profile);
247
         profileList.setSelectedIndex(model.indexOf(profile));
248
         profileList.setSelectedIndex(model.indexOf(profile));

Loading…
Cancel
Save