Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/pqt/autorib/instr/InstrOption.java


1   //AutoRIB
2   // Copyright © 1998 - 2002, P W Quint
3   //
4   // Contact: autorib00@aol.com
5   //
6   // This library is free software; you can redistribute it and/or
7   // modify it under the terms of the GNU General Public
8   // License as published by the Free Software Foundation; either
9   // version 2 of the License, or (at your option) any later version.
10  //
11  // This library is distributed in the hope that it will be useful,
12  // but WITHOUT ANY WARRANTY; without even the implied warranty of
13  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  // General Public License for more details.
15  //
16  // You should have received a copy of the GNU General Public
17  // License along with this library; if not, write to the Free Software
18  // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  
20  package org.pqt.autorib.instr;
21  import java.io.*;
22  import java.util.*;
23  
24  import org.pqt.autorib.tokenizer.*;
25  import org.pqt.autorib.globals.*;
26  import org.pqt.autorib.util.*;
27  import org.pqt.autorib.rib.*;
28  
29  
30  
31  public class InstrOption extends InstrRequest {
32      public String optionName;
33      public String stringOption = null;
34      public Float numberOption = null;
35      
36      public InstrOption()
37      { }
38      
39      public InstrOption(InstrWReader in) throws IOException, FormatException {
40          read(in);
41      }
42      
43      
44      public void read(InstrWReader in) throws IOException,
45      FormatException {
46          readRequestName(in);
47          optionName = in.tokenizer.getString();
48          if (optionName.equalsIgnoreCase("zdriver")) {
49              stringOption = in.tokenizer.getString();
50              Globals.zdriver = stringOption;
51          }
52          else if (optionName.equalsIgnoreCase("depthfilter")) {
53              stringOption = in.tokenizer.getString();
54              Globals.depthFilter = stringOption;
55          }
56          else if (optionName.equalsIgnoreCase("nosurface")) {
57              numberOption = new Float(in.tokenizer.getNumber());
58              Globals.noSurface = (numberOption.floatValue() != 0f);
59          }
60          else if (optionName.equalsIgnoreCase("omitcurrentobject")) {
61              numberOption = new Float(in.tokenizer.getNumber());
62              Globals.omitCurrentObject = (numberOption.floatValue() != 0f);
63          }
64          else if (optionName.equalsIgnoreCase("envmapfov")) {
65              numberOption = new Float(in.tokenizer.getNumber());
66              Globals.envmapfov = numberOption.floatValue();
67          }
68          else if (optionName.equalsIgnoreCase("tightclipping")) {
69              numberOption = new Float(in.tokenizer.getNumber());
70              Globals.omitCurrentObject = (numberOption.floatValue() != 0f);
71          }
72          else if (optionName.equalsIgnoreCase("convertshadows")) {
73              numberOption = new Float(in.tokenizer.getNumber());
74              Globals.doConvertShadows = (numberOption.floatValue() != 0f);
75          }
76          else
77              throw new FormatException("Unrecognized option",in.tokenizer);
78      }
79      
80      public void write(Writer out) throws IOException {
81          writeRequest(out);
82          out.write(" \"" + optionName + "\" ");
83          if (stringOption != null)
84              out.write(" \"" + stringOption + '"');
85          if (numberOption != null)
86              out.write(' ' + numberOption.toString());
87          out.write('\n');
88      }
89      
90  }//class
91  
92