Class BackgroundExecutionAlgorithm
java.lang.Object
org.graffiti.plugin.algorithm.ThreadSafeAlgorithm
org.vanted.plugins.layout.stressminimization.BackgroundExecutionAlgorithm
- All Implemented Interfaces:
PropertyChangeListener
,EventListener
,Algorithm
,SessionListener
public class BackgroundExecutionAlgorithm extends ThreadSafeAlgorithm implements PropertyChangeListener, SessionListener
This class handles the execution of a given
BackgroundAlgorithm
in the background, i.e.
asynchroneously. This class is an instance of ThreadSafeAlgorithm in order to provide a more flexible
options UI in the sidebar.-
Constructor Summary
Constructors Constructor Description BackgroundExecutionAlgorithm(BackgroundAlgorithm algorithm)
-
Method Summary
Modifier and Type Method Description void
attach(Graph g, Selection selection)
Attaches the given graph to this algorithm.void
check()
Checks whether all preconditions of the current graph are satisfied.void
execute()
Executes the whole algorithm.void
executeBackgroundAlgorithm()
Starts new thread which executes the BackgroundAlgorithm and starts the progress barvoid
executeThreadSafe(ThreadSafeOptions options)
KeyStroke
getAcceleratorKeyStroke()
Override this method to provide a accelerator hot key for the algorithm.ActionEvent
getActionEvent()
String
getCategory()
Returns the category an algorithm should assigned to.String
getDescription()
String
getMenuCategory()
Returns a path to a menu category.String
getName()
Returns the name (ID) of the algorithm.Parameter[]
getParameters()
Returns a list ofParameter
that are set for this algorithm.Set<Category>
getSetCategory()
Returns a set of categories to classify this algorithm .boolean
isLayoutAlgorithm()
A LayoutAlgorithm should return true.boolean
mayWorkOnMultipleGraphs()
void
propertyChange(PropertyChangeEvent arg0)
void
reset()
Resets the internal state of the algorithm.void
resetDataCache(ThreadSafeOptions options)
void
sessionChanged(Session s)
This method is called when the session changes.void
sessionDataChanged(Session s)
This method is called when the data (except the graph data) are changed.void
setActionEvent(ActionEvent a)
boolean
setControlInterface(ThreadSafeOptions threadSafeOptions, JComponent jc)
See readme for contextvoid
setParameters(Parameter[] params)
Sets the parameters for this algorithm.boolean
showMenuIcon()
Override this method to give a different look and feel to the application, and to put the plugin icon next to the menu item in the main menu bar.
-
Constructor Details
-
BackgroundExecutionAlgorithm
-
-
Method Details
-
getName
Description copied from interface:Algorithm
Returns the name (ID) of the algorithm. -
attach
Description copied from interface:Algorithm
Attaches the given graph to this algorithm. A ttaches the given Selection information to the algorithm. -
setParameters
Description copied from interface:Algorithm
Sets the parameters for this algorithm. Must have the same types and order as the array returned bygetParameter
.- Specified by:
setParameters
in interfaceAlgorithm
-
getParameters
Description copied from interface:Algorithm
Returns a list ofParameter
that are set for this algorithm.- Specified by:
getParameters
in interfaceAlgorithm
- Returns:
- a collection of
Parameter
that are needed by theAlgorithm
.
-
check
Description copied from interface:Algorithm
Checks whether all preconditions of the current graph are satisfied.- Specified by:
check
in interfaceAlgorithm
- Throws:
PreconditionException
- if the preconditions of the current graph are not satisfied.
-
execute
public void execute()Description copied from interface:Algorithm
Executes the whole algorithm. -
executeBackgroundAlgorithm
public void executeBackgroundAlgorithm()Starts new thread which executes the BackgroundAlgorithm and starts the progress bar -
reset
public void reset()Description copied from interface:Algorithm
Resets the internal state of the algorithm. -
getCategory
Description copied from interface:Algorithm
Returns the category an algorithm should assigned to. Return NULL if the algorithm should be sorted directly in the plugin menu.- Specified by:
getCategory
in interfaceAlgorithm
- Returns:
- The category an algorithm should assigned to.
-
getSetCategory
Description copied from interface:Algorithm
Returns a set of categories to classify this algorithm . e.g. return new HashSet(Arrays.asList( Category.GRAPH, Category.NODE )); is an algorithm, working on graphs and more specific on nodes - Specified by:
getSetCategory
in interfaceAlgorithm
- Returns:
- Set of Category Enums that classify this algorithm.
-
getMenuCategory
Description copied from interface:Algorithm
Returns a path to a menu category. This is s '.' separated string which reflects the position of this Algorithm in the Menu Hierarchy e.g. "Network.Layout" would put this algorithm in the menu 'Network' and its submenu 'Layout' If this menu is not existent it will be created If this method returns 'null' the algorithm will not appear in the menu- Specified by:
getMenuCategory
in interfaceAlgorithm
- Returns:
-
isLayoutAlgorithm
public boolean isLayoutAlgorithm()Description copied from interface:Algorithm
A LayoutAlgorithm should return true. All other types of algorithms should return false.- Specified by:
isLayoutAlgorithm
in interfaceAlgorithm
- Returns:
-
showMenuIcon
public boolean showMenuIcon()Description copied from interface:Algorithm
Override this method to give a different look and feel to the application, and to put the plugin icon next to the menu item in the main menu bar.- Specified by:
showMenuIcon
in interfaceAlgorithm
- Overrides:
showMenuIcon
in classThreadSafeAlgorithm
- Returns:
- True, if the plugin icon should be shown next to the menu item. Return FALSE (default!), if no icon should be shown in the menu.
-
getAcceleratorKeyStroke
Description copied from interface:Algorithm
Override this method to provide a accelerator hot key for the algorithm.- Specified by:
getAcceleratorKeyStroke
in interfaceAlgorithm
- Overrides:
getAcceleratorKeyStroke
in classThreadSafeAlgorithm
- Returns:
- NULL (default) if no accelerator should be assigned for this algorithm.
-
getDescription
- Specified by:
getDescription
in interfaceAlgorithm
-
setActionEvent
- Specified by:
setActionEvent
in interfaceAlgorithm
-
getActionEvent
- Specified by:
getActionEvent
in interfaceAlgorithm
-
mayWorkOnMultipleGraphs
public boolean mayWorkOnMultipleGraphs()- Specified by:
mayWorkOnMultipleGraphs
in interfaceAlgorithm
- Overrides:
mayWorkOnMultipleGraphs
in classThreadSafeAlgorithm
-
setControlInterface
See readme for context- Specified by:
setControlInterface
in classThreadSafeAlgorithm
- Parameters:
threadSafeOptions
-jc
-- Returns:
-
propertyChange
- Specified by:
propertyChange
in interfacePropertyChangeListener
-
sessionChanged
Description copied from interface:SessionListener
This method is called when the session changes.- Specified by:
sessionChanged
in interfaceSessionListener
- Parameters:
s
- the new Session.
-
sessionDataChanged
Description copied from interface:SessionListener
This method is called when the data (except the graph data) are changed.- Specified by:
sessionDataChanged
in interfaceSessionListener
-
executeThreadSafe
- Specified by:
executeThreadSafe
in classThreadSafeAlgorithm
-
resetDataCache
- Specified by:
resetDataCache
in classThreadSafeAlgorithm
-