|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectexe.Tree
public class Tree
This class provides support for binary and general trees, with methods to
output these trees in both GAIGS formats. A Tree object
contains a reference to the root of the tree, and children can be added to
this root using the various methods in the TreeNode class. The
methods of this class are used to set whether the Tree is
binary or general and to control the way the Tree is output in
a GAIGS animation.
In order to use any of these tree classes in a script-producing program, the
script-producing program must import the package exe.
| Field Summary | |
|---|---|
protected boolean |
binary
Maintains the binary status of this Tree. |
protected double |
font_size
Holds the minimum font size for this Tree when drawn in the
new GAIGS XML format. |
protected int |
lines_per_node
Keeps track of the number of lines of text for each TreeNode's label. |
protected java.io.PrintWriter |
out
Holds a reference to the PrintWriter output stream to which
this Tree should output its snapshots when its write
methods are called. |
protected TreeNode |
root
Contains a reference to the root of this Tree. |
protected double |
x_spacing
Contains the horizontal spacing of this Tree. |
protected double |
x1
Stores the left-most x-bound for this Tree within the
normalized [0,1] space. |
protected double |
x2
Stores the right-most x-bound for this Tree within the
normalized [0,1] space. |
protected double |
y_spacing
Contains the vertical spacing of this Tree. |
protected double |
y1
Stores the lower y-bound for this Tree within the
normalized [0,1] space. |
protected double |
y2
Stores the upper y-bound for this Tree within the
normalized [0,1] space. |
| Constructor Summary | |
|---|---|
Tree(boolean isBinary)
Constructs a new Tree by specifying whether it is a binary
or general Tree. |
|
Tree(boolean isBinary,
int lines_per_node)
Constructs a new Tree by specifying whether it is a binary
or general Tree and by giving the number of lines for node
labels. |
|
| Method Summary | |
|---|---|
TreeNode |
getRoot()
Returns the root of this Tree. |
boolean |
isBinary()
Indicates if this Tree is binary or general. |
void |
setBinary(boolean isBinary)
Specifies whether this Tree is binary or general. |
void |
setBounds(double x1,
double y1,
double x2,
double y2)
Sets the bounds in which this Tree is to be drawn. |
void |
setFontSize(double size)
Sets the minimum font size to keep the fonts in this Tree
readable. |
void |
setLinesPerNode(int lines_per_node)
Modifies the number of lines used for node labels. |
void |
setOut(java.io.PrintWriter out)
Stores a reference to the PrintWriter output stream to
which this Tree is to output its information. |
void |
setRoot(TreeNode r)
Sets the root TreeNode for this Tree. |
void |
setSpacing(double x,
double y)
Sets the spacing between nodes on the vertical and horizontal axes. |
void |
writeGAIGSTree(java.lang.String title)
Writes this Tree to the specified PrintWriter
output stream as an old GAIGS format snapshot. |
void |
writeGAIGSXMLTree()
Writes this Tree to the specified PrintWriter
output stream in the new GAIGS XML format. |
void |
writeGAIGSXMLTree(java.lang.String name)
Writes this Tree to the specified PrintWriter
output stream in the new GAIGS XML format. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected TreeNode root
Tree.
protected boolean binary
Tree. A value of
true means this Tree is binary, and a value of
false means this Tree is general. Defaults to
false, making the default a general Tree.
protected double x1
Tree within the
normalized [0,1] space. Defaults to 0.0 if no bounds are
set. The bounds variables can be used to localize this Tree
in a section of the drawing window in the new GAIGS XML format to allow
multiple structures to appear in the same snapshot.
protected double y1
Tree within the
normalized [0,1] space. Defaults to 0.0 if no bounds are
set. The bounds variables can be used to localize this Tree
in a section of the drawing window in the new GAIGS XML format to allow
multiple structures to appear in the same snapshot.
protected double x2
Tree within the
normalized [0,1] space. Defaults to 1.0 if no bounds are
set. The bounds variables can be used to localize this Tree
in a section of the drawing window in the new GAIGS XML format to allow
multiple structures to appear in the same snapshot.
protected double y2
Tree within the
normalized [0,1] space. Defaults to 1.0 if no bounds are
set. The bounds variables can be used to localize this Tree
in a section of the drawing window in the new GAIGS XML format to allow
multiple structures to appear in the same snapshot.
protected double font_size
Tree when drawn in the
new GAIGS XML format. Used to specify a font size that will be readable
when this Tree is drawn in a smaller portion of the screen.
protected double x_spacing
Tree. Used to
define how many node widths are between nodes on the x-axis when this
Tree is drawn in either GAIGS format. Defaults to a value
of 1.25, which produces just about as tight a tree as is
readable.
protected double y_spacing
Tree. Used to define
how many node widths are between nodes on the y-axis when this
Tree is drawn in either GAIGS format. Defaults to a value
of 1.25, which produces just about as tight a tree as is
readable.
protected int lines_per_node
TreeNode's label. This is used in the old GAIGS format, but
it is not necessary in the new GAIGS XML format because the number of
lines for each node can be determined from the XML script file. Default
value is 1.
protected java.io.PrintWriter out
PrintWriter output stream to which
this Tree should output its snapshots when its write
methods are called.
| Constructor Detail |
|---|
public Tree(boolean isBinary)
Tree by specifying whether it is a binary
or general Tree.
isBinary - Indicates if this Tree is binary or
general. A value of true makes a binary
Tree, and false results in a
general Tree.
public Tree(boolean isBinary,
int lines_per_node)
Tree by specifying whether it is a binary
or general Tree and by giving the number of lines for node
labels.
This is only necessary when outputting the Tree in the old
GAIGS format since the number of lines per node can be determined from
an XML script file in the new GAIGS XML format.
isBinary - Indicates if this Tree is binary or
general. A value of true makes a
binary Tree, and false
results in a general Tree.lines_per_node - Sets the number of lines for node labels.| Method Detail |
|---|
public void setRoot(TreeNode r)
TreeNode for this Tree.
This method completely resets the root for this Tree, and
any old data will be lost. Children can then be added to this root by
calling the appropriate methods in the TreeNode class.
r - Specifies the new root for this Tree. The variable
root is set to equal the value of r.public void setBinary(boolean isBinary)
Tree is binary or general.
If this Tree's root is not equal to
null, the value of binary will not be changed
because this Tree is already binary or general.
isBinary - Sets the value of binary. A value of
true results in a binary Tree,
and a value of false produces a general
Tree. The value of binary is
not changed if this Tree already has nodes.
public void setBounds(double x1,
double y1,
double x2,
double y2)
Tree is to be drawn.
These bounds specify the area within the normalized [0,1] space within
which this Tree should appear in the snapshot. Used to
draw this Tree in a portion of the viewing window so that
multiple structures can appear in a snapshot in the new GAIGS XML
format.
x1 - Sets the left-most bound on the horizontal axis.y1 - Sets the lower bound on the vertical axis.x2 - Sets the right-most bound on the horizontal axis.y2 - Sets the upper bound on the vertical axis.public void setFontSize(double size)
Tree
readable. Used to upsize the font when drawing this Tree in
a portion of the viewing window in the new GAIGS XML format.
size - Indicates the minimum font size for the fonts in this
Tree.
public void setSpacing(double x,
double y)
x - Specifies the number of node widths between nodes on the
horizontal axis.y - Specifies the number of node widths between nodes on the
vertical axis.public void setOut(java.io.PrintWriter out)
PrintWriter output stream to
which this Tree is to output its information.
out - Indicates the output stream to which this Tree
should print its information when its write methods are
called.public void setLinesPerNode(int lines_per_node)
lines_per_node in a
script-producing program that uses the new GAIGS XML format.
lines_per_node - Sets the number of lines needed for node labels in
this Tree.public TreeNode getRoot()
root of this Tree.
root of this
Tree. If the root has not been set,
null is returned.public boolean isBinary()
Tree is binary or general.
true if this Tree is binary or
false if this Tree is general.public void writeGAIGSTree(java.lang.String title)
Tree to the specified PrintWriter
output stream as an old GAIGS format snapshot.
If the value of out has not been set using the
setOut(PrintWriter) method, an Exception will
be thrown.
title - Specifies the title for the snapshot so that it can be
properly inserted into the snapshot specification.public void writeGAIGSXMLTree()
Tree to the specified PrintWriter
output stream in the new GAIGS XML format.
If the value of out has not been set using the
setOut(PrintWriter) method, an Exception will
be thrown.
public void writeGAIGSXMLTree(java.lang.String name)
Tree to the specified PrintWriter
output stream in the new GAIGS XML format.
If the value of out has not been set using the
setOut(PrintWriter) method, an Exception will
be thrown.
This method is identical to writeGAIGSXMLTree, except that
it prints the optional name element that gives this
Tree a label in the snapshot.
name - Specifies the label/title for this Tree in the
snapshot. This is a title that appears only above this
structure and is smaller than the title for the entire
snapshot. If an individual title for this Tree
is not desired, use writeGAIGSXMLTree().
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||