home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 7.9 KB | 297 lines |
- // Manif.java
- // 13.03.96
- //
- // all the info to represent one event (manifestation)
-
- package cybcerone.utils;
-
- import java.util.Vector;
- import java.awt.Graphics;
- import java.awt.image.ImageObserver;
- import java.io.DataInputStream;
- import java.io.IOException;
-
- /**
- * One of the base objects, an event (Manifestation in French)
- */
- public class Manif implements Literate, Paintable, Mapable {
-
- String eventType; // ET
- String title; // TE
- String batiment; // BA
- String day; // JD
- String month; // MD
- String year; // AD
- String faculte; // FJ
- String champBatiment; // CB
- String noSalle; // NS
- String hour; // TH
- String minute; // TM
- String personTitle; // TP
- String personName; // NA
- String personTitleSup; // TS
- String rattache; // RA
- String instit; // IN
- String champInstit; // CI
- String contactName; // NC
- String telephone; // TL
- String fax; // FX
- String email; // EM
- String delai; // DL
- String finance; // FI
- String plusieursJours; // PJ
- String endDay; // JF
- String endMonth; // MF
- String endYear; // AF
- String groupTitle; // TG
- String groupFilename; // GF
- String manifType; // MT
- String soustit; // ST
- String comments = ""; // CM
-
- private String shortTitle;
- private Date startDate;
- private Date time;
-
- private static final int xOffset = Scaler.scale (15);
-
- /** for reading */
- public Manif () {
- }
-
- public Manif (DataInputStream inStream) throws IOException {
- String line = inStream.readLine ();
-
- while (line != null && !line.startsWith ("===")) {
- decode (line);
- line = inStream.readLine ();
- }
-
- if (title != null) {
- makeShortTitle ();
- startDate = new Date (Integer.parseInt (year) - 1900,
- Integer.parseInt (month) - 1,
- Integer.parseInt (day));
-
- if (hour == null || minute == null)
- time = null;
- else
- time = new Date (Integer.parseInt (year) - 1900,
- Integer.parseInt (month) - 1,
- Integer.parseInt (day),
- Integer.parseInt (hour),
- Integer.parseInt (minute));
-
- }
-
- }
-
- private void decode (String line) {
- String field = "";
- String value = "";
-
-
- if (line.length () > 2) field = line.substring (0, 3);
- if (line.length () > 3) value = line.substring (4);
-
- if (field.equals ("ET:")) eventType = value;
- else if (field.equals ("TE:")) title = value;
- else if (field.equals ("BA:")) batiment = value;
- else if (field.equals ("JD:")) day = value;
- else if (field.equals ("MD:")) month = value;
- else if (field.equals ("AD:")) year = value;
- else if (field.equals ("FJ:")) faculte = value;
- else if (field.equals ("CB:")) champBatiment = value;
- else if (field.equals ("NS:")) noSalle = value;
- else if (field.equals ("TH:")) hour = value;
- else if (field.equals ("TM:")) minute = value;
- else if (field.equals ("TP:")) personTitle = value;
- else if (field.equals ("NA:")) personName = value;
- else if (field.equals ("TS:")) personTitleSup = value;
- else if (field.equals ("RA:")) rattache = value;
- else if (field.equals ("IN:")) instit = value;
- else if (field.equals ("CI:")) champInstit = value;
- else if (field.equals ("NC:")) contactName = value;
- else if (field.equals ("TL:")) telephone = value;
- else if (field.equals ("FX:")) fax = value;
- else if (field.equals ("EM:")) email = value;
- else if (field.equals ("DL:")) delai = value;
- else if (field.equals ("FI:")) finance = value;
- else if (field.equals ("PJ:")) plusieursJours = value;
- else if (field.equals ("JF:")) endDay = value;
- else if (field.equals ("MF:")) endMonth = value;
- else if (field.equals ("AF:")) endYear = value;
- else if (field.equals ("TG:")) groupTitle = value;
- else if (field.equals ("GF:")) groupFilename = value;
- else if (field.equals ("MT:")) {
- manifType = value;
- } else if (field.equals ("ST:")) {
- soustit = value;
- } else if (field.equals ("CM:")) comments += value;
- else if (line.length() > 0) {
- if (comments.length () > 0)
- comments += " ";
- comments += line;
- }
- }
-
- public Object read (DataInputStream inStream) throws IOException {
- Manif theManif = new Manif (inStream);
-
- if (theManif.title == null)
- return null;
- else
- return (theManif);
- }
-
- public void paint (Graphics g, int x, int y, ImageObserver observer) {
- g.drawString (shortTitle, x + xOffset, y);
- }
-
- private void makeShortTitle () {
- if (title.length () > 68)
- shortTitle = title.substring (0, 66) + "...";
- else
- shortTitle = title;
- }
-
- public String toString () {
- return ("Manif[" + shortTitle + ", " + time + ", " + faculte +
- ", " + batiment + "]");
- }
-
- /**
- * Returns true if this event takes place between these two
- * dates (inclusive on begin, exclusive on end).
- */
- public boolean between (Date begin, Date end) {
- return (sameDay (begin) ||
- (startDate.after (begin) && startDate.before (end)));
- }
-
- /** Returns true if this event takes place after this date (exclusive) */
- public boolean after (Date when) {
- return (startDate.after (when));
- }
-
- /** Returns true if this event takes place or or after this date */
- public boolean onOrAfter (Date when) {
- return (sameDay (when) || startDate.after (when));
- }
-
- /** Returns true if this event takes place on the given day */
- public boolean sameDay (Date when) {
- return (startDate.getDate () == when.getDate () &&
- startDate.getMonth () == when.getMonth () &&
- startDate.getYear () == when.getYear ());
- }
-
- public String getFaculte () { return faculte; }
- public Date getStartDate () { return startDate; }
-
- public String getMapName () {
- if (batiment.equals ("BFSH2")) {
- if (noSalle != null && Character.isDigit (noSalle.charAt (0)))
- return (batiment + "_" + noSalle.charAt (0));
- else
- return (batiment + "_2");
- } else
- return batiment;
- }
-
- public String getZoneName () {
- return null;
- }
-
- public String getTitle () {
- return title;
- }
-
- public String getGroupTitle () {
- return groupTitle;
- }
-
- public String getTime () {
- if (hour != null && minute != null)
- return (hour + "h" + minute);
- else
- return null;
- }
-
- public String getPerson () {
- String retVal = "";
-
- if (personName != null) {
- if (personTitle != null && !personTitle.equals ("AUC")) {
- if (personTitle.equals ("DR")) retVal += "Dr. ";
- else if (personTitle.equals ("PRF")) retVal += "Prof. ";
- }
- retVal += personName;
- if (personTitleSup != null)
- retVal += ", " + personTitleSup;
-
- return retVal;
- } else
- return null;
- }
-
- public String getWhere () {
- String retVal = "";
-
- if (batiment != null && !batiment.equals ("Z"))
- retVal += batiment;
- if (champBatiment != null) {
- if (retVal.length () > 0)
- retVal += " ";
- retVal += champBatiment;
- }
- if (noSalle != null) {
- if (retVal.length () > 0)
- retVal += " ";
- retVal += noSalle;
- }
- if (telephone != null) {
- if (retVal.length () > 0)
- retVal += ", ";
- retVal += "tel " + telephone;
- }
-
- if (retVal.length () > 0)
- return retVal;
- else
- return null;
- }
-
- public String getDate () {
- return (startDate.getDate () + "/" +
- (startDate.getMonth () + 1) + "/" +
- startDate.getYear ());
- }
-
- public String getComments () {
- String retVal = "";
-
- if (soustit != null)
- retVal += soustit;
- if (comments.length () > 0) {
- if (retVal.length () > 0)
- retVal += ", ";
- retVal += comments;
- }
-
- return retVal;
- }
-
- public MapInfoPanel getMapInfoPanel (Appletlike app) {
- ManifInfoPanel thePanel = new ManifInfoPanel (app);
- thePanel.setData (this);
- return thePanel;
- }
-
- public String getRattache () {
- return rattache;
- }
-
- public Date getDateAndTime () { return time; }
- }
-