home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Late Night VRML 2.0 with Java CD-ROM
/
code.zip
/
Ch12
/
geometry
/
Box.bak
< prev
next >
Wrap
Text File
|
1997-01-05
|
2KB
|
115 lines
// VRML Generator
// Copyright Justin Couch 1996
//
// Chapter 13: Late Night VRML 2.0 and Java
//
// Box class
package geometry;
import java.io.*;
import java.awt.*;
import vrml.external.*;
import vrml.external.field.*;
import vrml.external.exception.*;
import geometry.Geometry;
public class Box extends Geometry
{
private float[] size = null;
// constructor builds a default box node
public Box()
{
System.out.println("Default called No browser");
Browser b = Browser.getBrowser();
if(b == null)
return;
node = b.createVrmlFromString("Box {}")[0];
}
public Box(Browser b)
{
System.out.println("Default called with browser");
if(b == null)
return;
node = b.createVrmlFromString("Box {}")[0];
System.out.println("The box original is " + node );
}
public Box(float x, float y, float z)
{
System.out.println("Long called No browser");
Browser b = Browser.getBrowser();
size = new float[3];
size[0] = x;
size[1] = y;
size[2] = z;
if(b == null)
return;
node = b.createVrmlFromString("Box { size " +
x + " " +
y + " " +
z + "}")[0];
have_browser = true;
}
public Box(Browser b, float x, float y, float z)
{
System.out.println("Long called with browser");
size = new float[3];
size[0] = x;
size[1] = y;
size[2] = z;
if(b == null)
return;
node = b.createVrmlFromString("Box { size " +
x + " " +
y + " " +
z + "}")[0];
have_browser = true;
}
public void finalize()
{
node = null;
size = null;
}
public void writeToFile(PrintStream fp, int indent)
{
int i;
StringBuffer buffer = new StringBuffer();
for(i = 0; i < indent; i++)
buffer.append(" ");
fp.print(buffer.toString() + "geometry ");
if(name != null)
fp.print("DEF " + name + " ");
fp.print("Box {");
if(size != null)
fp.print(" size " +
size[0] + " " +
size[1] + " " +
size[2]);
fp.println("}");
}
}