home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 2.0 KB | 81 lines |
- // Unite.java
- // 18.03.96
- //
- // a room in a building
-
- package cybcerone.utils;
-
- import java.awt.Graphics;
- import java.awt.image.ImageObserver;
- import java.io.DataInputStream;
- import java.io.IOException;
-
- /**
- * A room in the main building, though it's flexible enough
- * to be a room in any building.
- */
- public class Unite implements Paintable, Literate, Mapable {
- private String name;
- private String buildingName;
- private String levelName;
- private String zoneName;
-
- private static final int xOffset = Scaler.scale (15);
-
- public Unite (String name, String building, String level, String zone) {
- this.name = name;
- this.buildingName = building;
- this.levelName = level;
- this.zoneName = zone;
- }
-
- /** for reading */
- public Unite () {
- }
-
- public String getName () { return name; }
- public String getBuildingName () { return buildingName; }
- public String getLevelName () { return levelName; }
- public String getZoneName () { return zoneName; }
-
- public String toString () {
- return ("Unite[" + name + ", " + buildingName + ", "
- + levelName + ", " + zoneName + "]");
- }
-
- public void paint (Graphics g, int x, int y, ImageObserver observer) {
- g.drawString (name, x + xOffset, y);
- }
-
- public String getMapName () {
- return (buildingName + "_" + levelName);
- }
-
- public MapInfoPanel getMapInfoPanel (Appletlike app) {
- UniteInfoPanel thePanel = new UniteInfoPanel (app);
- thePanel.setData (this);
- return thePanel;
- }
-
- /** Right now this assumes all rooms are in BFSH2 */
- synchronized public Object read (DataInputStream inStream)
- throws IOException {
-
- String line = inStream.readLine ();
-
- if (line == null) return null;
-
- int endOfName = line.indexOf (" ");
- int endOfLevel = line.indexOf (" ", endOfName + 1);
-
- name = line.substring (0, endOfName);
- buildingName = "BFSH2";
- levelName = line.substring (endOfName + 1, endOfLevel);
- zoneName = line.substring (endOfLevel + 1);
-
- return new Unite (name, buildingName, levelName, zoneName);
- }
-
- }
-
-