1 /*****************************************************/
\r
2 /* This java file is a part of the */
\r
4 /* - Plouf's Java IRC Client - */
\r
6 /* Copyright (C) 2002 - 2004 Philippe Detournay */
\r
8 /* All contacts : theplouf@yahoo.com */
\r
10 /* PJIRC is free software; you can redistribute */
\r
11 /* it and/or modify it under the terms of the GNU */
\r
12 /* General Public License as published by the */
\r
13 /* Free Software Foundation; version 2 or later of */
\r
16 /* PJIRC is distributed in the hope that it will */
\r
17 /* be useful, but WITHOUT ANY WARRANTY; without */
\r
18 /* even the implied warranty of MERCHANTABILITY or */
\r
19 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
\r
20 /* General Public License for more details. */
\r
22 /* You should have received a copy of the GNU */
\r
23 /* General Public License along with PJIRC; if */
\r
24 /* not, write to the Free Software Foundation, */
\r
25 /* Inc., 59 Temple Place, Suite 330, Boston, */
\r
26 /* MA 02111-1307 USA */
\r
28 /*****************************************************/
\r
30 package irc.gui.pixx;
\r
32 import java.awt.Color;
\r
35 * PixxInterface color model.
\r
37 public class PixxColorModel {
\r
41 public static final int COLOR_BLACK = 0;
\r
45 public static final int COLOR_WHITE = 1;
\r
49 public static final int COLOR_DARK_GRAY = 2;
\r
53 public static final int COLOR_GRAY = 3;
\r
57 public static final int COLOR_LIGHT_GRAY = 4;
\r
61 public static final int COLOR_FRONT = 5;
\r
65 public static final int COLOR_BACK = 6;
\r
69 public static final int COLOR_SELECTED = 7;
\r
73 public static final int COLOR_EVENT = 8;
\r
77 public static final int COLOR_CLOSE = 9;
\r
81 public static final int COLOR_VOICE = 10;
\r
85 public static final int COLOR_OP = 11;
\r
89 public static final int COLOR_SEMIOP = 12;
\r
93 public static final int COLOR_MALE = 13;
\r
97 public static final int COLOR_FEMEALE = 14;
\r
101 public static final int COLOR_UNDEF = 15;
\r
103 private Color[] _colors;
\r
106 * Create a new PixxColorModel using default colors.
\r
108 public PixxColorModel() {
\r
109 Color[] cols = new Color[16];
\r
110 cols[0] = Color.black;
\r
111 cols[1] = Color.white;
\r
112 cols[2] = new Color(0x868686);
\r
113 cols[3] = Color.gray;
\r
114 cols[4] = new Color(0xD0D0D0);
\r
115 cols[5] = new Color(0x336699);
\r
116 cols[6] = new Color(0x084079);
\r
117 cols[7] = new Color(0x003167);
\r
118 cols[8] = new Color(0xa40000);
\r
119 cols[9] = new Color(0x4B8ECE);
\r
120 cols[10] = new Color(0x008000);
\r
121 cols[11] = new Color(0x336699);
\r
122 cols[12] = new Color(0x336699);
\r
123 cols[13] = new Color(0x4040ff);
\r
124 cols[14] = new Color(0xff40ff);
\r
125 cols[15] = new Color(0x336699);
\r
130 * Set the i'th color.
\r
137 public void setColor(int i, Color c) {
\r
138 if ((i >= 0) && (i < _colors.length))
\r
143 * Get the number of color in the mode.
\r
145 * @return color count.
\r
147 public int getColorCount() {
\r
148 return _colors.length;
\r
151 private Color computeColor(int r, int g, int b, int i) {
\r
164 return new Color(r, g, b);
\r
168 * Create a new PixxColorModel using given r g b basecolor.
\r
173 * green base color.
\r
177 public PixxColorModel(int r, int g, int b) {
\r
178 Color[] cols = new Color[16];
\r
179 cols[0] = Color.black;
\r
180 cols[1] = Color.white;
\r
181 cols[2] = new Color(0x868686);
\r
182 cols[3] = Color.gray;
\r
183 cols[4] = new Color(0xD0D0D0);
\r
184 cols[8] = new Color(0xa40000);
\r
185 cols[10] = new Color(0x008000);
\r
186 cols[13] = new Color(0x4040ff);
\r
187 cols[14] = new Color(0xff40ff);
\r
189 cols[5] = computeColor(r, g, b, 0x66);
\r
190 cols[6] = computeColor(r, g, b, 0x55);
\r
191 cols[7] = computeColor(r, g, b, 0x4B);
\r
192 cols[9] = computeColor(r, g, b, 0x80);
\r
193 cols[11] = computeColor(r, g, b, 0x66);
\r
194 cols[12] = computeColor(r, g, b, 0x66);
\r
195 cols[15] = computeColor(r, g, b, 0x66);
\r
200 * Create a new PixxColorModel using given colors.
\r
205 public PixxColorModel(Color[] cols) {
\r
209 private void init(Color[] cols) {
\r
210 _colors = new Color[cols.length];
\r
211 for (int i = 0; i < cols.length; i++)
\r
212 _colors[i] = cols[i];
\r
216 * Get the color at the given index.
\r
220 * @return the i'th color.
\r
222 public Color getColor(int i) {
\r