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

  1. // ManifInfoPanel.java
  2. // 17.03.96
  3. //
  4. // a map panel for an event
  5.  
  6. package cybcerone.utils;
  7.  
  8. import java.awt.Image;
  9.  
  10. import cybcerone.orient.OrientPanel;
  11.  
  12. /**
  13.  * The information from an event that gets put on the top of the
  14.  * map screen.
  15.  */
  16. public class ManifInfoPanel extends MapInfoPanel {
  17.   private static final String id = "ManifInfoPanel";
  18.   private static final String statusText = "Selected event";
  19.  
  20.   private static final String imageFile = "pictoInfoManif.gif";
  21.  
  22.   private static ScrollingPanel theTitle;
  23.   private static ScrollingPanel theSubTitle;
  24.   private static ScrollingPanel theTime;
  25.   private static ScrollingPanel thePerson;
  26.   private static ScrollingPanel theComments;
  27.  
  28.   private static final int x = scale (49);
  29.   private static final int y1 = scale (0);
  30.   private static final int y2 = scale (27);
  31.   private static final int y3 = scale (54);
  32.   private static final int y4 = scale (81);
  33.   private static final int y5 = scale (108);
  34.  
  35.  
  36.   public ManifInfoPanel (Appletlike app) {
  37.     super (id, statusText, app);
  38.     
  39.     setBackground (OrientPanel.imagePath + imageFile, 3);
  40.  
  41.     theTitle = newPanel (x, y1);
  42.     theSubTitle = newPanel (x, y2);
  43.     theTime = newPanel (x, y3);
  44.     thePerson = newPanel (x, y4);
  45.     theComments = newPanel (x, y5);
  46.  
  47.     theTime.setColor (gray);
  48.     thePerson.setColor (gray);
  49.     theComments.setColor (gray);
  50.   }
  51.  
  52.   private ScrollingPanel newPanel (int x, int y) {
  53.     ScrollingPanel thePanel = new ScrollingPanel (id, statusText, app);
  54.     add (thePanel);
  55.     thePanel.reshape (x, y, size().width - x, scale (25));
  56.     return thePanel;
  57.   }
  58.  
  59.   public void setData (Manif theManif) {
  60.     theTitle.setText (theManif.getTitle ());
  61.     theSubTitle.setText (theManif.getGroupTitle ());
  62.  
  63.     setTime (theManif);
  64.     setPerson (theManif);
  65.     theComments.setText (theManif.getComments ());
  66.   }
  67.  
  68.   private void setTime (Manif theManif) {
  69.     String date = theManif.getDate ();
  70.     String time = theManif.getTime ();
  71.     String fac = theManif.getFaculte ();
  72.     String where = theManif.getWhere ();
  73.  
  74.     String timeText = "";
  75.  
  76.     if (date != null)
  77.       timeText += "le " + date;
  78.     if (time != null) {
  79.       if (timeText.length () > 0)
  80.     timeText += " ";
  81.       timeText += "α " + time;
  82.     }
  83.     if (fac != null) {
  84.       if (timeText.length () > 0)
  85.     timeText += ", ";
  86.       timeText += fac;
  87.     }
  88.     if (where != null) {
  89.       if (timeText.length () > 0)
  90.     timeText += ", ";
  91.       timeText += where;
  92.     }
  93.     
  94.     theTime.setText (timeText);
  95.   }
  96.  
  97.   private void setPerson (Manif theManif) {
  98.     String person = theManif.getPerson ();
  99.     String rattache = theManif.getRattache ();
  100.  
  101.     String personText = "";
  102.  
  103.     if (person != null)
  104.       personText += person;
  105.     if (rattache != null) {
  106.       if (personText.length () > 0)
  107.     personText += ", ";
  108.       personText += "rattache a " + rattache;
  109.     }
  110.     
  111.     thePerson.setText (personText);
  112.   }
  113.       
  114. }
  115.