1 19 20 package taskblocks.modelimpl; 21 22 import java.awt.Color ; 23 import java.awt.Graphics2D ; 24 import java.awt.image.BufferedImage ; 25 26 import javax.swing.Icon ; 27 import javax.swing.ImageIcon ; 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 (255,120,100), 1), 36 new ColorLabel("Orange", new Color (255,200,80), 2), 37 new ColorLabel("Yellow", new Color (255,255,100), 3), 38 new ColorLabel("Green", new Color (140,255,110), 4), 39 new ColorLabel("Gray", new Color (200,200,200), 5), 40 }; 41 42 public Color _color; 43 public String _name; 44 public Icon _icon; 45 public int _index; 46 public ColorLabel(String name, Color color, int index) { 47 _name = name; 48 _color = color; 49 _index = index; 50 BufferedImage img = new BufferedImage (12, 12, BufferedImage.TYPE_INT_ARGB); 51 Graphics2D g2 = (Graphics2D )img.getGraphics(); 52 g2.setColor(_color); 53 g2.fillRect(0,0,img.getWidth(), img.getHeight()); 54 _icon = new ImageIcon (img); 55 } 56 public String toString() { 57 return _name; 58 } 59 } 60 | Popular Tags |