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

  1. // TodayPanel.java
  2. // 21.03.96
  3. //
  4. // events that are happening today
  5.  
  6. package cybcerone.main;
  7.  
  8. import java.awt.Rectangle;
  9. import java.awt.Image;
  10. import java.awt.Graphics;
  11.  
  12. import cybcerone.utils.Date;
  13. import cybcerone.utils.Appletlike;
  14. import cybcerone.utils.Manif;
  15. import cybcerone.utils.TextPanel;
  16. import cybcerone.utils.Fonts;
  17.  
  18. /**
  19.  * Events that are happening today.
  20.  */
  21. class TodayPanel extends HappeningPanel {
  22.   private static final Rectangle placement = new Rectangle (0, 583, 1024, 85);
  23.  
  24.   private static final String id = "TodayPanel";
  25.   private static String statusText = "Today's events";
  26.   private static final String bgFile = imagePath + "fond_aujour.gif";
  27.  
  28.   private Image ledsOn;
  29.   
  30.   private TodayEventPanel infoPanel;
  31.   private TextPanel titlePanel;
  32.   
  33.   public TodayPanel (Image ledsOn, Appletlike app) {
  34.     super (id, statusText, app);
  35.     reshape (placement);
  36.  
  37.     if (!Date.realDate ()) {
  38.       statusText += " (demonstration)";
  39.       setStatusText (statusText);
  40.     }
  41.     
  42.     setBackground (bgFile, 0);
  43.     this.ledsOn = ledsOn;
  44.     
  45.     add (infoPanel = new TodayEventPanel (id, statusText, this));
  46.     infoPanel.setColor (gray);
  47.     infoPanel.setFont (Fonts.smallFont);
  48.  
  49.     add (titlePanel = new TextPanel (id, statusText, app));
  50.     titlePanel.reshape (scale (210), scale (11), scale (809), scale (22));
  51.     titlePanel.setFont (Fonts.smallFont);
  52.     titlePanel.setColor (gray);
  53.     hide ();
  54.   }
  55.  
  56.   public void update (Object updateVal) {
  57.     if (updateVal instanceof Manif)
  58.       update ((Manif)updateVal);
  59.     else
  60.       super.update (updateVal);
  61.   }
  62.   
  63.   protected void update (Manif theEvent) {
  64.     titlePanel.setText (theEvent.getTime () + " " + theEvent.getTitle ());
  65.     titlePanel.setNext (theEvent);
  66.   }
  67.  
  68.   public void update () {
  69.     super.update ();
  70.     infoPanel.update (getTheEvents ());
  71.   }
  72.  
  73.   protected Date pastDate (Date now) {
  74.     return (new Date (now.getYear (), now.getMonth (), now.getDate ()));
  75.   }
  76.   
  77.   protected Date futureDate (Date now) {
  78.     return (new Date (now.getYear (), now.getMonth (), now.getDate () + 1));
  79.   }
  80.  
  81.   public void paint (Graphics g) {
  82.     super.paint (g);
  83.     if (ledsOn != null)
  84.       g.drawImage (ledsOn, 0, scale (37), this);
  85.   }
  86.   
  87. }
  88.