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

  1. // TodayEventPanel.java
  2. // 24.03.96
  3. //
  4. // a subpanel of the TodayPanel, shows info on the events happening today
  5.  
  6. package cybcerone.main;
  7.  
  8. import java.awt.Image;
  9. import java.awt.Graphics;
  10. import java.awt.FontMetrics;
  11. import java.awt.Rectangle;
  12. import java.awt.Color;
  13.  
  14. import cybcerone.utils.Manif;
  15. import cybcerone.utils.ManifVector;
  16. import cybcerone.utils.VectorScrollingPanel;
  17. import cybcerone.utils.Appletlike;
  18.  
  19. /**
  20.  * Scrolls along at the bottom of the TodayPanel, giving relevant
  21.  * information about the displayed event.
  22.  */
  23. class TodayEventPanel extends VectorScrollingPanel {
  24.   Rectangle placement = new Rectangle (86, 37, 1024-91, 26);
  25.  
  26.   public TodayEventPanel (String id, String statusText, Appletlike app) {
  27.     super (id, statusText, app);
  28.     reshape (placement);
  29.     setSpace (scale (placement.width / 2));
  30.   }
  31.   
  32.   public void update (ManifVector theEvents) {
  33.     setText (theEvents.toVector ());
  34.   }
  35.  
  36.   protected String getInfo (Object elem) {
  37.     if (elem instanceof Manif) {
  38.       return getInfo ((Manif) elem);
  39.     } else
  40.       return null;
  41.   }
  42.  
  43.   private String getInfo (Manif theManif) {
  44.     String faculte = theManif.getFaculte ();
  45.     String person = theManif.getPerson ();
  46.     String where = theManif.getWhere ();
  47.     String comments = theManif.getComments ();
  48.  
  49.     String retVal = "";
  50.     
  51.     if (faculte != null)
  52.       retVal += faculte;
  53.     if (person != null) {
  54.       if (retVal.length () > 0)
  55.     retVal += ", ";
  56.       retVal += person;
  57.     }
  58.     if (where != null) {
  59.       if (retVal.length () > 0)
  60.     retVal += ", ";
  61.       retVal += where;
  62.     }
  63.     if (comments.length () > 0) {
  64.       if (retVal.length () > 0)
  65.     retVal += ", ";
  66.       retVal += comments;
  67.     }
  68.  
  69.     return retVal;
  70.   }
  71.     
  72.  
  73.   protected Object setText () {
  74.     Object theVal = super.setText ();
  75.     if (theVal != null)
  76.       app.update (theVal);
  77.     return theVal;
  78.   }
  79. }
  80.