2002/08/16 23:37:17
[org.ibex.core.git] / src / org / xwt / Surface.java
1 // Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL]
2 package org.xwt;
3
4 import org.bouncycastle.util.encoders.Base64;
5 import org.xwt.util.*;
6 import java.io.*;
7 import java.util.*;
8
9 /** 
10  *  A Surface, as described in the XWT Reference.
11  *
12  *  Platform subclasses should include an inner class subclass of
13  *  Surface to return from the Platform._createSurface() method
14  *
15  *  Note that the members in the section 'state variables' are either
16  *  in real-time (the actual size/position/state), or in
17  *  MessageQueue-time (the size/position/state at the time that the
18  *  now-executing message was enqueued). This distinction is important.
19  */
20 public abstract class Surface {
21
22     // Static Data ////////////////////////////////////////////////////////////////////////////////
23
24     /** true iff a user-created surface was created */
25     static boolean refreshableSurfaceWasCreated = false;
26
27     /** a reference to the most recently enqueued Move message; used to throttle the message rate */
28     private static Message lastMoveMessage = null;
29
30     /** all instances of Surface which need to be refreshed by the MessageQueue */
31     public static Vec allSurfaces = new Vec();
32
33     /** true iff the alt button is pressed down, in real time */
34     public static boolean alt = false;
35     
36     /** true iff the control button is pressed down, in real time */
37     public static boolean control = false;
38
39     /** true iff the shift button is pressed down, in real time */
40     public static boolean shift = false;
41
42     /** true iff button 1 is depressed, in MessageQueue-time */
43     public static boolean button1 = false;
44
45     /** true iff button 2 is depressed, in MessageQueue-time */
46     public static boolean button2 = false;
47
48     /** true iff button 3 is depressed, in MessageQueue-time */
49     public static boolean button3 = false;
50
51     /** true iff all surfaces created from now on should be scarred */
52     public static boolean scarAllSurfacesFromNowOn = false;
53
54
55     // Public Members and State Variables /////////////////////////////////////////////////////////
56
57     /** this is the box on this surface which the mouse was inside at the time that the currently-executing event was enqueued */
58     public Box boxContainingMouse = null;
59
60     /** false if the surface has never been rendered; used to determine if the surface should be repositioned to be centered on the screen */
61     public boolean centerSurfaceOnRender = true;
62
63     /** the x position of the mouse, relative to this Surface, in MessageQueue-time */
64     public int mousex;
65
66     /** the y position of the mouse, relative to this Surface, in MessageQueue-time */
67     public int mousey;
68
69     /** True iff this surface is minimized, in real time */
70     public boolean minimized = false;
71
72     /** True iff this surface is maximized, in real time */
73     public boolean maximized = false;
74
75     /** The name of the cursor on this surface -- this value fluctuates during rendering, so it may not be accurate;
76      *  syncCursor() is called once the value is stable, to prevent the "flickering cursor" phenomenon
77      */
78     public String cursor = "default";
79
80     /** The width of the surface's drawable area, in real time */
81     public int width = 0;
82
83     /** The height of the surface's drawable area, in real time */
84     public int height = 0;
85
86     /** The Box at the root of this surface */
87     public Box root;
88
89     /** The number of SizeChange/PosChange traps triggered since the last successful render -- used to detect infinite loops */
90     public int sizePosChangesSinceLastRender = 0;
91
92     /** the x-position of the mouse the last time a Press message was enqueued */
93     int last_press_x = Integer.MAX_VALUE;
94
95     /** the y-position of the mouse the last time a Press message was enqueued */
96     int last_press_y = Integer.MAX_VALUE;
97
98     /** the last button to recieve a Click message; used for simulating DoubleClick's */
99     static int lastClickButton = 0;
100
101     /** the last time a Click message was processed; used for simulating DoubleClick's */
102     static long lastClickTime = 0;
103     
104     
105     // Methods to be overridden by subclasses ///////////////////////////////////////////////////////
106
107     /** when this method is invoked, the surface should push itself to the back of the stacking order */
108     public abstract void toBack();
109
110     /** when this method is invoked, the surface should pull itself to the front of the stacking order */
111     public abstract void toFront();
112
113     /** sets the <i>actual</i> cursor for this surface to the cursor referenced by <tt>cursor</tt> */
114     public abstract void syncCursor();
115
116     /** If <tt>b == true</tt>, make the window invisible; otherwise, make it non-invisible. */
117     public abstract void setInvisible(boolean b);
118
119     /** If <tt>b == true</tt>, maximize the surface; otherwise, un-maximize it. */
120     protected abstract void _setMaximized(boolean b);
121
122     /** If <tt>b == true</tt>, minimize the surface; otherwise, un-minimize it. */
123     protected abstract void _setMinimized(boolean b);
124
125     /** Sets the surface's width and height. */
126     protected abstract void setSize(int width, int height);
127
128     /** Sets the surface's x and y position. */
129     public abstract void setLocation(int x, int y);
130
131     /** Sets the surface's title bar text, if applicable */
132     public abstract void setTitleBarText(String s);
133
134     /** Sets the surface's title bar text, if applicable */
135     public abstract void setIcon(Picture i);
136
137     /** copies a region from the doublebuffer to this surface */
138     public abstract void blit(DoubleBuffer source, int sx, int sy, int dx, int dy, int dx2, int dy2);
139
140     /** Destroy the surface */
141     public abstract void _dispose();
142
143     /** Notifies the surface that limits have been imposed on the surface's size */
144     public void setLimits(int min_width, int min_height, int max_width, int max_height) { }
145
146
147     // Helper methods for subclasses ////////////////////////////////////////////////////////////
148
149     protected final void Press(final int button) {
150         last_press_x = mousex;
151         last_press_y = mousey;
152
153         if (button == 1) button1 = true;
154         else if (button == 2) button2 = true;
155         else if (button == 3) button3 = true;
156
157         if (button == 1) new SimpleMessage("Press1", Boolean.TRUE, root.whoIs(mousex, mousey));
158         else if (button == 2) new SimpleMessage("Press2", Boolean.TRUE, root.whoIs(mousex, mousey));
159         else if (button == 3) {
160             final Box who = root.whoIs(mousex, mousey);
161             MessageQueue.add(new Message() { public void perform() {
162                 Surface.this.boxContainingMouse = who;
163                 Platform.clipboardReadEnabled = true;
164                 root.put("Press3", null, Boolean.TRUE);
165                 Platform.clipboardReadEnabled = false;
166             }});
167         }
168     }
169
170     protected final void Release(int button) {
171         if (button == 1) button1 = false;
172         else if (button == 2) button2 = false;
173         else if (button == 3) button3 = false;
174
175         if (button == 1) new SimpleMessage("Release1", Boolean.TRUE, root.whoIs(mousex, mousey));
176         else if (button == 2) new SimpleMessage("Release2", Boolean.TRUE, root.whoIs(mousex, mousey));
177         else if (button == 3) new SimpleMessage("Release3", Boolean.TRUE, root.whoIs(mousex, mousey));
178
179         if (Platform.needsAutoClick() && Math.abs(last_press_x - mousex) < 5 && Math.abs(last_press_y - mousey) < 5) Click(button);
180         last_press_x = Integer.MAX_VALUE;
181         last_press_y = Integer.MAX_VALUE;
182     }
183
184     protected final void Click(int button) {
185         if (button == 1) new SimpleMessage("Click1", Boolean.TRUE, root.whoIs(mousex, mousey));
186         else if (button == 2) new SimpleMessage("Click2", Boolean.TRUE, root.whoIs(mousex, mousey));
187         else if (button == 3) new SimpleMessage("Click3", Boolean.TRUE, root.whoIs(mousex, mousey));
188         if (Platform.needsAutoDoubleClick()) {
189             long now = System.currentTimeMillis();
190             if (lastClickButton == button && now - lastClickTime < 350) DoubleClick(button);
191             lastClickButton = button;
192             lastClickTime = now;
193         }
194     }
195
196     protected final void DoubleClick(int button) {
197         if (button == 1) new SimpleMessage("DoubleClick1", Boolean.TRUE, root.whoIs(mousex, mousey));
198         else if (button == 2) new SimpleMessage("DoubleClick2", Boolean.TRUE, root.whoIs(mousex, mousey));
199         else if (button == 3) new SimpleMessage("DoubleClick3", Boolean.TRUE, root.whoIs(mousex, mousey));
200     }
201
202     /** sends a KeyPressed message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
203     protected final void KeyPressed(String key) {
204         if (key == null) return;
205
206         if (key.toLowerCase().endsWith("shift")) shift = true;
207         else if (shift) key = key.toUpperCase();
208
209         if (key.toLowerCase().equals("alt")) alt = true;
210         else if (alt) key = "A-" + key;
211
212         if (key.toLowerCase().endsWith("control")) control = true;
213         else if (control) key = "C-" + key;
214
215         final String fkey = key;
216         MessageQueue.add(new KMessage(key));
217     }
218
219     // This is implemented as a private static class instead of an anonymous class to work around a GCJ bug
220     private class KMessage implements Message {
221         String key = null;
222         public KMessage(String k) { key = k; }
223         public void perform() {
224             if (key.equals("C-v") || key.equals("A-v")) Platform.clipboardReadEnabled = true;
225             outer: for(int i=0; i<keywatchers.size(); i++) {
226                 Box b = (Box)keywatchers.elementAt(i);
227                 for(Box cur = b; cur != null; cur = cur.getParent())
228                     if (cur.invisible) continue outer;
229                 b.put("KeyPressed", null, key);
230             }
231             Platform.clipboardReadEnabled = false;
232         }
233     }
234
235     /** sends a KeyReleased message; subclasses should not add the C- or A- prefixes, nor should they capitalize alphabet characters */
236     protected final void KeyReleased(final String key) {
237         if (key == null) return;
238         if (key.toLowerCase().equals("alt")) alt = false;
239         else if (key.toLowerCase().equals("control")) control = false;
240         else if (key.toLowerCase().equals("shift")) shift = false;
241         MessageQueue.add(new Message() { public void perform() {
242             outer: for(int i=0; i<keywatchers.size(); i++) {
243                 Box b = (Box)keywatchers.elementAt(i);
244                 for(Box cur = b; cur != null; cur = cur.getParent())
245                     if (cur.invisible) continue outer;
246                 b.put("KeyReleased", null, key);
247             }
248         }});
249     }
250
251     /**
252      *  Notify XWT that the mouse has moved. If the mouse leaves the
253      *  surface, but the host windowing system does not provide its new
254      *  position (for example, a Java MouseListener.mouseExited()
255      *  message), the subclass should use (-1,-1).
256      */
257     protected final void Move(final int newmousex, final int newmousey) {
258         MessageQueue.add(lastMoveMessage = new Message() { public void perform() {
259             synchronized(Surface.this) {
260
261                 // if move messages are arriving faster than we can process them, we just start ignoring them
262                 if (lastMoveMessage != this) return;
263
264                 int oldmousex = mousex;
265                 int oldmousey = mousey;
266                 mousex = newmousex;
267                 mousey = newmousey;
268
269                 String oldcursor = cursor;
270                 cursor = "default";
271
272                 // Root gets motion events outside itself (if trapped, of course)
273                 if (root.is_trapped("Move") && !root.inside(oldmousex, oldmousey) && !root.inside(mousex, mousey) && (button1 || button2 || button3))
274                     root.put("Move", null, Boolean.TRUE);
275
276                 root.Move(oldmousex, oldmousey, mousex, mousey);
277                 if (!cursor.equals(oldcursor)) syncCursor();
278             }
279         }});
280     }
281
282     protected final void SizeChange(int width, int height) {
283         this.width = width;
284         this.height = height;
285         abort = true;
286         long lastResizeTime = System.currentTimeMillis();
287         lastResizeTimeTop = (int)(lastResizeTime >> 32);
288         lastResizeTimeBottom = (int)(lastResizeTime & 0xffffffff);
289         Refresh();
290     }
291
292     protected final void PosChange(int x, int y) {
293         root.set(Box.abs, 0, x);
294         root.set(Box.abs, 1, y);
295         new SimpleMessage("PosChange", Boolean.TRUE, null);
296     }
297
298     protected final void Close() { new SimpleMessage("Close", Boolean.TRUE, null); }
299     protected final void Minimized(boolean b) { minimized = b; new SimpleMessage("Minimized", b ? Boolean.TRUE : Boolean.FALSE, null); }
300     protected final void Maximized(boolean b) { maximized = b; new SimpleMessage("Maximized", b ? Boolean.TRUE : Boolean.FALSE, null); }
301     protected final void Focused(boolean b) { new SimpleMessage("Focused", b ? Boolean.TRUE : Boolean.FALSE, null); }
302     public static void Refresh() { MessageQueue.refresh(); }
303
304     // the following value is split into two int's to work around GCJ bug java/6393
305
306     /** used in conjunction with Platform.supressDirtyOnResize() */
307     private int lastResizeTimeTop = 0;
308     private int lastResizeTimeBottom = 0;
309
310     /** This is how subclasses signal a 'shallow dirty', indicating that although the backbuffer is valid, the screen is not */
311     public final void Dirty(int x, int y, int w, int h) {
312         long lastResizeTime = (((long)lastResizeTimeTop) << 32) | (long)lastResizeTimeBottom;
313         if (Platform.supressDirtyOnResize() && System.currentTimeMillis() - lastResizeTime < 100 && (w >= width - 1 || h >= height - 1)) return;
314         screenDirtyRegions.dirty(x, y, w, h);
315         Refresh();
316     }
317
318
319     // Private Instance Data /////////////////////////////////////////////////////////////////////////////////////////////
320
321     /** The automatic double buffer for the root box */
322     DoubleBuffer backbuffer = null;
323
324     /** Dirty regions on the backbuffer which need to be rebuilt using Box.render() */
325     private DirtyList backbufferDirtyRegions = new DirtyList();
326
327     /** Dirty regions on the screen which need to be rebuilt using Surface.blit() */
328     private DirtyList screenDirtyRegions = new DirtyList();
329
330     /** A list of all the Boxes on this Surface that should be notified of keyboard events */
331     Vec keywatchers = new Vec();
332
333     /** When set to true, render() should abort as soon as possible and restart the rendering process */
334     volatile boolean abort = false;
335
336     /** a solid red 10x10 double buffer */
337     private DoubleBuffer showRenderBuf = null;
338
339     /** a striped 100x100 double buffer */
340     private DoubleBuffer showRenderBuf2 = null;
341
342     /** true iff this window should be scarred */
343     private boolean scarred = true;
344
345
346     // Other Methods ///////////////////////////////////////////////////////////////////////////////
347
348     /** If <tt>b == true</tt>, maximize the surface; otherwise, un-maximize it. */
349     public final void setMaximized(boolean b) {
350         if (b == maximized) return;
351         _setMaximized(b);
352         maximized = b;
353     }
354
355     /** If <tt>b == true</tt>, minimize the surface; otherwise, un-minimize it. */
356     public final void setMinimized(boolean b) {
357         if (b == minimized) return;
358         _setMinimized(b);
359         minimized = b;
360     }
361
362     /** wrapper for setSize() which makes sure to dirty the place where the scar used to be */
363     void _setSize(int width, int height) {
364         if (scarred) {
365             width = Math.max(width, scarPicture.getWidth());
366             height = Math.max(height, scarPicture.getHeight());
367             dirty(hscar,
368                   root.size(1) - vscar - scarPicture.getHeight(),
369                   scarPicture.getWidth(), scarPicture.getHeight());
370         }
371         setSize(width, height);
372         this.width = width;
373         this.height = height;
374     }
375
376     /** Indicates that the Surface is no longer needed */
377     public final void dispose() {
378         if (root == null) return;
379         if (Log.on) Log.log(this, "disposing " + this);
380         allSurfaces.removeElement(this);
381         _dispose();
382
383         // quit when all windows are closed
384         if (allSurfaces.size() == 0) {
385             if (Log.on) {
386                 if (refreshableSurfaceWasCreated) Log.log(this, "exiting because last remaining surface was disposed");
387                 else Log.log(this, "exiting because no surface was ever created");
388             }
389             Platform.exit();
390         }
391     }
392
393     /** Indicates that the backbuffer region x,y,w,h is no longer correct and must be regenerated */
394     public void dirty(int x, int y, int w, int h) {
395         backbufferDirtyRegions.dirty(x, y, w, h);
396         Refresh();
397     }
398
399     public Surface(Box root) {
400         this.scarred = scarAllSurfacesFromNowOn;
401         scarAllSurfacesFromNowOn = true;
402         this.root = root;
403         if (root.surface != null && root.surface.root == root) root.surface.dispose();
404         root.remove();
405         root.setSurface(this);
406
407         // make sure the root is properly sized
408         while (root.needs_prerender || abort) {
409             abort = false;
410             root.prerender();
411         }
412
413         // this is a bit dangerous since we're passing ourselves to another method before subclasses' ctors have run...        
414         backbuffer = Platform.createDoubleBuffer(Platform.getScreenWidth(), Platform.getScreenHeight(), this);
415
416         root.mark_for_prerender();
417         root.dirty();
418         Refresh();
419     }
420
421     /** runs the prerender() and render() pipelines in the root Box to regenerate the backbuffer, then blits it to the screen */
422     public synchronized void render() {
423
424         // if the window size changed as a result of a user action, we have to update the root box's size
425         if (root.size(0) != width || root.size(1) != height) {
426
427             // since the scar will be moving, dirty the place it used to be
428             if (scarred) dirty(hscar,
429                                root.size(1) - vscar - scarPicture.getHeight(),
430                                scarPicture.getWidth(), scarPicture.getHeight());
431
432             // sort of ugly; we can't use set() here because it will cause an infinite mutual recursion
433             root._size_0 = (short)width;
434             root._size_1 = (short)height;
435
436             root.mark_for_prerender();
437             root.put("SizeChange", null, Boolean.TRUE);
438         }
439
440         while (root.needs_prerender || abort) {
441             abort = false;
442             root.prerender();
443
444             // update mouseinside and trigger Enter/Leave as a result of box size/position changes
445             String oldcursor = cursor;
446             cursor = "default";
447             root.Move(mousex, mousey, mousex, mousey);
448             if (!cursor.equals(oldcursor)) syncCursor();
449         }
450
451         if (centerSurfaceOnRender) {
452             centerSurfaceOnRender = false;
453             int x = (Platform.getScreenWidth() - width) / 2;
454             int y = (Platform.getScreenHeight() - height) / 2;
455             setLocation(x, y);
456             root.set(Box.abs, 0, x);
457             root.set(Box.abs, 1, y);
458         }
459
460         sizePosChangesSinceLastRender = 0;
461         int[][] dirt = backbufferDirtyRegions.flush();
462         for(int i = 0; dirt != null && i < dirt.length; i++) {
463             if (dirt[i] == null) continue;
464             int x = dirt[i][0];
465             int y = dirt[i][1];
466             int w = dirt[i][2];
467             int h = dirt[i][3];
468             if (x < 0) x = 0;
469             if (y < 0) y = 0;
470             if (x+w > width) w = width - x;
471             if (y+h > height) h = height - y;
472             if (w <= 0 || h <= 0) continue;
473
474             root.render(x, y, w, h, backbuffer);
475             
476             // if any area under the scar was repainted, rescar that area
477             if (scarred && x < hscar + scarPicture.getWidth() &&
478                 y + h > height - scarPicture.getHeight() - vscar) {
479                 int _x1 = Math.max(x, hscar);
480                 int _x2 = Math.min(x + w, hscar + scarPicture.getWidth());
481                 int _y1 = Math.max(y, height - scarPicture.getHeight() - vscar);
482                 int _y2 = Math.min(y + h, height - vscar);
483                 
484                 backbuffer.drawPicture(scarPicture, _x1, _y1, _x2, _y2,
485                                        _x1 - (hscar),
486                                        _y1 - (height - scarPicture.getHeight() - vscar),
487                                        _x2 - (hscar),
488                                        _y2 - (height - scarPicture.getHeight() - vscar)
489                                        );
490             }
491
492             if (abort) {
493
494                 // x,y,w,h is only partially reconstructed, so we must be careful not to re-blit it
495                 blitDirtyScreenRegions(x, y, w, h);
496                 screenDirtyRegions.dirty(x, y, w, h);
497
498                 // put back all the dirty regions we haven't yet processed (including the current one)
499                 for(int j=i; j<dirt.length; j++)
500                     if (dirt[j] != null)
501                         backbufferDirtyRegions.dirty(dirt[j][0], dirt[j][1], dirt[j][2], dirt[j][3]);
502
503                 // tail-recurse
504                 render();
505                 return;
506             }
507
508             // now that we've reconstructed this region in the backbuffer, queue it to be reblitted
509             screenDirtyRegions.dirty(x, y, w, h);
510         }
511
512         // blit out all the areas we've just reconstructed
513         blitDirtyScreenRegions();
514     }
515
516     /** blits from the backbuffer to the screen for all regions of the screen which have become dirty */
517     public synchronized void blitDirtyScreenRegions() { blitDirtyScreenRegions(-1, -1, 0, 0); }
518
519     /** same as blitDirtyScreenRegions(), except that it will skip any regions within a,b,c,d */
520     private synchronized void blitDirtyScreenRegions(int a, int b, int c, int d) {
521
522         int[][] dirt = screenDirtyRegions.flush();
523         if (Main.showRenders && dirt != null && dirt.length > 0 && a == -1)
524             blit(backbuffer, 0, 0, 0, 0, width, height);
525
526         for(int i = 0; dirt != null && i < dirt.length; i++) {
527             if (dirt[i] == null) continue;
528             int x = dirt[i][0];
529             int y = dirt[i][1];
530             int w = dirt[i][2];
531             int h = dirt[i][3];
532             if (x < 0) x = 0;
533             if (y < 0) y = 0;
534             if (x+w > root.size(0)) w = root.size(0) - x;
535             if (y+h > root.size(1)) h = root.size(1) - y;
536             if (w <= 0 || h <= 0) continue;
537
538             // if any part of this region falls within the "bad region", just skip it
539             boolean hhit = (x >= a && x <= a + c) || (x+w >= a && x+w <= a + c);
540             boolean vhit = (y >= b && y <= b + d) || (y+h >= b && y+h <= b + d);
541             if (hhit && vhit) {
542                 screenDirtyRegions.dirty(x, y, w, h);
543                 continue;
544             }
545
546             blit(backbuffer, x, y, x, y, w + x, h + y);
547             
548             if (Main.showRenders) {
549                 if (showRenderBuf == null) {
550                     showRenderBuf = Platform.createDoubleBuffer(10, 10, this);
551                     showRenderBuf.fillRect(0, 0, 10, 10, 0x00FF0000);
552                     showRenderBuf2 = Platform.createDoubleBuffer(100, 100, this);
553                     for(int y1 = 0; y1<100; y1++)
554                         for(int x1 = 0; x1<100; x1++)
555                             if ((x1 + y1) % 5 == 0)
556                                 showRenderBuf2.fillRect(x1, y1, x1 + 1, y1 + 1, 0x00FF0000);
557                 }
558                 for(int x1 = x; x1<x + w; x1 += 100)
559                     for(int y1 = y; y1< y + h; y1 += 100) {
560                         blit(showRenderBuf2, 0, 0, x1, y1, Math.min(x1 + 100, x + w), Math.min(y1 + 100, y + h));
561                     }
562                 for(int j=x; j<x + w; j += 10) {
563                     blit(showRenderBuf, 0, 0, j, y, Math.min(j+ 10, x + w), y + 1);
564                     blit(showRenderBuf, 0, 0, j, y + h, Math.min(j + 10, x + w), y + h + 1);
565                 }
566                 for(int j=y; j<y + h; j += 10) {
567                     blit(showRenderBuf, 0, 0, x, j, x + 1, Math.min(j + 10, y + h));
568                     blit(showRenderBuf, 0, 0, x + w, j, x + w + 1, Math.min(j + 10, y + h));
569                 }
570             }
571
572         }
573     }
574
575     // FEATURE: reinstate recycler
576     public class SimpleMessage implements Message {
577         
578         private Box boxContainingMouse;
579         private Object value;
580         public String name;
581         
582         SimpleMessage(String name, Object value, Box boxContainingMouse) {
583             this.boxContainingMouse = boxContainingMouse;
584             this.name = name;
585             this.value = value;
586             MessageQueue.add(this);
587         }
588         
589         public void perform() {
590             Surface.this.boxContainingMouse = this.boxContainingMouse;
591             root.put(name, root, value);
592         }
593
594         public String toString() {
595             return "SimpleMessage [name=" + name + ", value=" + value + "]";
596         }
597         
598     }
599
600     // Scar-Related Stuff ////////////////////////////////////////////////////////////////////
601
602     /** The scar's horizontal offset */
603     int hscar = 0;
604
605     /** The scar's vertical offset */
606     int vscar = 0;
607
608     /** the scar image drawn on the bottom right hand corner */
609     static Picture scarPicture = null;
610
611 }