elan
Class Context

java.lang.Object
  |
  +--elan.Context

public class Context
extends java.lang.Object

Stores and manages the internal state of the IDE. Most commands, either GUI or model related, pass through this class.


Method Summary
 void addLegalCommand(java.lang.String command)
          adds a command to the list of legal/valid avaible slogo commands
 void appendErrorMessage(java.lang.String error)
          adds an error message to the list of messages for the user
 void appendMessage(java.lang.String update)
          adds a message to the list of messages for the user
 void back(double amount)
          moves the Turtle backward
 void clean()
          cleans the turtle canvas (i.e.
 void clearMessages()
          clears all messages to be shown to user
 void clearScreen()
          resets the Turtle's location to default location & clears all lines from canvas
 void forward(double amount)
          moves the Turtle foward
 java.awt.Color getBackground()
           
 java.lang.Object[] getCoreCommands()
           
 java.lang.Object[] getCustomCommands()
           
static Context getInstance()
           
 java.lang.Object[] getMessages()
           
 java.awt.Color getPenColor()
           
 float getPenWidth()
           
 java.awt.geom.Point2D getTurtleCoords()
           
 int getTurtleDisplacement()
           
 double getTurtleHeading()
           
 java.awt.Image getTurtleImage()
           
 double getTurtleXCor()
           
 double getTurtleYCor()
           
 void home()
          resets the Turtle's location to default location
 boolean isPenDown()
           
 boolean isTurtleVisible()
           
 void load(java.io.File file)
          loads an existing file into the file manager and compiles the file
 void loadNew(java.lang.String filename)
          loads a new file into the file manager
 void print()
           
 void removeLegalCommand(java.lang.String command)
          removes a custom function from the list of available custom functions
 void save(java.lang.String filename)
          saves an existing file in the file manager and writes the file to disk
 void setBackground(java.awt.Color c)
          set the color of the background on the Canvas Frame
 void setPenColor(java.awt.Color c)
          set the Turtle's pen color to the specified value
 void setPenDown(boolean b)
           
 void setPenWidth(float width)
          set the size/width of the Turtle's pen
 void setTurtleCoords(double x, double y)
          set the Turtle's x-coordinate & y-coordinate
 void setTurtleDisplacement(int value)
          set the Turtle's displacement (i.e.
 void setTurtleHeading(double change)
          set the Turtle's heading
 void setTurtleHeadingAbsolute(int newHeading)
          set the Turtle's heading to the specified value
 void setTurtleImage(java.awt.Image im)
          set the Turtle's image on the drawing canvas
 void setTurtleVisibility(boolean vis)
          set the visibility of the Turtle
 void setTurtleXCor(double change)
          set the Turtle's x-coordinate
 void setTurtleYCor(double change)
          set the Turtle's y-coordinate
 void sortCustomCommands()
          sorts the list of available custom functions
 void towards(double lhs, double rhs)
          moves the Turtle towards ...
 void update()
          updates the view of the entire IDE
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Context getInstance()
Returns:
the single instance of this object

getTurtleDisplacement

public int getTurtleDisplacement()
Returns:
current displacement of the Turtle

setTurtleDisplacement

public void setTurtleDisplacement(int value)
set the Turtle's displacement (i.e. change between previous position and new position)

Parameters:
value - displacement to which to set the Turtle

getTurtleXCor

public double getTurtleXCor()
Returns:
Turtle's x-coordinate

getTurtleYCor

public double getTurtleYCor()
Returns:
Turtle's y-coordinate

setTurtleXCor

public void setTurtleXCor(double change)
set the Turtle's x-coordinate

Parameters:
change - displacement in x direction to which to set the Turtle

setTurtleYCor

public void setTurtleYCor(double change)
set the Turtle's y-coordinate

Parameters:
change - displacement in y direction to which to set the Turtle

setTurtleCoords

public void setTurtleCoords(double x,
                            double y)
set the Turtle's x-coordinate & y-coordinate


getTurtleCoords

public java.awt.geom.Point2D getTurtleCoords()
Returns:
current Point at which the Turtle is located

setTurtleImage

public void setTurtleImage(java.awt.Image im)
set the Turtle's image on the drawing canvas

Parameters:
im - image to which to set the turtle

getTurtleImage

public java.awt.Image getTurtleImage()
Returns:
current Image representing Turtle

setTurtleHeading

public void setTurtleHeading(double change)
set the Turtle's heading

Parameters:
change - amount by which to change the Turtle's current heading (see also setTurtleHeadingAbsolute(double d) )

setTurtleHeadingAbsolute

public void setTurtleHeadingAbsolute(int newHeading)
set the Turtle's heading to the specified value


getTurtleHeading

public double getTurtleHeading()
Returns:
heading at which turtle is pointing

getMessages

public java.lang.Object[] getMessages()
Returns:
array of messages to be shown to user

appendMessage

public void appendMessage(java.lang.String update)
adds a message to the list of messages for the user

Parameters:
update - message to append

appendErrorMessage

public void appendErrorMessage(java.lang.String error)
adds an error message to the list of messages for the user

Parameters:
error - message to append

clearMessages

public void clearMessages()
clears all messages to be shown to user


setPenDown

public void setPenDown(boolean b)

isPenDown

public boolean isPenDown()
Returns:
true - if pen is down

setPenColor

public void setPenColor(java.awt.Color c)
set the Turtle's pen color to the specified value

Parameters:
c - the color to which to set the pen

getPenColor

public java.awt.Color getPenColor()
Returns:
the color of the Turtle's pen

setPenWidth

public void setPenWidth(float width)
set the size/width of the Turtle's pen

Parameters:
width - the width to which to set the Turtle's pen

getPenWidth

public float getPenWidth()
Returns:
the size/width of the Turtle's pen

setBackground

public void setBackground(java.awt.Color c)
set the color of the background on the Canvas Frame

Parameters:
c - the color to which to set the background

getBackground

public java.awt.Color getBackground()
Returns:
the set color for the canvas

setTurtleVisibility

public void setTurtleVisibility(boolean vis)
set the visibility of the Turtle

Parameters:
vis - true - if Turtle is visible

isTurtleVisible

public boolean isTurtleVisible()
Returns:
true - if Turtle is visible

addLegalCommand

public void addLegalCommand(java.lang.String command)
adds a command to the list of legal/valid avaible slogo commands

Parameters:
command - command to add to the list of available custom functions

removeLegalCommand

public void removeLegalCommand(java.lang.String command)
removes a custom function from the list of available custom functions

Parameters:
command - command to remove from the list of available custom functions

sortCustomCommands

public void sortCustomCommands()
sorts the list of available custom functions


getCustomCommands

public java.lang.Object[] getCustomCommands()
Returns:
all of the user-defined commands

getCoreCommands

public java.lang.Object[] getCoreCommands()
Returns:
the list of core SLOGO commands

clean

public void clean()
cleans the turtle canvas (i.e. clears all lines)


home

public void home()
resets the Turtle's location to default location


clearScreen

public void clearScreen()
resets the Turtle's location to default location & clears all lines from canvas


towards

public void towards(double lhs,
                    double rhs)
moves the Turtle towards ...


forward

public void forward(double amount)
moves the Turtle foward

Parameters:
amount - number to units of which to move the Turtle

back

public void back(double amount)
moves the Turtle backward

Parameters:
amount - number to units of which to move the Turtle

save

public void save(java.lang.String filename)
saves an existing file in the file manager and writes the file to disk

Parameters:
filename - name of file being saved

load

public void load(java.io.File file)
loads an existing file into the file manager and compiles the file

Parameters:
file - File to load into file manager

loadNew

public void loadNew(java.lang.String filename)
loads a new file into the file manager

Parameters:
filename - name of new file opened in file manager (NOTE: actual file is not created and written out until the file has been saved)

update

public void update()
updates the view of the entire IDE


print

public void print()