home *** CD-ROM | disk | FTP | other *** search
/ Late Night VRML 2.0 with Java CD-ROM / code.zip / Ch13 / hash / Figure.java < prev    next >
Text File  |  1996-11-27  |  2KB  |  45 lines

  1. // An AnimationMaster Figure
  2.  
  3. // Written by Bernie Roehl, November 1996
  4.  
  5. package hash;
  6.  
  7. import java.io.*;
  8. import java.util.*;
  9.  
  10. public class Figure {
  11.         protected int version;
  12.         protected int platformType;
  13.         Part root;
  14.  
  15.         public int getVersion() { return version; }
  16.         public int getPlatformType() { return platformType; }
  17.         public Part getRoot() { return root; }
  18.  
  19.         public void dump() {
  20.                 System.out.println("Version " + version);
  21.                 System.out.println("Platform = " + platformType);
  22.                 root.dump("");
  23.         }
  24.  
  25.         public Figure(DataInputStream input)
  26.                 throws IOException, HashSyntaxException {
  27.                 StringTokenizer s;
  28.  
  29.                 s = new StringTokenizer(input.readLine());
  30.                 if (s.countTokens() != 7)
  31.                         throw new HashSyntaxException("missing fields in header line");
  32.                 if (s.nextToken().equals("FIGU") == false)
  33.                         throw new HashSyntaxException("missing signature in first line");
  34.                 version = Integer.parseInt(s.nextToken());
  35.                 s.nextToken();  // skip zero
  36.                 platformType = Integer.parseInt(s.nextToken());
  37.                 input.readLine();   // skip zero line
  38.                 if (version == 6) {
  39.                         input.readLine();
  40.                         input.readLine();
  41.                 }
  42.                 root = new Part(input);
  43.         }
  44. }
  45.