summaryrefslogtreecommitdiff
path: root/NET/worlds/console/Overlay.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/console/Overlay.java')
-rw-r--r--NET/worlds/console/Overlay.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/NET/worlds/console/Overlay.java b/NET/worlds/console/Overlay.java
new file mode 100644
index 0000000..237c506
--- /dev/null
+++ b/NET/worlds/console/Overlay.java
@@ -0,0 +1,53 @@
+package NET.worlds.console;
+
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Graphics;
+import java.awt.Image;
+
+class Overlay {
+ private String name;
+ private int x;
+ private int y;
+ private Image image;
+ private Dimension dim;
+
+ public Overlay(String name, int x, int y) {
+ this.name = name;
+ this.x = x;
+ this.y = y;
+ this.image = null;
+ }
+
+ public void paint(Graphics g, Component c) {
+ if (this.image != null) {
+ g.drawImage(this.image, this.x, this.y, c);
+ }
+ }
+
+ public Dimension imageSize(Component c) {
+ if (this.image == null) {
+ this.image = SplashCanvas.getEarlyImage(this.name, c);
+ if (this.image != null) {
+ int width = this.image.getWidth(c);
+ int height = this.image.getHeight(c);
+ if (width != -1 && height != -1) {
+ return this.dim = new Dimension(width, height);
+ }
+ }
+
+ this.dim = new Dimension(0, 0);
+ }
+
+ return this.dim;
+ }
+
+ public boolean matches(String name, int x, int y) {
+ return x == this.x && y == this.y && name.equals(this.name);
+ }
+
+ public void flush() {
+ this.image.flush();
+ this.image = null;
+ }
+}