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; } }