Просмотр исходного кода

Colour abstraction

Change-Id: I978e118b20c507cbc305d5ee5c6ecabf6d7454b8
Depends-On: I691b6dca615fd6a197712d9f11cedafdc9a8bc5d
Reviewed-on: http://gerrit.dmdirc.com/2188
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1
Chris Smith 12 лет назад
Родитель
Сommit
034882ff81

+ 2
- 1
src/com/dmdirc/addons/nickcolours/ColourRenderer.java Просмотреть файл

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.nickcolours;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.ui.messages.ColourManager;
26 27
 
27 28
 import java.awt.Color;
@@ -59,7 +60,7 @@ public class ColourRenderer extends DefaultTableCellRenderer {
59 60
             final boolean hasFocus, final int row, final int column) {
60 61
         Color colour = null;
61 62
         if (value != null && !((String) value).isEmpty()) {
62
-            colour = ColourManager.parseColour((String) value, null);
63
+            colour = UIUtilities.convertColour(ColourManager.parseColour((String) value, null));
63 64
         }
64 65
 
65 66
         setHorizontalAlignment(CENTER);

+ 5
- 5
src/com/dmdirc/addons/nickcolours/NickColourPlugin.java Просмотреть файл

@@ -119,7 +119,7 @@ public final class NickColourPlugin extends BasePlugin implements ActionListener
119 119
                 toLowerCase("*:" + client.getClient().getNickname());
120 120
 
121 121
         if (useowncolour && client.getClient().equals(myself)) {
122
-            final Color color = ColourManager.parseColour(owncolour);
122
+            final Color color = UIUtilities.convertColour(ColourManager.parseColour(owncolour));
123 123
             putColour(map, color, color);
124 124
         } else if (userandomcolour) {
125 125
             putColour(map, getColour(client.getClient().getNickname()), getColour(client.
@@ -141,10 +141,10 @@ public final class NickColourPlugin extends BasePlugin implements ActionListener
141 141
             Color nickColor = null;
142 142
 
143 143
             if (parts[0] != null) {
144
-                textColor = ColourManager.parseColour(parts[0], null);
144
+                textColor = UIUtilities.convertColour(ColourManager.parseColour(parts[0], null));
145 145
             }
146 146
             if (parts[1] != null) {
147
-                nickColor = ColourManager.parseColour(parts[1], null);
147
+                nickColor = UIUtilities.convertColour(ColourManager.parseColour(parts[1], null));
148 148
             }
149 149
 
150 150
             putColour(map, textColor, nickColor);
@@ -183,9 +183,9 @@ public final class NickColourPlugin extends BasePlugin implements ActionListener
183 183
             count += nick.charAt(i);
184 184
         }
185 185
 
186
-        count = count % randColours.length;
186
+        count %= randColours.length;
187 187
 
188
-        return ColourManager.parseColour(randColours[count]);
188
+        return UIUtilities.convertColour(ColourManager.parseColour(randColours[count]));
189 189
     }
190 190
 
191 191
     /**

+ 8
- 6
src/com/dmdirc/addons/osd/OsdWindow.java Просмотреть файл

@@ -123,8 +123,9 @@ public class OsdWindow extends JDialog implements MouseListener,
123 123
 
124 124
         panel = new JPanel();
125 125
         panel.setBorder(new LineBorder(Color.BLACK));
126
-        panel.setBackground(IdentityManager.getGlobalConfig().getOptionColour(plugin.getDomain(),
127
-                "bgcolour"));
126
+        panel.setBackground(UIUtilities.convertColour(
127
+                IdentityManager.getGlobalConfig().getOptionColour(plugin.getDomain(),
128
+                "bgcolour")));
128 129
 
129 130
         final int width = IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
130 131
                 "width");
@@ -132,8 +133,9 @@ public class OsdWindow extends JDialog implements MouseListener,
132 133
         setLayout(new MigLayout("wmin " + width + ", wmax " + width + ", ins rel, fill"));
133 134
 
134 135
         label = new JLabel(text);
135
-        label.setForeground(IdentityManager.getGlobalConfig().getOptionColour(plugin.getDomain(),
136
-                "fgcolour"));
136
+        label.setForeground(UIUtilities.convertColour(
137
+                IdentityManager.getGlobalConfig().getOptionColour(plugin.getDomain(),
138
+                "fgcolour")));
137 139
         label.setFont(label.getFont().deriveFont(
138 140
                 (float) IdentityManager.getGlobalConfig().getOptionInt(plugin.getDomain(),
139 141
                 "fontSize")));
@@ -254,7 +256,7 @@ public class OsdWindow extends JDialog implements MouseListener,
254 256
      * @param colour The background colour to use
255 257
      */
256 258
     public void setBackgroundColour(final String colour) {
257
-        panel.setBackground(ColourManager.parseColour(colour));
259
+        panel.setBackground(UIUtilities.convertColour(ColourManager.parseColour(colour)));
258 260
     }
259 261
 
260 262
     /**
@@ -263,7 +265,7 @@ public class OsdWindow extends JDialog implements MouseListener,
263 265
      * @param colour The foreground colour to use
264 266
      */
265 267
     public void setForegroundColour(final String colour) {
266
-        label.setForeground(ColourManager.parseColour(colour));
268
+        label.setForeground(UIUtilities.convertColour(ColourManager.parseColour(colour)));
267 269
     }
268 270
 
269 271
     /** {@inheritDoc} */

+ 2
- 2
src/com/dmdirc/addons/ui_swing/MainFrame.java Просмотреть файл

@@ -44,13 +44,13 @@ import com.dmdirc.interfaces.FrameInfoListener;
44 44
 import com.dmdirc.interfaces.NotificationListener;
45 45
 import com.dmdirc.logger.ErrorLevel;
46 46
 import com.dmdirc.logger.Logger;
47
+import com.dmdirc.ui.Colour;
47 48
 import com.dmdirc.ui.CoreUIUtils;
48 49
 import com.dmdirc.ui.IconManager;
49 50
 import com.dmdirc.util.ListenerList;
50 51
 import com.dmdirc.util.QueuedLinkedHashSet;
51 52
 import com.dmdirc.util.ReturnableThread;
52 53
 
53
-import java.awt.Color;
54 54
 import java.awt.Dimension;
55 55
 import java.awt.event.WindowEvent;
56 56
 import java.awt.event.WindowFocusListener;
@@ -717,7 +717,7 @@ public final class MainFrame extends JFrame implements WindowListener,
717 717
     /** {@inheritDoc} */
718 718
     @Override
719 719
     public void notificationSet(final FrameContainer window,
720
-            final Color colour) {
720
+            final Colour colour) {
721 721
         if (activeFrame.getContainer().equals(window)) {
722 722
             window.clearNotification();
723 723
         }

+ 34
- 0
src/com/dmdirc/addons/ui_swing/UIUtilities.java Просмотреть файл

@@ -27,8 +27,10 @@ import com.dmdirc.addons.ui_swing.actions.UndoAction;
27 27
 import com.dmdirc.addons.ui_swing.components.DMDircUndoableEditListener;
28 28
 import com.dmdirc.logger.ErrorLevel;
29 29
 import com.dmdirc.logger.Logger;
30
+import com.dmdirc.ui.Colour;
30 31
 import com.dmdirc.util.ReturnableThread;
31 32
 
33
+import java.awt.Color;
32 34
 import java.awt.FontMetrics;
33 35
 import java.awt.Graphics2D;
34 36
 import java.awt.Image;
@@ -453,4 +455,36 @@ public final class UIUtilities {
453 455
     public static void addComboBoxWidthModifier(final JComboBox combo) {
454 456
         combo.addPopupMenuListener(new ComboBoxWidthModifier());
455 457
     }
458
+
459
+    /**
460
+     * Converts a DMDirc {@link Colour} into an AWT-specific {@link Color} by
461
+     * copying the values of the red, green and blue channels.
462
+     *
463
+     * @param colour The colour to be converted
464
+     * @return A corresponding AWT colour
465
+     */
466
+    public static Color convertColour(final Colour colour) {
467
+        return new Color(colour.getRed(), colour.getGreen(), colour.getBlue());
468
+    }
469
+
470
+    /**
471
+     * Converts the given colour into a hexadecimal string.
472
+     *
473
+     * @param colour The colour to be converted
474
+     * @return A corresponding 6 character hex string
475
+     */
476
+    public static String getHex(final Color colour) {
477
+        return getHex(colour.getRed()) + getHex(colour.getGreen())
478
+                + getHex(colour.getBlue());
479
+    }
480
+
481
+    /**
482
+     * Converts the specified integer (in the range 0-255) into a hex string.
483
+     * @param value The integer to convert
484
+     * @return A 2 char hex string representing the specified integer
485
+     */
486
+    private static String getHex(final int value) {
487
+        final String hex = Integer.toHexString(value);
488
+        return (hex.length() < 2 ? "0" : "") + hex;
489
+    }
456 490
 }

+ 13
- 8
src/com/dmdirc/addons/ui_swing/components/NickList.java Просмотреть файл

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.addons.ui_swing.components;
24 24
 
25 25
 import com.dmdirc.Channel;
26
+import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.addons.ui_swing.components.frames.ChannelFrame;
27 28
 import com.dmdirc.addons.ui_swing.components.renderers.NicklistRenderer;
28 29
 import com.dmdirc.addons.ui_swing.textpane.ClickType;
@@ -78,12 +79,14 @@ public class NickList extends JScrollPane implements ConfigChangeListener,
78 79
 
79 80
         nickList = new JList();
80 81
 
81
-        nickList.setBackground(config.getOptionColour(
82
+        nickList.setBackground(UIUtilities.convertColour(
83
+                config.getOptionColour(
82 84
                 "ui", "nicklistbackgroundcolour",
83
-                "ui", "backgroundcolour"));
84
-        nickList.setForeground(config.getOptionColour(
85
+                "ui", "backgroundcolour")));
86
+        nickList.setForeground(UIUtilities.convertColour(
87
+                config.getOptionColour(
85 88
                 "ui", "nicklistforegroundcolour",
86
-                "ui", "foregroundcolour"));
89
+                "ui", "foregroundcolour")));
87 90
         nickList.setFont(new Font(config.getOption("ui", "textPaneFontName"),
88 91
                 Font.PLAIN, getFont().getSize()));
89 92
         config.addChangeListener("ui", "nicklistforegroundcolour", this);
@@ -254,12 +257,14 @@ public class NickList extends JScrollPane implements ConfigChangeListener,
254 257
                 || "nicklistforegroundcolour".equals(key)
255 258
                 || "foregroundcolour".equals(key)
256 259
                 || "textPaneFontName".equals(key)) {
257
-            nickList.setBackground(config.getOptionColour(
260
+            nickList.setBackground(UIUtilities.convertColour(
261
+                    config.getOptionColour(
258 262
                     "ui", "nicklistbackgroundcolour",
259
-                    "ui", "backgroundcolour"));
260
-            nickList.setForeground(config.getOptionColour(
263
+                    "ui", "backgroundcolour")));
264
+            nickList.setForeground(UIUtilities.convertColour(
265
+                    config.getOptionColour(
261 266
                     "ui", "nicklistforegroundcolour",
262
-                    "ui", "foregroundcolour"));
267
+                    "ui", "foregroundcolour")));
263 268
             nickList.setFont(new Font(config.getOption("ui", "textPaneFontName"),
264 269
                 Font.PLAIN, getFont().getSize()));
265 270
             nickList.repaint();

+ 9
- 6
src/com/dmdirc/addons/ui_swing/components/SwingSearchBar.java Просмотреть файл

@@ -408,11 +408,14 @@ public final class SwingSearchBar extends JPanel implements ActionListener,
408 408
 
409 409
     /** Sets the colours used in this document. */
410 410
     private void setColours() {
411
-        searchBox.setForeground(IdentityManager.getGlobalConfig().
412
-                getOptionColour("ui", "foregroundcolour"));
413
-        searchBox.setBackground(IdentityManager.getGlobalConfig().
414
-                getOptionColour("ui", "backgroundcolour"));
415
-        searchBox.setCaretColor(IdentityManager.getGlobalConfig().
416
-                getOptionColour("ui", "foregroundcolour"));
411
+        searchBox.setForeground(UIUtilities.convertColour(
412
+                IdentityManager.getGlobalConfig().
413
+                getOptionColour("ui", "foregroundcolour")));
414
+        searchBox.setBackground(UIUtilities.convertColour(
415
+                IdentityManager.getGlobalConfig().
416
+                getOptionColour("ui", "backgroundcolour")));
417
+        searchBox.setCaretColor(UIUtilities.convertColour(
418
+                IdentityManager.getGlobalConfig().
419
+                getOptionColour("ui", "foregroundcolour")));
417 420
     }
418 421
 }

+ 7
- 6
src/com/dmdirc/addons/ui_swing/components/TopicBar.java Просмотреть файл

@@ -35,7 +35,6 @@ import com.dmdirc.config.IdentityManager;
35 35
 import com.dmdirc.interfaces.ConfigChangeListener;
36 36
 import com.dmdirc.interfaces.TopicChangeListener;
37 37
 import com.dmdirc.parser.common.ChannelJoinRequest;
38
-import com.dmdirc.ui.messages.ColourManager;
39 38
 import com.dmdirc.ui.messages.Styliser;
40 39
 
41 40
 import java.awt.Color;
@@ -221,7 +220,7 @@ public class TopicBar extends JComponent implements ActionListener,
221 220
                     channel.getStyliser().addStyledString(
222 221
                             (StyledDocument) topicText.getDocument(),
223 222
                             new String[]{Styliser.CODE_HEXCOLOUR
224
-                                    + ColourManager.getHex(foregroundColour)
223
+                                    + UIUtilities.getHex(foregroundColour)
225 224
                                     + channel.getCurrentTopic().getTopic(), },
226 225
                             as);
227 226
                 }
@@ -331,10 +330,12 @@ public class TopicBar extends JComponent implements ActionListener,
331 330
      * Load and set colours.
332 331
      */
333 332
     private void setColours() {
334
-        backgroundColour = channel.getConfigManager().getOptionColour(
335
-                "ui", "inputbackgroundcolour", "ui", "backgroundcolour");
336
-        foregroundColour = channel.getConfigManager().getOptionColour(
337
-                "ui", "inputforegroundcolour", "ui", "foregroundcolour");
333
+        backgroundColour = UIUtilities.convertColour(
334
+                channel.getConfigManager().getOptionColour(
335
+                "ui", "inputbackgroundcolour", "ui", "backgroundcolour"));
336
+        foregroundColour = UIUtilities.convertColour(
337
+                channel.getConfigManager().getOptionColour(
338
+                "ui", "inputforegroundcolour", "ui", "foregroundcolour"));
338 339
         setBackground(backgroundColour);
339 340
         setForeground(foregroundColour);
340 341
         setDisabledTextColour(foregroundColour);

+ 4
- 3
src/com/dmdirc/addons/ui_swing/components/colours/ColourChooser.java Просмотреть файл

@@ -160,7 +160,7 @@ public final class ColourChooser extends JPanel implements ActionListener {
160 160
     /** Sets the colour back to white. */
161 161
     public void clearColour() {
162 162
         value = "ffffff";
163
-        previewPanel.setBackground(ColourManager.getColour("ffffff"));
163
+        previewPanel.setBackground(Color.WHITE);
164 164
         previewPanel.setToolTipText("");
165 165
     }
166 166
 
@@ -170,10 +170,11 @@ public final class ColourChooser extends JPanel implements ActionListener {
170 170
      */
171 171
     private void updateColour(final String newColour) {
172 172
         if (newColour == null || newColour.isEmpty()) {
173
-            previewPanel.setBackground(ColourManager.getColour("ffffff"));
173
+            previewPanel.setBackground(Color.WHITE);
174 174
             previewPanel.setToolTipText("");
175 175
         } else {
176
-            previewPanel.setBackground(ColourManager.parseColour(newColour));
176
+            previewPanel.setBackground(UIUtilities.convertColour(
177
+                    ColourManager.parseColour(newColour)));
177 178
             previewPanel.setToolTipText(newColour);
178 179
         }
179 180
     }

+ 3
- 2
src/com/dmdirc/addons/ui_swing/components/colours/ColourPickerPanel.java Просмотреть файл

@@ -22,6 +22,7 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.components.colours;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.ui.messages.ColourManager;
26 27
 
27 28
 import java.awt.Color;
@@ -142,7 +143,7 @@ public final class ColourPickerPanel extends JPanel implements MouseListener,
142 143
                 ircOffset = offset;
143 144
 
144 145
                 for (int i = 0; i < 16; i++) {
145
-                    g.setColor(ColourManager.getColour(i));
146
+                    g.setColor(UIUtilities.convertColour(ColourManager.getColour(i)));
146 147
                     g.fillRect(i * IRC_WIDTH + BORDER_SIZE, offset, IRC_WIDTH,
147 148
                             IRC_HEIGHT);
148 149
                     g.setColor(Color.BLACK);
@@ -251,7 +252,7 @@ public final class ColourPickerPanel extends JPanel implements MouseListener,
251 252
     private static Color getIrcColour(final MouseEvent e) {
252 253
         final int i = (e.getX() - BORDER_SIZE) / IRC_WIDTH;
253 254
 
254
-        return ColourManager.getColour(i);
255
+        return UIUtilities.convertColour(ColourManager.getColour(i));
255 256
     }
256 257
 
257 258
     /**

+ 4
- 3
src/com/dmdirc/addons/ui_swing/components/colours/OptionalColourChooser.java Просмотреть файл

@@ -159,7 +159,7 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
159 159
     /** Sets the colour back to white. */
160 160
     public void clearColour() {
161 161
         value = "ffffff";
162
-        previewPanel.setBackground(ColourManager.getColour("ffffff"));
162
+        previewPanel.setBackground(Color.WHITE);
163 163
         previewPanel.setToolTipText("");
164 164
     }
165 165
 
@@ -184,10 +184,11 @@ public final class OptionalColourChooser extends JPanel implements ActionListene
184 184
      */
185 185
     private void updateColour(final String newColour) {
186 186
         if (newColour.isEmpty()) {
187
-            previewPanel.setBackground(ColourManager.getColour("ffffff"));
187
+            previewPanel.setBackground(Color.WHITE);
188 188
             previewPanel.setToolTipText("");
189 189
         } else {
190
-            previewPanel.setBackground(ColourManager.parseColour(newColour));
190
+            previewPanel.setBackground(UIUtilities.convertColour(
191
+                    ColourManager.parseColour(newColour)));
191 192
             previewPanel.setToolTipText(newColour);
192 193
         }
193 194
     }

+ 18
- 12
src/com/dmdirc/addons/ui_swing/components/frames/InputTextFrame.java Просмотреть файл

@@ -99,15 +99,18 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
99 99
 
100 100
         if (!UIUtilities.isGTKUI()) {
101 101
             //GTK users appear to dislike choice, ignore them if they want some.
102
-            getInputField().setBackground(config.getOptionColour(
102
+            getInputField().setBackground(UIUtilities.convertColour(
103
+                    config.getOptionColour(
103 104
                     "ui", "inputbackgroundcolour",
104
-                    "ui", "backgroundcolour"));
105
-            getInputField().setForeground(config.getOptionColour(
105
+                    "ui", "backgroundcolour")));
106
+            getInputField().setForeground(UIUtilities.convertColour(
107
+                    config.getOptionColour(
106 108
                     "ui", "inputforegroundcolour",
107
-                    "ui", "foregroundcolour"));
108
-            getInputField().setCaretColor(config.getOptionColour(
109
+                    "ui", "foregroundcolour")));
110
+            getInputField().setCaretColor(UIUtilities.convertColour(
111
+                    config.getOptionColour(
109 112
                     "ui", "inputforegroundcolour",
110
-                    "ui", "foregroundcolour"));
113
+                    "ui", "foregroundcolour")));
111 114
         }
112 115
 
113 116
         config.addChangeListener("ui", "inputforegroundcolour", this);
@@ -367,17 +370,20 @@ public abstract class InputTextFrame extends TextFrame implements InputWindow,
367 370
                 && getInputField() != null && !UIUtilities.isGTKUI()) {
368 371
             if ("inputbackgroundcolour".equals(key)
369 372
                     || "backgroundcolour".equals(key)) {
370
-                getInputField().setBackground(getContainer().getConfigManager().
373
+                getInputField().setBackground(UIUtilities.convertColour(
374
+                        getContainer().getConfigManager().
371 375
                         getOptionColour("ui", "inputbackgroundcolour",
372
-                        "ui", "backgroundcolour"));
376
+                        "ui", "backgroundcolour")));
373 377
             } else if ("inputforegroundcolour".equals(key)
374 378
                     || "foregroundcolour".equals(key)) {
375
-                getInputField().setForeground(getContainer().getConfigManager()
379
+                getInputField().setForeground(UIUtilities.convertColour(
380
+                        getContainer().getConfigManager()
376 381
                         .getOptionColour("ui", "inputforegroundcolour",
377
-                        "ui", "foregroundcolour"));
378
-                getInputField().setCaretColor(getContainer().getConfigManager()
382
+                        "ui", "foregroundcolour")));
383
+                getInputField().setCaretColor(UIUtilities.convertColour(
384
+                        getContainer().getConfigManager()
379 385
                         .getOptionColour("ui", "inputforegroundcolour",
380
-                        "ui", "foregroundcolour"));
386
+                        "ui", "foregroundcolour")));
381 387
             }
382 388
         }
383 389
     }

+ 6
- 4
src/com/dmdirc/addons/ui_swing/components/frames/TextFrame.java Просмотреть файл

@@ -563,10 +563,12 @@ public abstract class TextFrame extends JPanel implements Window,
563 563
      * Updates colour settings from their config values.
564 564
      */
565 565
     private void updateColours() {
566
-        getTextPane().setForeground(getContainer().getConfigManager()
567
-                .getOptionColour("ui", "foregroundcolour"));
568
-        getTextPane().setBackground(getContainer().getConfigManager()
569
-                .getOptionColour("ui", "backgroundcolour"));
566
+        getTextPane().setForeground(UIUtilities.convertColour(
567
+                getContainer().getConfigManager()
568
+                .getOptionColour("ui", "foregroundcolour")));
569
+        getTextPane().setBackground(UIUtilities.convertColour(
570
+                getContainer().getConfigManager()
571
+                .getOptionColour("ui", "backgroundcolour")));
570 572
     }
571 573
 
572 574
     /** Disposes of this window, removing any listeners. */

+ 8
- 6
src/com/dmdirc/addons/ui_swing/components/renderers/NicklistRenderer.java Просмотреть файл

@@ -23,10 +23,12 @@
23 23
 package com.dmdirc.addons.ui_swing.components.renderers;
24 24
 
25 25
 import com.dmdirc.ChannelClientProperty;
26
+import com.dmdirc.addons.ui_swing.UIUtilities;
26 27
 import com.dmdirc.config.ConfigManager;
27 28
 import com.dmdirc.interfaces.ConfigChangeListener;
28 29
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
29 30
 
31
+import com.dmdirc.ui.Colour;
30 32
 import java.awt.Color;
31 33
 import java.awt.Component;
32 34
 import java.util.Map;
@@ -69,10 +71,10 @@ public final class NicklistRenderer extends DefaultListCellRenderer implements
69 71
         config.addChangeListener("ui", "nicklistbackgroundcolour", this);
70 72
         config.addChangeListener("ui", "backgroundcolour", this);
71 73
         config.addChangeListener("ui", "nickListAltBackgroundColour", this);
72
-        altBackgroundColour = config.getOptionColour(
74
+        altBackgroundColour = UIUtilities.convertColour(config.getOptionColour(
73 75
                 "ui", "nickListAltBackgroundColour",
74 76
                 "ui", "nicklistbackgroundcolour",
75
-                "ui", "backgroundcolour");
77
+                "ui", "backgroundcolour"));
76 78
         showColours = config.getOptionBool("ui", "shownickcoloursinnicklist");
77 79
     }
78 80
 
@@ -93,11 +95,11 @@ public final class NicklistRenderer extends DefaultListCellRenderer implements
93 95
 
94 96
         if (showColours && map != null) {
95 97
             if (map.containsKey(ChannelClientProperty.NICKLIST_FOREGROUND)) {
96
-                setForeground((Color) map.get(ChannelClientProperty.NICKLIST_FOREGROUND));
98
+                setForeground(UIUtilities.convertColour((Colour) map.get(ChannelClientProperty.NICKLIST_FOREGROUND)));
97 99
             }
98 100
 
99 101
             if (map.containsKey(ChannelClientProperty.NICKLIST_BACKGROUND)) {
100
-                setBackground((Color) map.get(ChannelClientProperty.NICKLIST_BACKGROUND));
102
+                setBackground(UIUtilities.convertColour((Colour) map.get(ChannelClientProperty.NICKLIST_BACKGROUND)));
101 103
             }
102 104
         }
103 105
 
@@ -112,10 +114,10 @@ public final class NicklistRenderer extends DefaultListCellRenderer implements
112 114
 
113 115
         } else {
114 116
             altBackgroundColour =
115
-                    config.getOptionColour(
117
+                    UIUtilities.convertColour(config.getOptionColour(
116 118
                     "ui", "nickListAltBackgroundColour",
117 119
                     "ui", "nicklistbackgroundcolour",
118
-                    "ui", "backgroundcolour");
120
+                    "ui", "backgroundcolour"));
119 121
         }
120 122
         nicklist.repaint();
121 123
     }

+ 4
- 4
src/com/dmdirc/addons/ui_swing/framemanager/buttonbar/ButtonBar.java Просмотреть файл

@@ -35,10 +35,10 @@ import com.dmdirc.config.IdentityManager;
35 35
 import com.dmdirc.interfaces.ConfigChangeListener;
36 36
 import com.dmdirc.interfaces.FrameInfoListener;
37 37
 import com.dmdirc.interfaces.NotificationListener;
38
-import com.dmdirc.ui.WindowManager;
39 38
 import com.dmdirc.interfaces.ui.Window;
39
+import com.dmdirc.ui.WindowManager;
40
+import com.dmdirc.ui.Colour;
40 41
 
41
-import java.awt.Color;
42 42
 import java.awt.Dimension;
43 43
 import java.awt.Insets;
44 44
 import java.awt.event.ActionEvent;
@@ -422,7 +422,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
422 422
     /** {@inheritDoc} */
423 423
     @Override
424 424
     public void notificationSet(final FrameContainer window,
425
-            final Color colour) {
425
+            final Colour colour) {
426 426
         UIUtilities.invokeLater(new Runnable() {
427 427
 
428 428
             /** {@inheritDoc} */
@@ -430,7 +430,7 @@ public final class ButtonBar implements FrameManager, ActionListener,
430 430
             public void run() {
431 431
                 final FrameToggleButton button = getButton(window);
432 432
                 if (button != null) {
433
-                    button.setForeground(colour);
433
+                    button.setForeground(UIUtilities.convertColour(colour));
434 434
                 }
435 435
             }
436 436
         });

+ 4
- 2
src/com/dmdirc/addons/ui_swing/framemanager/tree/NodeLabel.java Просмотреть файл

@@ -24,11 +24,13 @@ package com.dmdirc.addons.ui_swing.framemanager.tree;
24 24
 
25 25
 import com.dmdirc.FrameContainer;
26 26
 import com.dmdirc.addons.ui_swing.SelectionListener;
27
+import com.dmdirc.addons.ui_swing.UIUtilities;
27 28
 import com.dmdirc.addons.ui_swing.components.ImageButton;
28 29
 import com.dmdirc.addons.ui_swing.components.frames.TextFrame;
29 30
 import com.dmdirc.config.IdentityManager;
30 31
 import com.dmdirc.interfaces.FrameInfoListener;
31 32
 import com.dmdirc.interfaces.NotificationListener;
33
+import com.dmdirc.ui.Colour;
32 34
 import com.dmdirc.ui.IconManager;
33 35
 import com.dmdirc.ui.messages.Styliser;
34 36
 
@@ -129,9 +131,9 @@ public class NodeLabel extends JPanel implements SelectionListener,
129 131
     /** {@inheritDoc} */
130 132
     @Override
131 133
     public void notificationSet(final FrameContainer window,
132
-            final Color colour) {
134
+            final Colour colour) {
133 135
         if (equals(window)) {
134
-            notificationColour = colour;
136
+            notificationColour = UIUtilities.convertColour(colour);
135 137
         }
136 138
     }
137 139
 

+ 8
- 6
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeFrameManager.java Просмотреть файл

@@ -34,9 +34,9 @@ import com.dmdirc.interfaces.FrameInfoListener;
34 34
 import com.dmdirc.interfaces.NotificationListener;
35 35
 import com.dmdirc.logger.ErrorLevel;
36 36
 import com.dmdirc.logger.Logger;
37
+import com.dmdirc.ui.Colour;
37 38
 import com.dmdirc.ui.WindowManager;
38 39
 
39
-import java.awt.Color;
40 40
 import java.awt.Rectangle;
41 41
 import java.awt.event.MouseEvent;
42 42
 import java.io.Serializable;
@@ -271,12 +271,14 @@ public final class TreeFrameManager implements FrameManager,
271 271
 
272 272
     /** Sets treeview colours. */
273 273
     private void setColours() {
274
-        tree.setBackground(IdentityManager.getGlobalConfig().getOptionColour(
274
+        tree.setBackground(UIUtilities.convertColour(
275
+                IdentityManager.getGlobalConfig().getOptionColour(
275 276
                 "treeview", "backgroundcolour",
276
-                "ui", "backgroundcolour"));
277
-        tree.setForeground(IdentityManager.getGlobalConfig().getOptionColour(
277
+                "ui", "backgroundcolour")));
278
+        tree.setForeground(UIUtilities.convertColour(
279
+                IdentityManager.getGlobalConfig().getOptionColour(
278 280
                 "treeview", "foregroundcolour",
279
-                "ui", "foregroundcolour"));
281
+                "ui", "foregroundcolour")));
280 282
 
281 283
         tree.repaint();
282 284
     }
@@ -360,7 +362,7 @@ public final class TreeFrameManager implements FrameManager,
360 362
 
361 363
     /** {@inheritDoc} */
362 364
     @Override
363
-    public void notificationSet(final FrameContainer window, final Color colour) {
365
+    public void notificationSet(final FrameContainer window, final Colour colour) {
364 366
         SwingUtilities.invokeLater(new Runnable() {
365 367
 
366 368
             /** {@inheritDoc} */

+ 10
- 10
src/com/dmdirc/addons/ui_swing/framemanager/tree/TreeViewTreeCellRenderer.java Просмотреть файл

@@ -22,10 +22,10 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing.framemanager.tree;
24 24
 
25
+import com.dmdirc.addons.ui_swing.UIUtilities;
25 26
 import com.dmdirc.config.ConfigManager;
26 27
 import com.dmdirc.config.IdentityManager;
27 28
 import com.dmdirc.interfaces.ConfigChangeListener;
28
-import com.dmdirc.ui.messages.ColourManager;
29 29
 import com.dmdirc.ui.messages.Styliser;
30 30
 
31 31
 import java.awt.Color;
@@ -86,7 +86,7 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
86 86
      * Configures the renderer based on the passed parameters.
87 87
      *
88 88
      * @param tree JTree for this renderer.
89
-     * @param value node to be renderered.
89
+     * @param value node to be rendered.
90 90
      * @param sel whether the node is selected.
91 91
      * @param expanded whether the node is expanded.
92 92
      * @param leaf whether the node is a leaf.
@@ -135,9 +135,9 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
135 135
             sb.append(Styliser.CODE_BOLD);
136 136
         }
137 137
         sb.append(Styliser.CODE_HEXCOLOUR);
138
-        sb.append(ColourManager.getHex(foreground));
138
+        sb.append(UIUtilities.getHex(foreground));
139 139
         sb.append(',');
140
-        sb.append(ColourManager.getHex(background));
140
+        sb.append(UIUtilities.getHex(background));
141 141
         label.setBackground(background);
142 142
         label.setOpaque(true);
143 143
         label.setTextStyle(styliser, sb.toString());
@@ -150,18 +150,18 @@ public class TreeViewTreeCellRenderer implements TreeCellRenderer,
150 150
 
151 151
     /** Sets the colours for the renderer. */
152 152
     private void setColours() {
153
-        rolloverColour = config.getOptionColour(
153
+        rolloverColour = UIUtilities.convertColour(config.getOptionColour(
154 154
                 "ui", "treeviewRolloverColour",
155 155
                 "treeview", "backgroundcolour",
156
-                "ui", "backgroundcolour");
157
-        activeBackground = config.getOptionColour(
156
+                "ui", "backgroundcolour"));
157
+        activeBackground = UIUtilities.convertColour(config.getOptionColour(
158 158
                 "ui", "treeviewActiveBackground",
159 159
                 "treeview", "backgroundcolour",
160
-                "ui", "backgroundcolour");
161
-        activeForeground = config.getOptionColour(
160
+                "ui", "backgroundcolour"));
161
+        activeForeground = UIUtilities.convertColour(config.getOptionColour(
162 162
                 "ui", "treeviewActiveForeground",
163 163
                 "treeview", "foregroundcolour",
164
-                "ui", "foregroundcolour");
164
+                "ui", "foregroundcolour"));
165 165
         activeBold = config.getOptionBool("ui", "treeviewActiveBold");
166 166
 
167 167
         manager.getTree().repaint();

Загрузка…
Отмена
Сохранить