|
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(java.lang.String name)
Initializes a new YModule instance with the given name. |
|
YModule(java.lang.String moduleName,
java.lang.String authorName,
java.lang.String description)
Deprecated. Use YModule(String) instead.
Proper module description should take place in the API documentation. |
Method Summary | |
---|---|
void |
addModuleListener(ModuleListener listener)
Adds the given module listener to receive module events during the execution of this module. |
protected OptionHandler |
createOptionHandler()
Creates an option handler for this class. |
protected java.lang.Thread |
createThread(java.lang.Runnable forRunnable)
Creates a new thread that is named after this module and sets the thread priority to Thread.MIN_PRIORITY . |
protected void |
dispose()
Disposition code performed after the execution of mainrun()
was finished. |
protected boolean |
exceptionHappened(java.lang.Throwable throwable)
Callback method used by run() to indicate exceptional behavior. |
protected void |
fitGraph2DView()
Fits the contents inside the current view if the current view is of type Graph2DView . |
java.lang.String |
getAuthor()
Deprecated. Proper module description should take place in the API documentation. |
java.lang.String |
getDescription()
Deprecated. Proper module description should take place in the API documentation. |
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. |
ModuleListener[] |
getModuleListeners()
Returns all the module listeners that have been added to this module. |
java.lang.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() . |
protected void |
initGuiFactory(OptionHandler optionHandler)
Sets the GuiFactory instance responsible for localizing
the given option handler's user interface. |
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 the given module listener so that it no longer receives module events from this module. |
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(java.lang.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(java.lang.String name)
YModule
instance with the given name.
The module's author
and description
properties will be set to empty strings.
name
- the module's name.public YModule(java.lang.String moduleName, java.lang.String authorName, java.lang.String description)
YModule(String)
instead.
Proper module description should take place in the API documentation.
YModule
instance with the given
name, author and description.
Method Detail |
---|
public java.lang.String getModuleName()
public void setModuleName(java.lang.String name)
public java.lang.String getAuthor()
public java.lang.String getDescription()
protected Timer getTimer()
public void setGraph2D(Graph2D graph)
protected Graph2D getGraph2D()
public void addModuleListener(ModuleListener listener)
listener
- The listener to register. May not be null
.ModuleListener
public void removeModuleListener(ModuleListener listener)
listener
- The listener to remove.ModuleListener
public ModuleListener[] getModuleListeners()
addModuleListener(ModuleListener)
,
removeModuleListener(ModuleListener)
protected View getView()
protected Graph2DView getGraph2DView()
null
if the current view is not of type
Graph2DView
.
protected void fitGraph2DView()
Graph2DView
.
Graph2DView.fitContent()
public OptionHandler getOptionHandler()
createOptionHandler()
.
If this module does not provide an option handler null
is returned.
protected void initGuiFactory(OptionHandler optionHandler)
GuiFactory
instance responsible for localizing
the given option handler's user interface.
The default implementation of this method looks for the first resource bundle that corresponds to this module's class or one of the module's super classes.
optionHandler
- the option handler whose user interface will be
localized.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 java.lang.Thread createThread(java.lang.Runnable forRunnable)
Thread.MIN_PRIORITY
.
Called from startAsThread(y.view.Graph2D)
.
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(java.lang.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-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |