org.PingOO.DLAI.lib.graph
Class BuildGraph

java.lang.Object
  |
  +--java.io.StreamTokenizer
        |
        +--org.PingOO.DLAI.lib.graph.ScanWord
              |
              +--org.PingOO.DLAI.lib.graph.BuildGraph

public class BuildGraph
extends ScanWord

This class will parse a description file and build a plot based on the instructions in the file.
The build Graph class, with attached Axes and DataSets can be accessed though methods in the class

Version:
1.14 1996/09/06 00:08:49
Author:
Leigh Brookshaw (http://www.sci.usq.edu.au/staff/leighb/graph/) (leighb@usq.edu.au)

Inner Class Summary
private  class BuildGraph.NamedObject
          This is a structure class used exclusively by BuildGraph.
 
Field Summary
protected  java.applet.Applet applet
          The Calling Applet
(package private) static int ATTACH
           
(package private) static int AXIS
           
(package private) static int BACKGROUND
           
(package private) static int BEGIN
           
(package private) static int BOLD
           
(package private) static int BOTTOM
           
protected  java.util.Stack build
          The BUILD stack.
protected  java.util.Vector built
          The class vector.
(package private) static int CDATA
           
(package private) static int CLABELS
           
(package private) static int COLOR
           
(package private) static int CONTOUR
           
(package private) static int DATA
           
private  java.util.Vector datasets
          This vector contains all the datasets as they are built.
protected  boolean debug
          Debug.
(package private) static int DEBUG
           
(package private) static int END
           
(package private) static int FONT
           
(package private) static int FUNCTION
           
(package private) static int G2DINT
           
protected  java.lang.Object graph
          The constructed Graph Object
(package private) static int GRAPH2D
           
protected  TextLine graphtitle
          The TextLine containing the title
(package private) static int GRID
           
(package private) static int GRID_COLOR
           
(package private) static int GRID_OFF
           
(package private) static int GRID_ON
           
(package private) static int ITALIC
           
(package private) static int LABEL
           
(package private) static int LABEL_COLOR
           
(package private) static int LABEL_FONT
           
(package private) static int LABEL_OFF
           
(package private) static int LEFT
           
 int level
          The current brace level.
 int lineno
          Current line being parsed
(package private) static int LLEVELS
           
(package private) static int LOGCONTOURS
           
(package private) static int MARKER
           
(package private) static int MARKER_COLOR
           
(package private) static int MARKER_SIZE
           
(package private) static int MARKER_STYLE
           
(package private) static int MARKER_URL
           
(package private) static int NAME
           
(package private) static int NUMBER
           
protected  java.util.Stack object
          The Object stack.
(package private) static int OFF
           
(package private) static int ON
           
(package private) static int PLAIN
           
(package private) static int RIGHT
           
(package private) static int SIZE
           
(package private) static int SQUARE
           
(package private) static int STYLE
           
(package private) static int TITLE
           
(package private) static int TOP
           
(package private) static int URL
           
(package private) static int XMAX
           
(package private) static int XMIN
           
(package private) static int XNUMBER
           
(package private) static int XRANGE
           
(package private) static int YMAX
           
(package private) static int YMIN
           
(package private) static int YNUMBER
           
(package private) static int YRANGE
           
(package private) static int ZERO
           
(package private) static int ZERO_COLOR
           
(package private) static int ZERO_OFF
           
(package private) static int ZERO_ON
           
 
Fields inherited from class org.PingOO.DLAI.lib.graph.ScanWord
ERROR, is, kwords, STRING, StringChar, UNKNOWN
 
Fields inherited from class java.io.StreamTokenizer
buf, CT_ALPHA, CT_COMMENT, CT_DIGIT, CT_QUOTE, CT_WHITESPACE, ctype, eolIsSignificantP, forceLower, input, LINENO, nval, peekc, pushedBack, reader, slashSlashCommentsP, slashStarCommentsP, sval, TT_EOF, TT_EOL, TT_NOTHING, TT_NUMBER, TT_WORD, ttype
 
Constructor Summary
BuildGraph(java.io.InputStream in, java.applet.Applet ap)
          Instantiate the class
 
Method Summary
protected  double[] arrayFromFunction(ParseFunction f, int nx, double xmin, double xmax)
           
protected  double[] arrayFromFunction(ParseFunction f, int nx, double xmin, double xmax, int ny, double ymin, double ymax)
           
protected  boolean build(BuildGraph.NamedObject nobj)
          Based on the parsed object build something.
protected  boolean buildAxis()
          Builds the axis.
protected  boolean buildContour(BuildGraph.NamedObject nobj)
          Builds the contour.
protected  boolean buildData(int type)
          Build the data
protected  boolean buildFont()
          Builds the font.
protected  boolean buildGraph(int type)
          Pops things off the object stack and build the graph.
protected  boolean buildGrid()
          Builds the grid.
protected  boolean buildLabel()
          Buids the label.
protected  boolean buildMarker()
           
protected  boolean buildTitle()
          Builds the title.
protected  boolean buildZero()
          Builds zero.
private  void debugMessage(java.lang.String s, int token)
          Outputs the parsed debug message, appending line number, and token string.
private  void errorAtLine(java.lang.String s)
          Outputs the parsed error message with the line number of the line that triggered the error.
 java.util.Vector getBuilt()
          Get a vector of all the built Classes.
 java.lang.Object getGraph()
          Gets the Graph object that has been built!
 TextLine getGraphTitle()
          Get the title of the Graph.
protected  boolean isContext(int token)
          Checks if the object is on the "to be built" stack.
 void parse()
          This is THE method that parses the input file and constructs the plot.
 
Methods inherited from class org.PingOO.DLAI.lib.graph.ScanWord
addKeyWord, closeStream, getKeyValue, getNumber, nextWord, resetKeyWords, resetWordSyntax, setStringChar
 
Methods inherited from class java.io.StreamTokenizer
commentChar, eolIsSignificant, lineno, lowerCaseMode, nextToken, ordinaryChar, ordinaryChars, parseNumbers, pushBack, quoteChar, read, resetSyntax, slashSlashComments, slashStarComments, toString, whitespaceChars, wordChars
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

BEGIN

static final int BEGIN

GRAPH2D

static final int GRAPH2D

MARKER

static final int MARKER

AXIS

static final int AXIS

URL

static final int URL

DATA

static final int DATA

SIZE

static final int SIZE

COLOR

static final int COLOR

NAME

static final int NAME

TITLE

static final int TITLE

LABEL

static final int LABEL

FONT

static final int FONT

STYLE

static final int STYLE

BOTTOM

static final int BOTTOM

TOP

static final int TOP

LEFT

static final int LEFT

RIGHT

static final int RIGHT

END

static final int END

G2DINT

static final int G2DINT

OFF

static final int OFF

ON

static final int ON

ATTACH

static final int ATTACH

PLAIN

static final int PLAIN

BOLD

static final int BOLD

ITALIC

static final int ITALIC

DEBUG

static final int DEBUG

GRID

static final int GRID

ZERO

static final int ZERO

CONTOUR

static final int CONTOUR

LLEVELS

static final int LLEVELS

NUMBER

static final int NUMBER

CDATA

static final int CDATA

FUNCTION

static final int FUNCTION

XRANGE

static final int XRANGE

YRANGE

static final int YRANGE

BACKGROUND

static final int BACKGROUND

LOGCONTOURS

static final int LOGCONTOURS

CLABELS

static final int CLABELS

SQUARE

static final int SQUARE

MARKER_STYLE

static final int MARKER_STYLE

MARKER_COLOR

static final int MARKER_COLOR

MARKER_SIZE

static final int MARKER_SIZE

LABEL_COLOR

static final int LABEL_COLOR

LABEL_FONT

static final int LABEL_FONT

GRID_COLOR

static final int GRID_COLOR

GRID_OFF

static final int GRID_OFF

ZERO_COLOR

static final int ZERO_COLOR

ZERO_OFF

static final int ZERO_OFF

MARKER_URL

static final int MARKER_URL

GRID_ON

static final int GRID_ON

ZERO_ON

static final int ZERO_ON

XMIN

static final int XMIN

XMAX

static final int XMAX

YMIN

static final int YMIN

YMAX

static final int YMAX

XNUMBER

static final int XNUMBER

YNUMBER

static final int YNUMBER

LABEL_OFF

static final int LABEL_OFF

build

protected java.util.Stack build
The BUILD stack.
Everything pushed on this stack has to be built from other objects.
An example would be a Font, which is constructed from Logical name, style and size.

object

protected java.util.Stack object
The Object stack.
All input tokens get pushed onto and popped off this stack.

built

protected java.util.Vector built
The class vector.
This contains final class objects that cannot be deleted.
That is we don't want these classes unnattached and collected into the garbage.
The obvious classes here are the main Graph2D class, the Axes of the plot DataSets etc.

graph

protected java.lang.Object graph
The constructed Graph Object

graphtitle

protected TextLine graphtitle
The TextLine containing the title

applet

protected java.applet.Applet applet
The Calling Applet

debug

protected boolean debug
Debug.
If true output copious debug messages.
Though unless you know what is going on with the code most messages will probably be meaningless.

datasets

private java.util.Vector datasets
This vector contains all the datasets as they are built.
The data sets in this lists are then searched so that they can be attached to axis.

lineno

public int lineno
Current line being parsed

level

public int level
The current brace level.
At the end of the input if all braces are matched the level should be back to zero.
Constructor Detail

BuildGraph

public BuildGraph(java.io.InputStream in,
                  java.applet.Applet ap)
Instantiate the class
Parameters:
in - The inputstream to be read
ap - the driving applet.
Method Detail

getGraph

public java.lang.Object getGraph()
Gets the Graph object that has been built!
Returns:
The Graph object that has been built!

getGraphTitle

public TextLine getGraphTitle()
Get the title of the Graph.
Returns:
The title of the Graph.

getBuilt

public java.util.Vector getBuilt()
Get a vector of all the built Classes.
Ie the DataSets, Axis, Graph etc.
This can be used by an applet to override anything specified in the input file.
Returns:
The vector of all the built Classes.

parse

public void parse()
This is THE method that parses the input file and constructs the plot.

isContext

protected boolean isContext(int token)
Checks if the object is on the "to be built" stack.
This way context can be checked so potential errors flagged.
Parameters:
token - Is this the object we are currently building?
Returns:
true if the token matches current object being built, false otherwise.

build

protected boolean build(BuildGraph.NamedObject nobj)
Based on the parsed object build something.
Parameters:
nobj - The object to be built
Returns:
true if the build was successful, false otherwise.

buildGraph

protected boolean buildGraph(int type)
Pops things off the object stack and build the graph.
Parameters:
type - Type of graph to build, Graph2D, G2Dint, Contour.
Returns:
true if the build was successful, false otherwise.

buildContour

protected boolean buildContour(BuildGraph.NamedObject nobj)
Builds the contour.
Returns:
true if the build was successful, false otherwise.

buildFont

protected boolean buildFont()
Builds the font.
Returns:
true if the build was successful, false otherwise.

buildTitle

protected boolean buildTitle()
Builds the title.
Returns:
true if the build was successful, false otherwise.

buildLabel

protected boolean buildLabel()
Buids the label.
Returns:
true if the build was successful, false otherwise.

buildMarker

protected boolean buildMarker()

buildData

protected boolean buildData(int type)
Build the data
Returns:
true if the build was successful, false otherwise.

arrayFromFunction

protected double[] arrayFromFunction(ParseFunction f,
                                     int nx,
                                     double xmin,
                                     double xmax)
Parameters:
f -  
nx -  
xmin -  
xmax -  
Returns:
A double array.

arrayFromFunction

protected double[] arrayFromFunction(ParseFunction f,
                                     int nx,
                                     double xmin,
                                     double xmax,
                                     int ny,
                                     double ymin,
                                     double ymax)
Parameters:
f -  
nx -  
xmin -  
xmax -  
ny -  
ymin -  
ymax -  
Returns:
A double array.

buildAxis

protected boolean buildAxis()
Builds the axis.
Returns:
true if the build was successful, false otherwise.

buildGrid

protected boolean buildGrid()
Builds the grid.
Returns:
true if the build was successful, false otherwise.

buildZero

protected boolean buildZero()
Builds zero.
Returns:
true if the build was successful, false otherwise.

errorAtLine

private void errorAtLine(java.lang.String s)
Outputs the parsed error message with the line number of the line that triggered the error.
Parameters:
s - Message to ouput

debugMessage

private void debugMessage(java.lang.String s,
                          int token)
Outputs the parsed debug message, appending line number, and token string.
Parameters:
s - Message to ouput.
token - token to be replaced with a string.