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

  1. // OrientPanel.java
  2. // 16.03.96
  3. //
  4. // the orientation screen
  5.  
  6. package cybcerone.orient;
  7.  
  8. import java.util.Vector;
  9. import java.awt.Color;
  10.  
  11. import cybcerone.utils.Appletlike;
  12. import cybcerone.utils.SuperPanel;
  13. import cybcerone.utils.Mapable;
  14. import cybcerone.utils.MapInfoPanel;
  15.  
  16. /**
  17.  * The mapping module.
  18.  */
  19. public class OrientPanel extends SuperPanel {
  20.   public static final String id = "orient";
  21.   public static final String imagePath = "orientation/";
  22.   public static final String dataPath = "orientation/";
  23.  
  24.   private static final String statusText = "";
  25.   private static final String bgFile = imagePath + "fond_preorientation.gif";
  26.   private static final String dataFile = dataPath + "liste";
  27.  
  28.   private static OrientMap theMap;
  29.   private static OrientZoom theZoom;
  30.   private static OrientLegend theLegend;
  31.   private static OrientPhotos thePhotos;
  32.   private static OrientDesc theDesc;
  33.   private static MapInfoPanel theInfo;
  34.   
  35.   private Maplikes theMaps;
  36.   private static final String defaultMap = "BFSH2_2";
  37.   private static final String errorMap = "RGL";
  38.  
  39.   public OrientPanel (Appletlike app) {
  40.     super (id, statusText, app);
  41.     setBackground (Color.black);
  42.  
  43.     add (new OrientIcon (this));
  44.     add (theMap = new OrientMap (this));
  45.     add (theZoom = new OrientZoom (this));
  46.     add (theLegend = new OrientLegend (this));
  47.     add (thePhotos = new OrientPhotos (this));
  48.     add (theDesc = new OrientDesc (this));
  49.  
  50.     getData (dataFile, new NodeMap (this, imagePath), this);
  51.   }
  52.  
  53.   public void update (Object updateVal) {
  54.     if (updateVal instanceof Maplike) {
  55.       update ((Maplike)updateVal);
  56.     } if (updateVal instanceof Zone) {
  57.       update ((Zone)updateVal);
  58.     } else
  59.       super.update (updateVal);
  60.   }
  61.  
  62.   /** Done loading */
  63.   public void update (Vector theMaps) {
  64.     this.theMaps = new Maplikes (theMaps);
  65.     theMap.setMaps (this.theMaps);
  66.     reset ();
  67.   }
  68.  
  69.   public void reset () {
  70.     update (defaultMap);
  71.   }
  72.  
  73.   public void update (String newMapName) {
  74.     if (theMaps != null) {
  75.       Maplike newMap = theMaps.findMap (newMapName);
  76.       if (newMap == null)
  77.     newMap = theMaps.findMap (errorMap);
  78.       update (newMap);
  79.     }
  80.   }
  81.  
  82.   public void update (Maplike newMap) {
  83.     theMap.update (newMap);
  84.     theZoom.update (newMap);
  85.     theLegend.update (newMap);
  86.     thePhotos.update (newMap);
  87.     theDesc.update (newMap);
  88.   }
  89.  
  90.   /* find the map containing this zone, update with that and then
  91.    * highlight this zone */
  92.   public void update (Zone newZone) {
  93.     Maplike oldMap = theMaps.findMap (newZone.getName ());
  94.     update (oldMap.getParent ());
  95.     theMap.update (newZone);
  96.   }
  97.  
  98.   public void update (Mapable selected) {
  99.     if (theInfo != null)
  100.       remove (theInfo);
  101.     if (theMaps != null) {
  102.       Maplike newMap = theMaps.findMap (selected.getMapName ());
  103.       if (newMap == null)
  104.     newMap = theMaps.findMap (errorMap);
  105.       update (newMap);
  106.       add (theInfo = selected.getMapInfoPanel (this));
  107.       if (selected.getZoneName () != null)
  108.     theMap.update (newMap.find (selected.getZoneName ()));
  109.     }
  110.   }
  111. }
  112.