summaryrefslogtreecommitdiff
path: root/NET/worlds/console/SplashCanvas.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/console/SplashCanvas.java')
-rw-r--r--NET/worlds/console/SplashCanvas.java205
1 files changed, 205 insertions, 0 deletions
diff --git a/NET/worlds/console/SplashCanvas.java b/NET/worlds/console/SplashCanvas.java
new file mode 100644
index 0000000..2ccd13d
--- /dev/null
+++ b/NET/worlds/console/SplashCanvas.java
@@ -0,0 +1,205 @@
+/* */ package NET.worlds.console;
+/* */
+/* */ import java.awt.Canvas;
+/* */ import java.awt.Component;
+/* */ import java.awt.Dimension;
+/* */ import java.awt.Graphics;
+/* */ import java.awt.Image;
+/* */ import java.awt.MediaTracker;
+/* */ import java.awt.Toolkit;
+/* */ import java.util.Vector;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ class SplashCanvas
+/* */ extends Canvas
+/* */ {
+/* */ private static final long serialVersionUID = 341168247494647821L;
+/* */ protected String name;
+/* */ protected Image image;
+/* */ protected Dimension dim;
+/* 90 */ protected Vector<Overlay> overlays = new Vector();
+/* */
+/* */ SplashCanvas(String name) {
+/* 93 */ this.name = name;
+/* */ }
+/* */
+/* */ public void flush() {
+/* 97 */ this.image.flush();
+/* 98 */ this.image = null;
+/* */
+/* 100 */ for (int i = 0; i < this.overlays.size(); i++) {
+/* 101 */ Overlay over = (Overlay)this.overlays.elementAt(i);
+/* 102 */ over.flush();
+/* */ }
+/* 104 */ this.overlays.removeAllElements();
+/* */ }
+/* */
+/* */ public void paint(Graphics g)
+/* */ {
+/* 109 */ super.paint(g);
+/* 110 */ g.drawImage(this.image, 0, 0, this);
+/* 111 */ for (int i = 0; i < this.overlays.size(); i++) {
+/* 112 */ Overlay over = (Overlay)this.overlays.elementAt(i);
+/* 113 */ over.paint(g, this);
+/* */ }
+/* */ }
+/* */
+/* */ public void setImage(String name) {
+/* 118 */ this.name = name;
+/* 119 */ this.image = null;
+/* 120 */ imageSize();
+/* */ }
+/* */
+/* */ public void addOverlay(String name, int x, int y) {
+/* 124 */ Overlay over = new Overlay(name, x, y);
+/* */
+/* 126 */ Dimension dim = over.imageSize(this);
+/* 127 */ this.overlays.addElement(over);
+/* 128 */ repaint(x, y, dim.width, dim.height);
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void removeOverlay(String name, int x, int y)
+/* */ {
+/* 136 */ for (int i = 0; i < this.overlays.size(); i++) {
+/* 137 */ Overlay over = (Overlay)this.overlays.elementAt(i);
+/* 138 */ if (over.matches(name, x, y)) {
+/* 139 */ Dimension dim = over.imageSize(this);
+/* 140 */ this.overlays.removeElementAt(i);
+/* 141 */ repaint(x, y, dim.width, dim.height);
+/* 142 */ return;
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */ private Dimension imageSize() {
+/* 148 */ if (this.image == null) {
+/* 149 */ this.image = getEarlyImage(this.name, this);
+/* 150 */ if (this.image != null) {
+/* 151 */ int width = this.image.getWidth(this);
+/* 152 */ int height = this.image.getHeight(this);
+/* 153 */ if ((width != -1) && (height != -1))
+/* 154 */ return this.dim = new Dimension(width, height);
+/* */ }
+/* 156 */ this.dim = new Dimension(0, 0);
+/* */ }
+/* 158 */ for (int i = 0; i < this.overlays.size(); i++) {
+/* 159 */ Overlay over = (Overlay)this.overlays.elementAt(i);
+/* 160 */ over.imageSize(this);
+/* */ }
+/* 162 */ return this.dim;
+/* */ }
+/* */
+/* */
+/* */ public static Image getEarlyImage(String name, Component comp)
+/* */ {
+/* 168 */ for (int pass = 0; pass < 2; pass++) {
+/* 169 */ String imagename = Gamma.earlyURLUnalias(name);
+/* 170 */ Image image = Toolkit.getDefaultToolkit().getImage(imagename);
+/* */
+/* */
+/* 173 */ MediaTracker tracker = new MediaTracker(comp);
+/* 174 */ tracker.addImage(image, 0);
+/* */ try {
+/* 176 */ tracker.waitForAll();
+/* */ }
+/* */ catch (InterruptedException localInterruptedException) {}
+/* */
+/* 180 */ if (!tracker.isErrorAny()) {
+/* 181 */ return image;
+/* */ }
+/* */
+/* 184 */ if (pass == 0)
+/* 185 */ name = "..\\" + name;
+/* */ }
+/* 187 */ return null;
+/* */ }
+/* */
+/* */ public Dimension getPreferredSize()
+/* */ {
+/* 192 */ return imageSize();
+/* */ }
+/* */
+/* */ public Dimension getMinimumSize()
+/* */ {
+/* 197 */ return imageSize();
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\console\SplashCanvas.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file