|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.module.YModule
public abstract class YModule
This abstract class provides a skeleton for algorithms on graphs.
It defines an interface for the caller of the algorithm and
provides a mechanism for parameter passing via OptionHandler
s.
createOptionHandler()
has to
be overridden.
Field Summary | |
---|---|
static short |
FAILED
Exit state constant. |
protected ModuleListenerSupport |
moduleListenerSupport
The ModuleListenerSupport associated with this
YModule . |
static short |
PRECONDITION_VIOLATED
Exit state constant. |
static short |
SUCCESS
Exit state constant. |
Constructor Summary | |
---|---|
YModule(String moduleName,
String authorName,
String description)
Instantiates a YModule. |
Method Summary | |
---|---|
void |
addModuleListener(ModuleListener listener)
Registers ModuleListener to receive events during the execution of this module. |
protected OptionHandler |
createOptionHandler()
Creates an option handler for this class. |
protected Thread |
createThread(Runnable forRunnable)
Factory Method for startAsThread(y.view.Graph2D) . |
protected void |
dispose()
Disposition code performed after the execution of mainrun()
was finished. |
protected boolean |
exceptionHappened(Throwable throwable)
Callback method used by run() to indicate exceptional behavior. |
protected void |
fitGraph2DView()
Fits the content if the current view is of type Graph2DView . |
String |
getAuthor()
Returns the name of this module's author |
String |
getDescription()
Returns a short description of what this module does |
short |
getExitStatus()
Yields the exit status. |
protected Graph2D |
getGraph2D()
Grants access to the graph2D acted upon. |
protected Graph2DView |
getGraph2DView()
Grants access to the current view this module acts upon. |
String |
getModuleName()
Returns the name of this module. |
OptionHandler |
getOptionHandler()
Returns the option handler of this module. |
protected Timer |
getTimer()
Grants access to a timer object associated with this module. |
protected View |
getView()
Grants access to the current view this module acts upon. |
protected void |
init()
Initialization code performed before calling mainrun() . |
boolean |
isAbortable()
Returns whether or not this module can be aborted. |
boolean |
isBackupRealizersEnabled()
Returns whether or not this module will ask the given graph to backup all its realizers before it starts acting upon the graph. |
protected abstract void |
mainrun()
Main execution code to be implemented by any subclassing module. |
void |
removeModuleListener(ModuleListener listener)
Removes ModuleListener from the list of listeners. |
protected void |
run()
Calls the canonical module execution sequence: init() - mainrun() - dispose() . |
void |
setBackupRealizersEnabled(boolean enabled)
Sets whether or not this module will ask the given graph to backup all its realizers before it starts acting upon the graph. |
protected void |
setExitStatus(short status)
Sets the exit status of this module. |
void |
setGraph2D(Graph2D graph)
Sets the graph being acted upon. |
void |
setModuleName(String name)
Sets name of this module. |
void |
setOptionHandler(OptionHandler oh)
Sets the option handler for this method. |
void |
start(Graph2D graph)
Main module startup routine. |
void |
startAsThread(Graph2D graph)
Starts this module as a thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final short SUCCESS
public static final short FAILED
public static final short PRECONDITION_VIOLATED
protected final ModuleListenerSupport moduleListenerSupport
ModuleListenerSupport
associated with this
YModule
.
Constructor Detail |
---|
public YModule(String moduleName, String authorName, String description)
Method Detail |
---|
public String getModuleName()
public void setModuleName(String name)
public String getAuthor()
public String getDescription()
protected Timer getTimer()
public void setGraph2D(Graph2D graph)
protected Graph2D getGraph2D()
public void addModuleListener(ModuleListener listener)
listener
- The listener to register.ModuleListener
public void removeModuleListener(ModuleListener listener)
listener
- The listener to remove.ModuleListener
protected View getView()
protected Graph2DView getGraph2DView()
null
if the current view is not of type
Graph2DView
.
protected void fitGraph2DView()
Graph2DView
.
public OptionHandler getOptionHandler()
createOptionHandler()
.
If this module does not provide an option handler null
is returned.
protected OptionHandler createOptionHandler()
null
by default.public void setOptionHandler(OptionHandler oh)
public void start(Graph2D graph)
graph
- the graph being acted uponpublic void startAsThread(Graph2D graph)
graph
- the graph being acted upon.protected Thread createThread(Runnable forRunnable)
startAsThread(y.view.Graph2D)
.
This method creates a new Thread and sets its Priority to
Thread.MIN_PRIORITY
public boolean isAbortable()
public short getExitStatus()
SUCCESS
, FAILED
,
or PRECONDITION_VIOLATED
protected void setExitStatus(short status)
status
- One of the values SUCCESS, FAILED AND PRECONDITION_VIOLATED.protected void init()
mainrun()
.
protected abstract void mainrun()
protected void dispose()
mainrun()
was finished.
protected void run()
init()
- mainrun()
- dispose()
.
protected boolean exceptionHappened(Throwable throwable)
run()
to indicate exceptional behavior.
This method will notify registered listeners via ModuleListenerSupport.fireExceptionThrown(Throwable)
and returns true
iff this instance has listeners
.
Subclasses may override this method to change the behavior according to their needs.
throwable
- the exception
public boolean isBackupRealizersEnabled()
setBackupRealizersEnabled(boolean)
public void setBackupRealizersEnabled(boolean enabled)
Graph2D.backupRealizers()
|
© Copyright 2000-2013, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |