All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class javaParse.Desktop

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----javaParse.Desktop

public class Desktop
extends Canvas
implements MouseMotionListener, KeyListener, MouseListener
This is the canvas where the machines are built and displayed. It is the main class involved in the interface part of the different machines. The lists of transitions and states are kept here, and the actual painting of the transitions and states is performed here also.

See Also:
State, Transition

Variable Index

 o backcolor
 o currentCheckMark
value used in compareTo to initialise unique checkmarks
 o drag
 o draggingWhat
 o fieldCounter
The number of sublabels in a label.
 o firstState
used to retain the beginning state when dragging.
 o firstTransition
used when dragging.
 o initialState
The start state of the machine.
 o menu
 o menuOn
 o modified
Becomes true when the current machine is modified in any way.
 o selectedState
The currently selected dfa State (for label)
 o selectedTransition
The currently selected transition.
 o separator
The separators between the sublabels in a label.
 o showDfaLabels
whether to show State labels or not.
 o theStates
The list of states currently on the desktop.
 o theTransitions
The list of transitions currently on the desktop.
 o type
The type of the machine currently on the desktop.
 o x_offset
The x distance between the mouse pointer and the center of the state circle, when dragging a state.
 o y_offset
The x distance between the mouse pointer and the center of the state circle, when dragging a state.

Constructor Index

 o Desktop(Desktop)
copy constructor.
 o Desktop(int, Environment)
Builds a new Desktop with the specified type.

Method Index

 o addState(int, int)
Creates a new state and adds it to the list of states.
 o addTransition(State, State)
Creates a new transition and adds it to the list of transitions.
 o changeAspect(boolean)
Changes the aspect of the desktop.
 o getStateWithId(int)
returns the State with the given id if there is one else returns null.
 o isInState(int, int)
Checks to see if the given position is in a state.
 o isInStateDfaLabel(int, int)
Checks if the given position is in a Dfa State label.
 o isInTransition(int, int)
Checks to see if the given position is in a label.
 o keyPressed(KeyEvent)
 o keyReleased(KeyEvent)
 o keyTyped(KeyEvent)
 o locateLabel(Transition)
Returns the position of the label of the given transition.
 o mouseClicked(MouseEvent)
 o mouseDragged(MouseEvent)
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mouseMoved(MouseEvent)
 o mousePressed(MouseEvent)
 o mouseReleased(MouseEvent)
 o openWindow(State)
 o paint(Graphics)
 o placeState(State, Vector)
tries to find a good position for the parameter State by trying a few random positions and keeping the best one.
 o processKeyEvent(KeyEvent)
Overrides Component.processKeyEvent so that tabs are consumed here in the canvas instead of letting the canvas go out of focus and highlighting another component
 o relabel()
Relabels the states to have consecutive labels.
 o removeState(State)
Removes the given State from the Desktop
 o removeTransition(Transition)
Removes the given transition from the list of transitions.
 o setAllStateLists(Desktop)
 o setChecker(Vector)
 o setRowSize(Vector)
 o setVisible(boolean)
 o toLength(String, int)
Makes the String str have length length by adding white spaces.
 o toTabular()
Returns a string representing the tabular form of the current machine.
 o unfocusAll()
Removes the highlights from all the states.
 o unmarkAllStates()
sets the checkMarks on all the States on this Desktop to false
 o unselectTransitions()
Unselects all transitions on the Desktop
 o update(Graphics)

Variables

 o initialState
 public State initialState
The start state of the machine.

 o selectedTransition
 public Transition selectedTransition
The currently selected transition.

 o selectedState
 public State selectedState
The currently selected dfa State (for label)

 o theStates
 public Vector theStates
The list of states currently on the desktop. The machine will use them from here, too.

 o theTransitions
 public Vector theTransitions
The list of transitions currently on the desktop. The machine will use them from here, too.

 o modified
 public boolean modified
Becomes true when the current machine is modified in any way.

 o type
 public int type
The type of the machine currently on the desktop. This enables us to draw any type of machine using this class.

 o showDfaLabels
 public boolean showDfaLabels
whether to show State labels or not.

 o x_offset
 protected int x_offset
The x distance between the mouse pointer and the center of the state circle, when dragging a state.

 o y_offset
 protected int y_offset
The x distance between the mouse pointer and the center of the state circle, when dragging a state.

 o backcolor
 protected Color backcolor
 o menu
 protected PopupMenu menu
 o menuOn
 protected boolean menuOn
 o firstState
 protected State firstState
used to retain the beginning state when dragging.

 o firstTransition
 protected Transition firstTransition
used when dragging.

 o drag
 protected Point drag
 o draggingWhat
 protected int draggingWhat
 o fieldCounter
 protected int fieldCounter
The number of sublabels in a label.

 o separator
 protected String separator[]
The separators between the sublabels in a label.

 o currentCheckMark
 public int currentCheckMark
value used in compareTo to initialise unique checkmarks

Constructors

 o Desktop
 public Desktop(int type,
                Environment env)
Builds a new Desktop with the specified type.

Parameters:
type - the type of the machine represented on the desktop.
 o Desktop
 public Desktop(Desktop aDesktop)
copy constructor. makes a deep copy. Precondition: all State ids are unique.

Methods

 o processKeyEvent
 protected void processKeyEvent(KeyEvent e)
Overrides Component.processKeyEvent so that tabs are consumed here in the canvas instead of letting the canvas go out of focus and highlighting another component

Overrides:
processKeyEvent in class Component
 o keyPressed
 public void keyPressed(KeyEvent e)
 o keyTyped
 public void keyTyped(KeyEvent e)
 o keyReleased
 public void keyReleased(KeyEvent e)
 o mouseClicked
 public void mouseClicked(MouseEvent e)
 o mouseEntered
 public void mouseEntered(MouseEvent e)
 o mouseExited
 public void mouseExited(MouseEvent e)
 o mousePressed
 public void mousePressed(MouseEvent e)
 o mouseMoved
 public void mouseMoved(MouseEvent e)
 o mouseDragged
 public void mouseDragged(MouseEvent e)
 o mouseReleased
 public void mouseReleased(MouseEvent e)
 o setVisible
 public void setVisible(boolean boo)
Overrides:
setVisible in class Component
 o paint
 public void paint(Graphics g)
Overrides:
paint in class Canvas
 o update
 public void update(Graphics g)
Overrides:
update in class Component
 o addState
 public State addState(int x,
                       int y)
Creates a new state and adds it to the list of states.

 o getStateWithId
 public State getStateWithId(int idNum)
returns the State with the given id if there is one else returns null.

 o isInState
 public State isInState(int x,
                        int y)
Checks to see if the given position is in a state. To speed it up, we check if the position is in the rectangle surrounding the state's circle.

Returns:
the state found, or null, if none was found.
 o addTransition
 public Transition addTransition(State from,
                                 State to)
Creates a new transition and adds it to the list of transitions.

 o removeTransition
 public void removeTransition(Transition t)
Removes the given transition from the list of transitions.

 o removeState
 public void removeState(State s)
Removes the given State from the Desktop

 o locateLabel
 public Point locateLabel(Transition t)
Returns the position of the label of the given transition.

 o isInTransition
 public Transition isInTransition(int x,
                                  int y)
Checks to see if the given position is in a label.

Returns:
the transition found, or null if none was found.
 o isInStateDfaLabel
 public State isInStateDfaLabel(int x,
                                int y)
Checks if the given position is in a Dfa State label.

Returns:
the corresponding State found, or null if none is found
 o changeAspect
 public void changeAspect(boolean fade)
Changes the aspect of the desktop. It becomes faded when fade is true, and unfaded when fade is false.

 o relabel
 public void relabel()
Relabels the states to have consecutive labels.

 o unfocusAll
 public void unfocusAll()
Removes the highlights from all the states.

 o setAllStateLists
 public void setAllStateLists(Desktop d)
 o unselectTransitions
 public void unselectTransitions()
Unselects all transitions on the Desktop

 o toTabular
 public String toTabular()
Returns a string representing the tabular form of the current machine. It is the only method we could find to print the machine on all platforms.

 o toLength
 protected String toLength(String str,
                           int length)
Makes the String str have length length by adding white spaces. Used in method toTabular.

 o unmarkAllStates
 public void unmarkAllStates()
sets the checkMarks on all the States on this Desktop to false

 o placeState
 public void placeState(State aState,
                        Vector placedStates)
tries to find a good position for the parameter State by trying a few random positions and keeping the best one.

 o setRowSize
 public void setRowSize(Vector states)
 o setChecker
 public void setChecker(Vector states)
 o openWindow
 public void openWindow(State aState)

All Packages  Class Hierarchy  This Package  Previous  Next  Index