home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 25 / IOPROG_25.ISO / SOFT / JavaS / javastar-eval.exe / data1.cab / Program_Files / examples / namedb / gjt / Orientation.java < prev    next >
Encoding:
Java Source  |  1999-02-11  |  3.2 KB  |  88 lines

  1. package gjt;
  2.  
  3. /**
  4.  * Constants for orientations (and alignments).<p>
  5.  *
  6.  * This class may not be instantiated.
  7.  *
  8.  * @version 1.0, Apr 11 1996
  9.  * @author  David Geary
  10.  */
  11. public class Orientation {
  12.     public static final Orientation BAD    = new Orientation();
  13.     public static final Orientation NORTH  = new Orientation();
  14.     public static final Orientation SOUTH  = new Orientation();
  15.     public static final Orientation EAST   = new Orientation();
  16.     public static final Orientation WEST   = new Orientation();
  17.     public static final Orientation CENTER = new Orientation();
  18.     public static final Orientation TOP    = new Orientation();
  19.     public static final Orientation LEFT   = new Orientation();
  20.     public static final Orientation RIGHT  = new Orientation();
  21.     public static final Orientation BOTTOM = new Orientation();
  22.  
  23.     public static final Orientation HORIZONTAL = 
  24.         new Orientation();
  25.     public static final Orientation VERTICAL   = 
  26.         new Orientation();
  27.  
  28.     static public Orientation fromString(String s) {
  29.         Orientation o = BAD;
  30.  
  31.         if(s.equals("NORTH") || s.equals("north"))    o = NORTH;
  32.         else if(s.equals("SOUTH") || s.equals("south"))    
  33.             o = SOUTH;
  34.         else if(s.equals("EAST")  || s.equals("east"))     
  35.             o = EAST;
  36.         else if(s.equals("WEST")  || s.equals("west"))     
  37.             o = WEST;
  38.         else if(s.equals("CENTER") || s.equals("center"))   
  39.             o = CENTER;
  40.         else if(s.equals("TOP")   || s.equals("top"))      
  41.             o = TOP;
  42.         else if(s.equals("LEFT")  || s.equals("left"))     
  43.             o = LEFT;
  44.         else if(s.equals("RIGHT")  || s.equals("right"))    
  45.             o = RIGHT;
  46.         else if(s.equals("BOTTOM") || s.equals("bottom"))   
  47.             o = BOTTOM;
  48.         else if(s.equals("VERTICAL") || s.equals("vertical")) 
  49.             o = VERTICAL;
  50.         else if(s.equals("HORIZONTAL") || 
  51.                 s.equals("horizontal"))
  52.           o = HORIZONTAL;
  53.  
  54.         return o;
  55.     }
  56.     public String toString() {
  57.         String s = new String();
  58.  
  59.         if(this == Orientation.NORTH) 
  60.             s = getClass().getName() + "=NORTH";
  61.         else if(this == Orientation.SOUTH)
  62.             s = getClass().getName() + "=SOUTH";
  63.         else if(this == Orientation.EAST)
  64.             s = getClass().getName() + "=EAST";
  65.         else if(this == Orientation.WEST)
  66.             s = getClass().getName() + "=WEST";
  67.         else if(this == Orientation.CENTER)
  68.             s = getClass().getName() + "=CENTER";
  69.         else if(this == Orientation.TOP)
  70.             s = getClass().getName() + "=TOP";
  71.         else if(this == Orientation.LEFT)
  72.             s = getClass().getName() + "=LEFT";
  73.         else if(this == Orientation.RIGHT)
  74.             s = getClass().getName() + "=RIGHT";
  75.         else if(this == Orientation.BOTTOM)
  76.             s = getClass().getName() + "=BOTTOM";
  77.         else if(this == Orientation.HORIZONTAL)
  78.             s = getClass().getName() + "=HORIZONTAL";
  79.         else if(this == Orientation.VERTICAL)
  80.             s = getClass().getName() + "=VERTICAL";
  81.         else if(this == Orientation.BAD)
  82.             s = getClass().getName() + "=BAD";
  83.  
  84.         return s;
  85.     }
  86.     private Orientation() { }  // Defeat instantiation
  87. }
  88.