turingmachine
Class CTMDataState

java.lang.Object
  extended by turingmachine.CTMData
      extended by turingmachine.CTMDataState
All Implemented Interfaces:
java.io.Serializable

class CTMDataState
extends CTMData
implements java.io.Serializable

State data class.


Field Summary
static int END_NODE
          End state type.
static int GOSUB_NODE
          Gosub state type.
private  boolean mBreakPoint
          is the breakpoint set on this state.
private  java.util.ArrayList<CTMDataLink> mLinksFrom
          links from other states that come to this ( used for faster updates ) maybe make transient and autogen on load.
private  java.util.ArrayList<CTMDataLink> mLinksTo
          links from this state that go to another.
private  CTMPoint mLocation
          This states position in the document.
private  java.lang.String mName
          The name of this states displayed state.
private  int mType
          What type of state is this?
static int NORMAL_NODE
          Normal state type.
(package private) static long serialVersionUID
          Serial id, so future version will load old files
static int START_NODE
          Start state type.
 
Constructor Summary
CTMDataState(CTMDocument aDocument, java.lang.String aStateName, java.awt.Point aPoint)
          Constructor.
 
Method Summary
 void delete()
          Delete this state from its document
 CTMDataLink getLinkToState(CTMDataState aState)
          Check whether this state links from this to aState ( used as check before creating links ).
 CTMPoint getLocation()
          Get the states center point location.
 java.lang.String getName()
          Get the state name.
 int getType()
          Get the state type.
 boolean hasLinksFrom()
          Get whether or not this state has links leaving it.
 boolean isBreakPointSet()
          Is the breakpoint set.
 CTMDataLink linkAdd(CTMDataState toState)
          Add a link from this state to another state.
private  void linkAddTo(CTMDataLink aFromLink)
          Add a reference to another states link to this state.
 void linkRemove(CTMDataLink aLink)
          Remove a link from this state.
private  void linkRemoveTo(CTMDataLink aLink)
          Remove a reference from another states link to this state.
 java.util.Iterator<CTMDataLink> linksFromIterator()
          Get the iterator to this states links From.
 java.util.Iterator<CTMDataLink> linksToIterator()
          Get the iterator to this states links To.
 void setBreakPoint(boolean breakpoint)
          Sets the breakpoint.
 void setLocation(java.awt.geom.Point2D aPoint)
          Set this states position within the document.
 void setStateName(java.lang.String name)
          Set the state name.
 void setType(int aType)
          Set the states type.
 void toFront()
          Bring this state to the front in the document.
private  void touchLinks()
          Set all sub links as modified so they will sync.
 void translate(int aX, int aY)
          Move this state relative to its' current position.
 
Methods inherited from class turingmachine.CTMData
getDataParent, getDocument, getModificationCount, isDeleted, touch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

static final long serialVersionUID
Serial id, so future version will load old files

See Also:
Constant Field Values

mName

private java.lang.String mName
The name of this states displayed state.


mLocation

private CTMPoint mLocation
This states position in the document.


mBreakPoint

private boolean mBreakPoint
is the breakpoint set on this state.


mLinksTo

private java.util.ArrayList<CTMDataLink> mLinksTo
links from this state that go to another.


mLinksFrom

private java.util.ArrayList<CTMDataLink> mLinksFrom
links from other states that come to this ( used for faster updates ) maybe make transient and autogen on load.


mType

private int mType
What type of state is this?


START_NODE

public static final int START_NODE
Start state type.

See Also:
Constant Field Values

NORMAL_NODE

public static final int NORMAL_NODE
Normal state type.

See Also:
Constant Field Values

END_NODE

public static final int END_NODE
End state type.

See Also:
Constant Field Values

GOSUB_NODE

public static final int GOSUB_NODE
Gosub state type.

See Also:
Constant Field Values
Constructor Detail

CTMDataState

public CTMDataState(CTMDocument aDocument,
                    java.lang.String aStateName,
                    java.awt.Point aPoint)
Constructor.

Parameters:
aDocument - The document this state data is part of.
aStateName - The name of this states state.
aPoint - The initial location of the state.
Method Detail

linkAdd

public CTMDataLink linkAdd(CTMDataState toState)
Add a link from this state to another state. If a link already exists returns the existing link.

Parameters:
toState - The State to link to.
Returns:
The newly created link data.

linkAddTo

private void linkAddTo(CTMDataLink aFromLink)
Add a reference to another states link to this state.

Parameters:
aFromLink - The other states linkTo instance.

linkRemove

public void linkRemove(CTMDataLink aLink)
Remove a link from this state.

Parameters:
aLink - The link to remove.

linkRemoveTo

private void linkRemoveTo(CTMDataLink aLink)
Remove a reference from another states link to this state.

Parameters:
aLink - The other states link instance remove.

isBreakPointSet

public boolean isBreakPointSet()
Is the breakpoint set.

Returns:
true - yes, false - no.

setBreakPoint

public void setBreakPoint(boolean breakpoint)
Sets the breakpoint.

Parameters:
breakpoint - The value to set the breakpoint to.

getType

public int getType()
Get the state type.

Returns:
This states type.

setType

public void setType(int aType)
Set the states type.

Parameters:
aType - The type of state to set it to.

getLocation

public CTMPoint getLocation()
Get the states center point location.

Returns:
The center point location of the state.

setLocation

public void setLocation(java.awt.geom.Point2D aPoint)
Set this states position within the document.

Parameters:
aPoint - The new location for the state.

translate

public void translate(int aX,
                      int aY)
Move this state relative to its' current position.

Parameters:
aX - The horizontal shift offset.
aY - The vertical shift offset.

touchLinks

private void touchLinks()
Set all sub links as modified so they will sync.


getName

public java.lang.String getName()
Get the state name.

Returns:
This states state name.

setStateName

public void setStateName(java.lang.String name)
Set the state name.

Parameters:
name - The new name for the state.

toFront

public void toFront()
Bring this state to the front in the document.


delete

public void delete()
Delete this state from its document

Overrides:
delete in class CTMData

getLinkToState

public CTMDataLink getLinkToState(CTMDataState aState)
Check whether this state links from this to aState ( used as check before creating links ).

Parameters:
aState - the state to check to.
Returns:
true - it does link to aState, else false.

linksToIterator

public java.util.Iterator<CTMDataLink> linksToIterator()
Get the iterator to this states links To.

Returns:
An iterator for this states links to.

linksFromIterator

public java.util.Iterator<CTMDataLink> linksFromIterator()
Get the iterator to this states links From.

Returns:
An iterator for this states links from.

hasLinksFrom

public boolean hasLinksFrom()
Get whether or not this state has links leaving it.

Returns:
True if state has links leaving it, else false.