diff options
Diffstat (limited to 'src/com/fourisland/fourpuzzle/window/Window.java')
-rw-r--r-- | src/com/fourisland/fourpuzzle/window/Window.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/com/fourisland/fourpuzzle/window/Window.java b/src/com/fourisland/fourpuzzle/window/Window.java index 8cdaf9a..da3216a 100644 --- a/src/com/fourisland/fourpuzzle/window/Window.java +++ b/src/com/fourisland/fourpuzzle/window/Window.java | |||
@@ -6,13 +6,9 @@ | |||
6 | package com.fourisland.fourpuzzle.window; | 6 | package com.fourisland.fourpuzzle.window; |
7 | 7 | ||
8 | import com.fourisland.fourpuzzle.util.Interval; | 8 | import com.fourisland.fourpuzzle.util.Interval; |
9 | import com.fourisland.fourpuzzle.util.TransparentPixelFilter; | ||
10 | import java.awt.Graphics2D; | 9 | import java.awt.Graphics2D; |
11 | import java.awt.Image; | ||
12 | import java.awt.Rectangle; | 10 | import java.awt.Rectangle; |
13 | import java.awt.Toolkit; | ||
14 | import java.awt.image.BufferedImage; | 11 | import java.awt.image.BufferedImage; |
15 | import java.awt.image.FilteredImageSource; | ||
16 | 12 | ||
17 | /** | 13 | /** |
18 | * | 14 | * |
@@ -20,7 +16,13 @@ import java.awt.image.FilteredImageSource; | |||
20 | */ | 16 | */ |
21 | public enum Window | 17 | public enum Window |
22 | { | 18 | { |
23 | Default(32), | 19 | Default(32) |
20 | { | ||
21 | protected BufferedImage getBackground() | ||
22 | { | ||
23 | return SystemGraphic.getMessageBackground(); | ||
24 | } | ||
25 | }, | ||
24 | Selector(64) | 26 | Selector(64) |
25 | { | 27 | { |
26 | Interval in = Interval.createTickInterval(4); | 28 | Interval in = Interval.createTickInterval(4); |
@@ -41,6 +43,11 @@ public enum Window | |||
41 | return super.getX(sa); | 43 | return super.getX(sa); |
42 | } | 44 | } |
43 | } | 45 | } |
46 | |||
47 | protected BufferedImage getBackground() | ||
48 | { | ||
49 | return SystemGraphic.getSelectionBackground(); | ||
50 | } | ||
44 | }; | 51 | }; |
45 | 52 | ||
46 | protected enum SystemArea | 53 | protected enum SystemArea |
@@ -118,11 +125,15 @@ public enum Window | |||
118 | return getHeight(SystemArea.TOP_LEFT); | 125 | return getHeight(SystemArea.TOP_LEFT); |
119 | } | 126 | } |
120 | 127 | ||
121 | public Image getImage(int width, int height) | 128 | protected abstract BufferedImage getBackground(); |
129 | |||
130 | public BufferedImage getImage(int width, int height) | ||
122 | { | 131 | { |
123 | BufferedImage temp = new BufferedImage(getFullWidth(width), getFullHeight(height), BufferedImage.TYPE_INT_ARGB); | 132 | BufferedImage temp = new BufferedImage(getFullWidth(width), getFullHeight(height), BufferedImage.TYPE_INT_ARGB); |
124 | Graphics2D g = temp.createGraphics(); | 133 | Graphics2D g = temp.createGraphics(); |
125 | 134 | ||
135 | g.drawImage(getBackground(), 1, 1, getFullWidth(width)-2, getFullHeight(height)-2, null); | ||
136 | |||
126 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_LEFT)), 0, 0, null); | 137 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_LEFT)), 0, 0, null); |
127 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP)), getWidth(SystemArea.TOP_LEFT), 0, width, getHeight(SystemArea.TOP), null); | 138 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP)), getWidth(SystemArea.TOP_LEFT), 0, width, getHeight(SystemArea.TOP), null); |
128 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_RIGHT)), getWidth(SystemArea.TOP_LEFT)+width, 0, null); | 139 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.TOP_RIGHT)), getWidth(SystemArea.TOP_LEFT)+width, 0, null); |
@@ -132,6 +143,6 @@ public enum Window | |||
132 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.BOTTOM_RIGHT)), getWidth(SystemArea.BOTTOM_RIGHT)+width, getHeight(SystemArea.TOP_RIGHT)+height, null); | 143 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.BOTTOM_RIGHT)), getWidth(SystemArea.BOTTOM_RIGHT)+width, getHeight(SystemArea.TOP_RIGHT)+height, null); |
133 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.RIGHT)), (width+getWidth(SystemArea.TOP_LEFT)+getWidth(SystemArea.TOP_RIGHT))-getWidth(SystemArea.RIGHT), getHeight(SystemArea.TOP_RIGHT), getWidth(SystemArea.RIGHT), height, null); | 144 | g.drawImage(SystemGraphic.getChoiceArea(getBounds(SystemArea.RIGHT)), (width+getWidth(SystemArea.TOP_LEFT)+getWidth(SystemArea.TOP_RIGHT))-getWidth(SystemArea.RIGHT), getHeight(SystemArea.TOP_RIGHT), getWidth(SystemArea.RIGHT), height, null); |
134 | 145 | ||
135 | return Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(temp.getSource(), new TransparentPixelFilter(SystemGraphic.getTransparentColor().getRGB()))); | 146 | return temp; |
136 | } | 147 | } |
137 | } \ No newline at end of file | 148 | } \ No newline at end of file |