home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 3.7 KB | 149 lines |
- // MainPanel.java
- // 27.02.96
- //
- // the main screen
-
- package cybcerone.main;
-
- import java.awt.Image;
- import java.awt.Event;
- import java.util.Vector;
-
-
- import cybcerone.credit.CreditPanel;
- import cybcerone.utils.SuperPanel;
- import cybcerone.utils.Appletlike;
- import cybcerone.utils.ManifVector;
- import cybcerone.utils.Manif;
- import cybcerone.utils.Date;
- import cybcerone.utils.Buttons;
- import cybcerone.utils.Button;
-
- import cybcerone.person.PersonPanel;
- import cybcerone.orient.PreorientPanel;
- import cybcerone.faculte.FacultePanel;
- import cybcerone.manif.ManifPanel;
-
- /**
- * The main screen.
- */
- public class MainPanel extends SuperPanel implements Runnable {
- public static final String id = "main";
- public static final String imagePath = "pdg/";
-
- private static final String statusText = "Welcome to Cybcerone";
- private static final String bgFile = imagePath + "fond_pdg.gif";
-
- private static final String eventFile = "events/live.events";
- private static final String ledsOnFile = imagePath + "leds2_on.gif";
- private static final String ledsOffFile = imagePath + "leds2_off.gif";
-
- private TsolPanel tsol;
- private NowPanel now;
- private TodayPanel today;
-
- Thread updater;
-
- private Buttons theButtons;
-
- public MainPanel (Appletlike app) {
- super (id, statusText, app);
- setBackground (bgFile, 1);
- setNext (CreditPanel.id);
-
- Image ledsOn = getImage (ledsOnFile, 2);
- Image ledsOff = getImage (ledsOffFile, 2);
-
- /*
- add (new PersonButton (this));
- add (new FaculteButton (this));
- add (new OrientButton (this));
- add (new ManifButton (this));
- */
-
- theButtons = new Buttons ();
- theButtons.addButton
- (new Button (PersonPanel.id, "Directory of the University staff",
- 0, 0, 217, 211));
- theButtons.addButton
- (new Button (PreorientPanel.id, "Maps and orientation",
- 806, 0, 217, 211));
- theButtons.addButton
- (new Button (FacultePanel.id,
- "Organizational chart of faculties and services",
- 806, 213, 217, 206));
- theButtons.addButton
- (new Button (ManifPanel.id, "Calendar of events", 0, 213, 217, 206));
-
- add (tsol = new TsolPanel (this));
- add (now = new NowPanel (ledsOn, ledsOff, this));
- add (today = new TodayPanel (ledsOn, this));
-
- getData (eventFile, new Manif (), this);
- }
-
- public void update (Vector theData) {
- Object first = theData.firstElement ();
-
- update (new ManifVector (theData));
- }
-
- public void update (ManifVector events) {
- now.update (events);
- today.update (events);
- }
-
- public void start () {
- super.start ();
- if (updater == null) {
- updater = new Thread (this);
- updater.start ();
- }
- }
-
- public void stop () {
- super.stop ();
- if (updater != null)
- updater.stop ();
- updater = null;
- }
-
- /** Sleep until tomorrow, then reload the event file */
- public void run () {
- while (updater != null) {
- Date today = new Date ();
- Date tomorrow = new Date (today.getYear (), today.getMonth (),
- today.getDate () + 1);
- try {
- updater.sleep (tomorrow.getTime () - today.getTime ());
- } catch (InterruptedException e) {
- }
-
- getData (eventFile, new Manif (), this);
- }
- }
-
- public boolean mouseMove (Event evt, int x, int y) {
- Button theButton = theButtons.which (x, y);
-
- if (theButton != null)
- app.showStatus (theButton.getStatusText ());
- else if (locate (x, y) == null)
- app.showStatus (statusText);
- return true;
- }
-
- public boolean mouseDown (Event evt, int x, int y) {
- Button theButton = theButtons.which (x, y);
-
- if (theButton != null) {
- app.update (theButton.getNext ());
- return true;
- } else
- return super.mouseDown (evt, x, y);
- }
- }
-
-
-
-