org.graffiti.session
Class Session

java.lang.Object
  extended by org.graffiti.util.MutuallyReferableObject
      extended by org.graffiti.session.Session
All Implemented Interfaces:
ConstraintCheckerListener, MutuallyReferable
Direct Known Subclasses:
EditorSession

public class Session
extends MutuallyReferableObject
implements ConstraintCheckerListener

Contains a session. A session consists of a org.graffiti.graph.Graph and a list of corresponding org.graffiti.plugin.view.Views. Every Session contains a GraphConstraintChecker which checks the constraints defined by the current mode.

See Also:
Graph, View

Field Summary
protected  View activeView
          The active view in this session.
protected  List<Animation> animations
           
protected  GraphConstraintChecker constraintChecker
          The constraint checker of the graph.
protected  Graph graph
          The graph object of this session.
protected  int id
          Unique id for this session.
protected  List<View> views
          The list of views of this session.
 
Constructor Summary
Session()
          Constructs a new session instance with an empty graph and the corresponding constraint checker.
Session(Graph graph)
          Constructs a new session instance with the given graph.
 
Method Summary
 void addView(View view)
          Adds a new View to the inner list of views.
 void approveStartOfNewAnimation()
           
 void checkFailed(String msg)
          Handles the failed constraint check.
 void close()
          Closes this session.
 void discardActiveAnimation()
           
 Animation getActiveAnimation()
           
 View getActiveView()
          Returns the activeView.
 String getClassName(Algorithm algorithm)
          Returns the class name of the specified algorithm.
 Graph getGraph()
          Returns the graph of this session.
 int getId()
          Get unique id for this session.
protected  int getNextSessionId()
          Return the next unique session id to use.
 int getNextViewId()
          Return the next unique view id to use for this session.
 List<View> getViews()
          Returns the list of views in the manager.
 boolean hasActiveAnimation()
           
 boolean hasPassiveAnimation()
           
 boolean hasStartedNewAnimation()
           
 boolean isModified()
          Returns true, if the graph in this session has been modified.
 void removeView(View view)
          Removes the given view from this session.
 void setActiveAlgorithm(Algorithm a)
           
 void setActiveView(View activeView)
          Sets the activeView.
 void validateConstraints()
          Checks whether the graph satisfies all the constraints.
 
Methods inherited from class org.graffiti.util.MutuallyReferableObject
addReference
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

graph

protected Graph graph
The graph object of this session.


animations

protected List<Animation> animations

constraintChecker

protected GraphConstraintChecker constraintChecker
The constraint checker of the graph.


views

protected List<View> views
The list of views of this session.


activeView

protected View activeView
The active view in this session.


id

protected int id
Unique id for this session.

Constructor Detail

Session

public Session()
Constructs a new session instance with an empty graph and the corresponding constraint checker.


Session

public Session(Graph graph)
Constructs a new session instance with the given graph.

Parameters:
graph - the graph to be used for this session.
Method Detail

getNextSessionId

protected int getNextSessionId()
Return the next unique session id to use.

Returns:
Next session id.

getNextViewId

public int getNextViewId()
Return the next unique view id to use for this session.

Returns:
Next view id.

getId

public int getId()
Get unique id for this session.

Returns:
Unique id.

setActiveView

public void setActiveView(View activeView)
Sets the activeView.

Parameters:
activeView - The activeView to set

getActiveView

public View getActiveView()
Returns the activeView.

Returns:
View

getClassName

public String getClassName(Algorithm algorithm)
Returns the class name of the specified algorithm. Using the InstanceLoader an instance of this Algorithm can be created.

Parameters:
algorithm - the Algorithm of which to get the class name.
Returns:
the class name of the specified algorithm.
Throws:
RuntimeException - DOCUMENT ME!

getGraph

public Graph getGraph()
Returns the graph of this session.

Returns:
the graph of this session.

setActiveAlgorithm

public void setActiveAlgorithm(Algorithm a)

isModified

public boolean isModified()
Returns true, if the graph in this session has been modified.

Returns:
True, if the graph has been modified. False, if not.

getViews

public List<View> getViews()
Returns the list of views in the manager.

Returns:
the list of views in the manager.

addView

public void addView(View view)
Adds a new View to the inner list of views.

Parameters:
view - a view to be added.

checkFailed

public void checkFailed(String msg)
Handles the failed constraint check.

Specified by:
checkFailed in interface ConstraintCheckerListener
Parameters:
msg - tells details about the unsatisfied constraints.

close

public void close()
Closes this session. Closes all the views of this session.


removeView

public void removeView(View view)
Removes the given view from this session.

Parameters:
view - the view to be removed from this session.
Throws:
IllegalArgumentException - DOCUMENT ME!

validateConstraints

public void validateConstraints()
                         throws UnsatisfiedConstraintException
Checks whether the graph satisfies all the constraints.

Throws:
UnsatisfiedConstraintException - if there es a constraint which is not satisfied.

hasActiveAnimation

public boolean hasActiveAnimation()

getActiveAnimation

public Animation getActiveAnimation()

discardActiveAnimation

public void discardActiveAnimation()

approveStartOfNewAnimation

public void approveStartOfNewAnimation()

hasStartedNewAnimation

public boolean hasStartedNewAnimation()

hasPassiveAnimation

public boolean hasPassiveAnimation()


Generated at 2012-05-30 11:00:36 PM CEST