public interface AlgorithmPlugin extends RTEListener
PluginHost
.
AlgorithmRTE
.
Build Path -> Add to Build Path
). Finally create your plugin class and implement AlgorithmPlugin
.LanguageFile
s it is recommended to update the text file encoding parameter of your
plugin project. In Eclipse you have to go to Project -> Properties -> Resources
enable Other
and select
the corresponding encoding that is used in your text files. LanguageFile
uses UTF-8
by default but it is also
possible to specify another charset.LanguageFile
or in your project properties!
File -> Export... -> Java > JAR file
. If you use external
libraries except the lavesdk-x.x.jar you should ensure that you integrate this libraries into the JAR file (e.g. by using a subfolder
\lib that contains all the external libraries).
Sandbox
which provides a GUI for the basic functionality
of the algorithm.
onCreate(ViewContainer, PropertiesListModel)
is invoked to load the content of the plugin and initialize a new visualization. By onClose()
the plugin is notified when
the user deactivates the plugin meaning that another plugin is activated.RTEListener.beforeStart(lavesdk.algorithm.RTEvent)
/
RTEListener.beforeResume(lavesdk.algorithm.RTEvent)
/RTEListener.beforePause(lavesdk.algorithm.RTEvent)
/RTEListener.onStop()
). By way of example
the beforeStart-event could be used to check if a vertex is selected in a GraphView
and if not the start is canceled or something like that.
AlgorithmRTE
,
Sandbox
,
Validator
Modifier and Type | Method and Description |
---|---|
void |
applyCustomization(PropertiesListModel plm)
Applys the customization to the plugin.
|
java.lang.String |
getAssumptions()
Gets the assumptions of the algorithm or method.
|
java.lang.String |
getAuthor()
Gets the author of the plugin.
|
java.lang.String |
getAuthorContact()
Gets the author contact details of the plugin.
|
Configuration |
getConfiguration()
Gets the current configuration of the plugin.
|
java.lang.String |
getDescription()
Gets the description of the algorithm or method.
|
java.lang.String |
getInstructions()
Gets the instructions of the plugin.
|
java.lang.String |
getName()
Gets the name of the algorithm or method.
|
javax.swing.filechooser.FileNameExtensionFilter[] |
getOpenFileFilters()
Gets the open file filters for the plugin.
|
java.lang.String |
getProblemAffiliation()
Gets the affiliation of the problem the plugin is intended to solve or the algorithm relates to.
|
AlgorithmRTE |
getRuntimeEnvironment()
Gets the runtime environment of the algorithm.
|
javax.swing.filechooser.FileNameExtensionFilter[] |
getSaveFileFilters()
Gets the save file filters for the plugin.
|
java.lang.String |
getSubject()
Gets the subject in which the algorithm is applied.
|
AlgorithmText |
getText()
Gets the text of the algorithm that is represented by this plugin.
|
ToolBarExtension[] |
getToolBarExtensions()
Gets the toolbar extensions of the plugin.
|
java.lang.String |
getType()
Gets the type of the algorithm or method meaning for example whether the algorithm is exact, a heuristic or something like that.
|
LAVESDKV |
getUsedSDKVersion()
Gets the version of the LAVESDK that this plugin uses.
|
java.lang.String |
getVersion()
Gets the version of the plugin.
|
boolean |
hasCreatorPreferences()
Indicates whether the plugin has creator preferences.
|
boolean |
hasCustomization()
Indicates whether the plugin provides customization meaning that the user can customize the plugin.
|
boolean |
hasExerciseMode()
Indicates whether the plugin has an exercise mode meaning that
AlgorithmExercise s have been assigned to AlgorithmStep s
of the algorithm. |
void |
initialize(PluginHost host,
ResourceLoader resLoader,
Configuration config)
Initializes the plugin and is called once before the plugin is used.
|
void |
loadCreatorPreferences(PropertiesListModel plm)
Loads the creator preferences of the plugin.
|
void |
loadCustomization(PropertiesListModel plm)
Loads the customization of the plugin.
|
void |
onClose()
Indicates that the plugin is closed/disabled which means that it is no longer active in the host application.
|
void |
onCreate(ViewContainer container,
PropertiesListModel creatorPreferences)
Indicates that the plugin is activated in the host application by the user to visualize/create a
new instance of the algorithm.
|
void |
open(java.io.File file)
Opens the plugin content.
|
void |
save(java.io.File file)
Saves the plugin content.
|
beforePause, beforeResume, beforeStart, onPause, onRunning, onStop
void initialize(PluginHost host, ResourceLoader resLoader, Configuration config)
host
- PluginHost
, this is the interface to the host application and gives access to communicationresLoader
- the resource loader of the plugin that must be used to load resource files from within the plugin JARconfig
- the configuration of the plugin or null
if there is no configuration available for the pluginjava.lang.String getName()
LanguageFile
and PluginHost.getLanguageID()
to return a language dependent
name.final LanguageFile myLangFile = new LanguageFile("langFile.txt"); ... public String getName() { return LanguageFile.getLabel(myLangFile, "ALGORITHM_NAME", host.getLanguageID(), "My Algorithm Name"); } ...
java.lang.String getDescription()
LanguageFile
and PluginHost.getLanguageID()
to return a language dependent
description.final LanguageFile myLangFile = new LanguageFile("langFile.txt"); ... public String getDescription() { return LanguageFile.getLabel(myLangFile, "ALGORITHM_DESC", host.getLanguageID(), "My Algorithm Description"); } ...
java.lang.String getType()
LanguageFile
and PluginHost.getLanguageID()
to return a language dependent
algorithm type.final LanguageFile myLangFile = new LanguageFile("langFile.txt"); ... public String getType() { return LanguageFile.getLabel(myLangFile, "ALGORITHM_TYPE", host.getLanguageID(), "Heuristic"); } ...
java.lang.String getAuthor()
java.lang.String getAuthorContact()
java.lang.String getAssumptions()
LanguageFile
and PluginHost.getLanguageID()
to return a language dependent
assumption.final LanguageFile myLangFile = new LanguageFile("langFile.txt");
... public String getAssumptions() { return LanguageFile.getLabel(myLangFile, "ASSUMPTIONS", host.getLanguageID(), "A simple, non-negative weighted, connected graph."); } ...
java.lang.String getProblemAffiliation()
LanguageFile
and PluginHost.getLanguageID()
to return a language dependent
problem affiliation.final LanguageFile myLangFile = new LanguageFile("langFile.txt");
... public String getProblemAffiliation() { return LanguageFile.getLabel(myLangFile, "PROBLEMAFFILIATION", host.getLanguageID(), "Shortest path problem"); } ...
java.lang.String getSubject()
LanguageFile
and PluginHost.getLanguageID()
to return a language dependent subject.final LanguageFile myLangFile = new LanguageFile("langFile.txt"); ... public String getSubject() { return LanguageFile.getLabel(myLangFile, "SUBJECT", host.getLanguageID(), "Logistics"); } ...
java.lang.String getInstructions()
LanguageFile
and PluginHost.getLanguageID()
to return language dependent instructions.final LanguageFile myLangFile = new LanguageFile("langFile.txt"); ... public String getInstructions() { return LanguageFile.getLabel(myLangFile, "INSTRUCTIONS", host.getLanguageID(), "Do this, do not that!"); } ...
java.lang.String getVersion()
LAVESDKV getUsedSDKVersion()
LAVESDKV.CURRENT
like
adding System.out.println("LAVESDKV=" + LAVESDKV.CURRENT);
to a runnable snippet of code and execute it to read
the version information from the console.new LAVESDKV(1, 0);
AlgorithmRTE getRuntimeEnvironment()
AlgorithmRTE
and return your implementation here.null
if the plugin does not have a runtime environmentAlgorithmText getText()
AlgorithmText.getBaseCopy()
so that the text
may not be changed externally.null
if the plugin does not have an algorithm textboolean hasExerciseMode()
AlgorithmExercise
s have been assigned to AlgorithmStep
s
of the algorithm.
AlgorithmExercise
for each AlgorithmStep
of the algorithm. During the execution the user has to solve these exercises. The exercise mode is fully
automatic so you do not need more to do than defining AlgorithmExercise
s. Additionally the user has not the possibility to pause the
algorithm or to switch to the previous or next step during the exercise because the exercise mode is handled fully automatic by the
runtime environment.true
if the plugin has an interactive exercise mode otherwise false
Configuration getConfiguration()
null
if the plugin does not have a configurationboolean hasCreatorPreferences()
... public void loadCreatorPreferences(PropertiesListModel plm) { final BooleanPropertyGroup bpg = new BooleanPropertyGroup(list); plm.add(new BooleanProperty("directed", "Apply the algorithm to a directed graph.", bpg)); plm.add(new BooleanProperty("undirected", "Apply the algorithm to an undirected graph.", bpg)); ... } ...
true
if the plugin has creator preferences otherwise false
loadCreatorPreferences(PropertiesListModel)
void loadCreatorPreferences(PropertiesListModel plm)
... public void loadCreatorPreferences(PropertiesListModel plm) { final BooleanPropertyGroup bpg = new BooleanPropertyGroup(list); plm.add(new BooleanProperty("directed", "Apply the algorithm to a directed graph.", bpg)); plm.add(new BooleanProperty("undirected", "Apply the algorithm to an undirected graph.", bpg)); ... } ...
plm
- the properties list model in which the creator preferences can be loadedvoid onCreate(ViewContainer container, PropertiesListModel creatorPreferences)
ViewGroup
s to group views together. All views of a group are separated by a sash. The sash
can be used by the user to change the sizes of the views in a group.ViewGroup.restoreWeights(lavesdk.serialization.Serializer, String, float[])
.
AlgorithmTextView
to visualize an AlgorithmText
, a GraphView
to visualize graph data structures, a MatrixView
to visualize matrices and so on. If there is no suitable view you can create your own by extending View
.
container
- the container in which the views are displayedcreatorPreferences
- the properties list model that contains the creator preferences of the plugin or null
if there are currently no creator preferences available (although the plugin has creator preferences)View
,
ViewGroup
,
AlgorithmTextView
,
GraphView
,
ExecutionTableView
,
LegendView
,
hasCreatorPreferences()
void onClose()
boolean hasCustomization()
Property
s where each one of them describes a customizable point.Configuration
.AlgorithmTextView
(and so on...):
... public void loadCustomization(PropertiesListModel plm) { // create a property for the highlight foreground color and load the current highlight // foreground color from the configuration final Property highlightFG = new ColorProperty("highlight foreground", "changes the highlight foreground color in the algorithm text view", config.getColor("highlightFG")); // add the property to the properties list model plm.add(highlightFG); } ... public void applyCustomization(PropertiesListModel plm) { // get the highlight foreground color property from the model final ColorProperty highlightFG = plm.getColorProperty("highlightFG"); // apply data to the algorithm text view of the plugin and to the configuration if(highlightFG != null) { config.addColor("highlightFG", highlightFG.getValue()); algoTextView.setHighlightForeground(highlightFG.getValue()); } } ...
true
if the plugin has a customization otherwise false
(meaning that the user cannot customize the plugin)getConfiguration()
void loadCustomization(PropertiesListModel plm)
hasCustomization()
returns true
.
Property
s where each one of them describes a customizable point.Configuration
.AlgorithmTextView
(and so on...):
... public void loadCustomization(PropertiesListModel plm) { // create a property for the highlight foreground color and load the current highlight // foreground color from the configuration final Property highlightFG = new ColorProperty("highlight foreground", "changes the highlight foreground color in the algorithm text view", config.getColor("highlightFG")); // add the property to the properties list model plm.add(highlightFG); } ... public void applyCustomization(PropertiesListModel plm) { // get the highlight foreground color property from the model final ColorProperty highlightFG = plm.getColorProperty("highlightFG"); // apply data to the algorithm text view of the plugin and to the configuration if(highlightFG != null) { config.addColor("highlightFG", highlightFG.getValue()); algoTextView.setHighlightForeground(highlightFG.getValue()); } } ...
plm
- the properties list model in which the the customization properties can be loadedgetConfiguration()
,
hasCustomization()
void applyCustomization(PropertiesListModel plm)
hasCustomization()
returns true
.
Property
s where each one of them describes a customizable point.Configuration
.AlgorithmTextView
(and so on...):
... public void loadCustomization(PropertiesListModel plm) { // create a property for the highlight foreground color and load the current highlight // foreground color from the configuration final Property highlightFG = new ColorProperty("highlight foreground", "changes the highlight foreground color in the algorithm text view", config.getColor("highlightFG")); // add the property to the properties list model plm.add(highlightFG); } ... public void applyCustomization(PropertiesListModel plm) { // get the highlight foreground color property from the model final ColorProperty highlightFG = plm.getColorProperty("highlightFG"); // apply data to the algorithm text view of the plugin and to the configuration if(highlightFG != null) { config.addColor("highlightFG", highlightFG.getValue()); algoTextView.setHighlightForeground(highlightFG.getValue()); } } ...
plm
- the properties list model in which the the customization properties can be loadedgetConfiguration()
,
hasCustomization()
ToolBarExtension[] getToolBarExtensions()
null
if the plugin has no extensionsToolBarExtension
,
CircleLayoutToolBarExtension
,
BipartiteGraphToolBarExtension
,
CompleteGraphToolBarExtension
,
CompleteBipartiteGraphToolBarExtension
void save(java.io.File file)
getSaveFileFilters()
returns valid filters.final FileNameExtensionFilter vgfFilter = new FileNameExtensionFilter("Visual Graph File (*.vgf)", "vgf"); final FileNameExtensionFilter pngFilter = new FileNameExtensionFilter("Portable Network Graphics (*.png)", "png"); ... public void save(File file) { // use file filters to check the file if(vgfFilter.accept(file)) saveAsVGF(...); else if(pngFilter.accept(file)) saveAsPNG(...); ... // or use the extension to check the file if(file.getAbsolutePath().toLowerCase().endsWith(".vgf")) saveAsVGF(...); else if(file.getAbsolutePath().toLowerCase().endsWith(".png")) saveAsPNG(...); ... }
file
- the filevoid open(java.io.File file)
getOpenFileFilters()
returns valid filters.final FileNameExtensionFilter vgfFilter = new FileNameExtensionFilter("Visual Graph File (*.vgf)", "vgf"); final FileNameExtensionFilter pngFilter = new FileNameExtensionFilter("Portable Network Graphics (*.png)", "png"); ... public void open(File file) { // use file filters to check the file if(vgfFilter.accept(file)) openVGF(...); else if(pngFilter.accept(file)) openPNG(...); ... // or use the extension to check the file if(file.getAbsolutePath().toLowerCase().endsWith(".vgf")) openVGF(...); else if(file.getAbsolutePath().toLowerCase().endsWith(".png")) openPNG(...); ... }
file
- the filejavax.swing.filechooser.FileNameExtensionFilter[] getSaveFileFilters()
javax.swing.filechooser.FileNameExtensionFilter[] getOpenFileFilters()