16 package net.squiz.matrix.core;
32 protected static final int[]
VALID_X = {LEFT, RIGHT, CENTER};
35 protected static final int[]
VALID_Y = {TOP, BOTTOM, CENTER};
47 private static Map disabledIcons =
new HashMap();
62 if (decorator.getIconWidth() > mainIcon.getIconWidth()) {
63 throw new IllegalArgumentException(
64 "decorator icon is wider than main icon");
66 if (decorator.getIconHeight() > mainIcon.getIconHeight()) {
67 throw new IllegalArgumentException(
68 "decorator icon is higher than main icon");
71 throw new IllegalArgumentException(
72 "xAlignment must be LEFT, RIGHT or CENTER");
75 throw new IllegalArgumentException(
76 "yAlignment must be TOP, BOTTOM or CENTER");
80 this.decorator = decorator;
92 for (
int i = 0; i < legal.length; i++) {
93 if (value == legal[i])
104 if (!disabledIcons.containsKey(
mainIcon)) {
105 Image grayImage = GrayFilter.createDisabledImage(((ImageIcon)
mainIcon).getImage());
106 disabledIcons.put(mainIcon, grayImage);
108 return new ImageIcon((Image)disabledIcons.get(
mainIcon));
135 public void paintIcon(Component c, Graphics g,
int x,
int y) {
141 x += (w - decorator.getIconWidth()) / 2;
143 x += (w - decorator.getIconWidth());
145 y += (h - decorator.getIconHeight()) / 2;
147 y += (h - decorator.getIconHeight());
148 decorator.paintIcon(c, g, x, y);