17 package net.squiz.matrix.ui;
21 import java.awt.image.*;
22 import javax.swing.border.*;
23 import net.squiz.matrix.core.*;
30 public class StatusKey extends JPanel implements MatrixConstants {
32 public static final int KEY_SIZE = 15;
33 public static final Color KEY_BORDER =
new Color(0xCCCCCC);
34 public static final Font keyFont =
new Font(
"key_font", Font.PLAIN, 10);
35 public static final Dimension fillerSize =
new Dimension(1, 1);
42 setBackground(Color.white);
43 setBorder(
new EmptyBorder(3, 3, 3, 3));
44 setLayout(
new BoxLayout(
this, BoxLayout.Y_AXIS));
45 setMinimumSize(
new Dimension(0,0));
46 setMaximumSize(
new Dimension(0,200));
47 setPreferredSize(
new Dimension(0,200));
53 private void createKey() {
54 add(createColourKey(ARCHIVED_COLOUR,
"Archived"));
55 add(createColourKey(UNDER_CONSTRUCTION_COLOUR,
"Under Construction"));
56 add(createColourKey(PENDING_APPROVAL_COLOUR,
"Pending Approval"));
57 add(createColourKey(APPROVED_COLOUR,
"Approved"));
58 add(createColourKey(LIVE_COLOUR,
"Live"));
59 add(createColourKey(LIVE_APPROVAL_COLOUR,
"Up For Review"));
60 add(createColourKey(EDITING_COLOUR,
"Safe Editing"));
61 add(createColourKey(EDITING_APPROVAL_COLOUR,
"Safe Edit Pending Approval"));
62 add(createColourKey(EDITING_APPROVED_COLOUR,
"Safe Edit Approved"));
65 private JLabel createColourKey(Color c, String labelText) {
66 JLabel label =
new JLabel(labelText);
67 label.setIcon(createIcon(c));
68 label.setFont(keyFont);
70 add(
new Box.Filler(fillerSize, fillerSize, fillerSize));
75 private Icon createIcon(Color c) {
77 BufferedImage image =
new BufferedImage(KEY_SIZE, KEY_SIZE, BufferedImage.TYPE_INT_RGB);
78 Graphics g = image.createGraphics();
81 g.fillRect(0, 0, KEY_SIZE, KEY_SIZE);
82 g.setColor(c.darker());
83 g.drawRect(0, 0, KEY_SIZE - 1, KEY_SIZE - 1);
85 ImageIcon icon =
new ImageIcon(image);