home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / java / unuy2wen / cybcerone / utils / superpanel.java < prev    next >
Encoding:
Java Source  |  1996-08-14  |  3.3 KB  |  126 lines

  1. // SuperPanel.java
  2. // 27.02.96
  3. //
  4. // these are the big panels in which other, smaller panels are embedded
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.awt.Event;
  9. import java.awt.Image;
  10. import java.awt.Rectangle;
  11. import java.util.Vector;
  12.  
  13. /**
  14.  * This is an extension of IdPanel that is also sort of Appletlike.  It
  15.  * can read images and data, and be updated.  Automatically takes up the
  16.  * full upper portion of the screen (1024 x 668 before scaling).
  17.  */
  18. public class SuperPanel extends IdPanel implements Appletlike {
  19.   private static final Rectangle placement = new Rectangle (0, 0, 1024, 668);
  20.  
  21.   /** Make it so. */
  22.   public SuperPanel (String id, String statusText, Appletlike app) {
  23.     super (id, statusText, app);
  24.     this.app = app;
  25.     reshape (placement);
  26.   }
  27.  
  28.   /**
  29.    * Update the panel with this Object.  This method just calls a few other,
  30.    * more private methods.  It should be overridden in the subclasses to
  31.    * handle any special data types.
  32.    */
  33.   public void update (Object updateVal) {
  34.     if (updateVal instanceof String)
  35.       update ((String)updateVal);
  36.     else if (updateVal instanceof Vector)
  37.       update ((Vector)updateVal);
  38.     else if (updateVal instanceof Mapable)
  39.       update ((Mapable)updateVal);
  40.   }
  41.   
  42.   /**
  43.    * If you're updated with a String, that must be the id of the
  44.    * panel to switch to.  Don't forget to override this is that's not
  45.    * the case.
  46.    */
  47.   protected void update (String nextId) {
  48.     app.update (nextId);
  49.   }
  50.  
  51.   /**
  52.    * If you're updated with a Vector, well, we don't know what to do yet.
  53.    * Just print a message for now and override in the subclasses.
  54.    */
  55.   protected void update (Vector data) {
  56. //    System.err.println ("SuperPanel: update called with " + data);
  57.   }
  58.  
  59.   /**
  60.    * We've been updated with a mapable object, let the applet
  61.    * handle this.
  62.    */
  63.   protected void update (Mapable selected) {
  64.     app.update (selected);
  65.   }
  66.   
  67.   /**
  68.    * Put that String on the status line, baby.
  69.    */
  70.   public void showStatus (String newStatus) {
  71.     app.showStatus (newStatus);
  72.   }
  73.  
  74.   /**
  75.    * Go get me this image.
  76.    */
  77.   public Image getImage (String imageFileName) {
  78.     return app.getImage (imageFileName);
  79.   }
  80.  
  81.   /**
  82.    * Go get me this image.  I have this priority.
  83.    */
  84.   public Image getImage (String imageFileName, int priority) {
  85.     return app.getImage (imageFileName, priority);
  86.   }
  87.  
  88.   /**
  89.    * Load the file at this filename.  The actual reading will be handled
  90.    * by this Literate object.  When it's done, notify this Appletlike object
  91.    * through his update method.
  92.    */
  93.   public void getData (String filename, Literate reader,
  94.                Appletlike requester) {
  95.     app.getData (filename, reader, requester);
  96.   }
  97.  
  98.   /** 
  99.    * Same as above, but returns of Vector of Strings since there is no reader.
  100.    */
  101.   public void getData (String filename, Appletlike requester) {
  102.     app.getData (filename, requester);
  103.   }
  104.  
  105.   /** Change what the cursor looks like. */
  106.   public void setCursor (int cursorType) {
  107.     app.setCursor (cursorType);
  108.   }
  109.  
  110.   /**
  111.    * Override this in subclasses so that they can put themselves back
  112.    * into their initial state.
  113.    */
  114.   public void reset () {
  115. //    System.err.println ("SuperPanel: reset called on " + getId ());
  116.   }
  117.  
  118.   /**
  119.    * Write this message on the initialization log.
  120.    */
  121.   public void initMessage (String message) {
  122.     app.initMessage (message);
  123.   }
  124. }
  125.  
  126.