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
-
backcolor
-
-
currentCheckMark
- value used in compareTo to initialise unique checkmarks
-
drag
-
-
draggingWhat
-
-
fieldCounter
- The number of sublabels in a label.
-
firstState
- used to retain the beginning state when dragging.
-
firstTransition
- used when dragging.
-
initialState
- The start state of the machine.
-
menu
-
-
menuOn
-
-
modified
- Becomes true when the current machine is modified in any way.
-
selectedState
- The currently selected dfa State (for label)
-
selectedTransition
- The currently selected transition.
-
separator
- The separators between the sublabels in a label.
-
showDfaLabels
- whether to show State labels or not.
-
theStates
- The list of states currently on the desktop.
-
theTransitions
- The list of transitions currently on the desktop.
-
type
- The type of the machine currently on the desktop.
-
x_offset
- The x distance between the mouse pointer
and the center of the state circle, when
dragging a state.
-
y_offset
- The x distance between the mouse pointer
and the center of the state circle, when
dragging a state.
-
Desktop(Desktop)
-
copy constructor.
-
Desktop(int, Environment)
- Builds a new Desktop with the specified type.
-
addState(int, int)
- Creates a new state and adds it to the list of states.
-
addTransition(State, State)
- Creates a new transition and adds it to the list of transitions.
-
changeAspect(boolean)
- Changes the aspect of the desktop.
-
getStateWithId(int)
- returns the State with the given id if there is one
else returns null.
-
isInState(int, int)
- Checks to see if the given position is in a state.
-
isInStateDfaLabel(int, int)
- Checks if the given position is in a Dfa State label.
-
isInTransition(int, int)
- Checks to see if the given position is in a label.
-
keyPressed(KeyEvent)
-
-
keyReleased(KeyEvent)
-
-
keyTyped(KeyEvent)
-
-
locateLabel(Transition)
- Returns the position of the label of the given transition.
-
mouseClicked(MouseEvent)
-
-
mouseDragged(MouseEvent)
-
-
mouseEntered(MouseEvent)
-
-
mouseExited(MouseEvent)
-
-
mouseMoved(MouseEvent)
-
-
mousePressed(MouseEvent)
-
-
mouseReleased(MouseEvent)
-
-
openWindow(State)
-
-
paint(Graphics)
-
-
placeState(State, Vector)
- tries to find a good position for the parameter State by trying a few random positions
and keeping the best one.
-
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
-
relabel()
- Relabels the states to have consecutive labels.
-
removeState(State)
-
Removes the given State from the Desktop
-
removeTransition(Transition)
- Removes the given transition from the list of transitions.
-
setAllStateLists(Desktop)
-
-
setChecker(Vector)
-
-
setRowSize(Vector)
-
-
setVisible(boolean)
-
-
toLength(String, int)
- Makes the String str have length length by adding white spaces.
-
toTabular()
- Returns a string representing the tabular form of the current machine.
-
unfocusAll()
- Removes the highlights from all the states.
-
unmarkAllStates()
- sets the checkMarks on all the States on this Desktop to false
-
unselectTransitions()
- Unselects all transitions on the Desktop
-
update(Graphics)
-
initialState
public State initialState
- The start state of the machine.
selectedTransition
public Transition selectedTransition
- The currently selected transition.
selectedState
public State selectedState
- The currently selected dfa State (for label)
theStates
public Vector theStates
- The list of states currently on the desktop.
The machine will use them from here, too.
theTransitions
public Vector theTransitions
- The list of transitions currently on the desktop.
The machine will use them from here, too.
modified
public boolean modified
- Becomes true when the current machine is modified in any way.
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.
showDfaLabels
public boolean showDfaLabels
- whether to show State labels or not.
x_offset
protected int x_offset
- The x distance between the mouse pointer
and the center of the state circle, when
dragging a state.
y_offset
protected int y_offset
- The x distance between the mouse pointer
and the center of the state circle, when
dragging a state.
backcolor
protected Color backcolor
menu
protected PopupMenu menu
menuOn
protected boolean menuOn
firstState
protected State firstState
- used to retain the beginning state when dragging.
firstTransition
protected Transition firstTransition
- used when dragging.
drag
protected Point drag
draggingWhat
protected int draggingWhat
fieldCounter
protected int fieldCounter
- The number of sublabels in a label.
separator
protected String separator[]
- The separators between the sublabels in a label.
currentCheckMark
public int currentCheckMark
- value used in compareTo to initialise unique checkmarks
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.
Desktop
public Desktop(Desktop aDesktop)
- copy constructor. makes a deep copy.
Precondition: all State ids are unique.
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
keyPressed
public void keyPressed(KeyEvent e)
keyTyped
public void keyTyped(KeyEvent e)
keyReleased
public void keyReleased(KeyEvent e)
mouseClicked
public void mouseClicked(MouseEvent e)
mouseEntered
public void mouseEntered(MouseEvent e)
mouseExited
public void mouseExited(MouseEvent e)
mousePressed
public void mousePressed(MouseEvent e)
mouseMoved
public void mouseMoved(MouseEvent e)
mouseDragged
public void mouseDragged(MouseEvent e)
mouseReleased
public void mouseReleased(MouseEvent e)
setVisible
public void setVisible(boolean boo)
- Overrides:
- setVisible in class Component
paint
public void paint(Graphics g)
- Overrides:
- paint in class Canvas
update
public void update(Graphics g)
- Overrides:
- update in class Component
addState
public State addState(int x,
int y)
- Creates a new state and adds it to the list of states.
getStateWithId
public State getStateWithId(int idNum)
- returns the State with the given id if there is one
else returns null.
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.
addTransition
public Transition addTransition(State from,
State to)
- Creates a new transition and adds it to the list of transitions.
removeTransition
public void removeTransition(Transition t)
- Removes the given transition from the list of transitions.
removeState
public void removeState(State s)
- Removes the given State from the Desktop
locateLabel
public Point locateLabel(Transition t)
- Returns the position of the label of the given transition.
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.
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
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.
relabel
public void relabel()
- Relabels the states to have consecutive labels.
unfocusAll
public void unfocusAll()
- Removes the highlights from all the states.
setAllStateLists
public void setAllStateLists(Desktop d)
unselectTransitions
public void unselectTransitions()
- Unselects all transitions on the Desktop
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.
toLength
protected String toLength(String str,
int length)
- Makes the String str have length length by adding white spaces.
Used in method toTabular.
unmarkAllStates
public void unmarkAllStates()
- sets the checkMarks on all the States on this Desktop to false
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.
setRowSize
public void setRowSize(Vector states)
setChecker
public void setChecker(Vector states)
openWindow
public void openWindow(State aState)
All Packages Class Hierarchy This Package Previous Next Index