KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > taskblocks > modelimpl > ColorLabel


1 /*
2  * Copyright (C) Jakub Neubauer, 2007
3  *
4  * This file is part of TaskBlocks
5  *
6  * TaskBlocks is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * TaskBlocks is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */

19
20 package taskblocks.modelimpl;
21
22 import java.awt.Color JavaDoc;
23 import java.awt.Graphics2D JavaDoc;
24 import java.awt.image.BufferedImage JavaDoc;
25
26 import javax.swing.Icon JavaDoc;
27 import javax.swing.ImageIcon JavaDoc;
28
29 import taskblocks.Colors;
30
31 public class ColorLabel {
32     
33     public static ColorLabel[] COLOR_LABELS = new ColorLabel[] {
34         new ColorLabel("None", Colors.TASK_COLOR, 0),
35         new ColorLabel("Red", new Color JavaDoc(255,120,100), 1),
36         new ColorLabel("Orange", new Color JavaDoc(255,200,80), 2),
37         new ColorLabel("Yellow", new Color JavaDoc(255,255,100), 3),
38         new ColorLabel("Green", new Color JavaDoc(140,255,110), 4),
39         new ColorLabel("Gray", new Color JavaDoc(200,200,200), 5),
40     };
41     
42     public Color JavaDoc _color;
43     public String JavaDoc _name;
44     public Icon JavaDoc _icon;
45     public int _index;
46     public ColorLabel(String JavaDoc name, Color JavaDoc color, int index) {
47         _name = name;
48         _color = color;
49         _index = index;
50         BufferedImage JavaDoc img = new BufferedImage JavaDoc(12, 12, BufferedImage.TYPE_INT_ARGB);
51         Graphics2D JavaDoc g2 = (Graphics2D JavaDoc)img.getGraphics();
52         g2.setColor(_color);
53         g2.fillRect(0,0,img.getWidth(), img.getHeight());
54         _icon = new ImageIcon JavaDoc(img);
55     }
56     public String JavaDoc toString() {
57         return _name;
58     }
59 }
60
Popular Tags