Package org.graffiti.plugin.algorithm
Class AbstractAlgorithm
java.lang.Object
org.graffiti.plugin.algorithm.AbstractAlgorithm
- All Implemented Interfaces:
UndoableEdit
,Algorithm
- Direct Known Subclasses:
AbstractAnimatedAlgorithm
,AbstractEditorAlgorithm
,AbstractThreadSaveLayoutAlgorithm
,AddDiagramLegendAlgorithm
,AddInterestingAttributes
,AdditionalIdentifiersAlgorithm
,AddRandomClusterInformationAlgorithm
,AllPathsSelectionAlgorithm
,AlternativeIDannotationStatistics
,ArrayLayout
,BarabasiAlbertGraphGenerator
,BeanShellDesktopAlgorithm
,BringToFrontOrBackAlgorithm
,BundleParallelEdges
,CalculateAttribute
,CenterLayouterAlgorithm
,CircleLayouterAlgorithm
,CircleLayouterWithMinimumCrossingsAlgorithm
,CircleSearchAndLayoutAlgorithm
,ClearSelection
,ClusterGraphLayout
,ClusterHistogramFisherTest
,ClusterIndividualLayout
,ColorizeAlgorithm
,ColorizeSuperGraphAlgorithm
,ColorScaleLegendAlgorithm
,CombineMappingData
,ConnectedComponentLayout
,CopyDataTableAlgorithm
,CopyPatternLayoutAlgorithm
,CountCircularCrossingsAlgorithm
,CreateClusterGraphAlgorithm
,CreateDirectChildrenClustersHistogramAlgorithm
,CreateDistanceMatrixAlgorithm
,CreateFuncatGraphAlgorithm
,CreateGOchildrenAverageDataDiagramAlgorithm
,CreateGOchildrenClustersHistogramAlgorithm
,CreateGOchildrenTtestHistogramAlgorithm
,CreateGOtreeAlgorithm
,CreateKEGGOrthologyGraphAlgorithm
,CreateKeggReactionNetworkAlgorithm
,CreateOrgSpecificSuperGraphsAlgorithm
,DavidTestAlgorithm
,DeleteNodesAlgorithm
,DotLayoutAlgorithm
,EdgeRoutingAlgorithm
,EnrichHiddenLabelsAlgorithm
,ErdosRenyiGraphGenerator
,EvaluateKGML
,ExchangeNodePositionsAlgorithm
,ExpandReduceLayouterAlgorithm
,ExpandSelectionAlgorithm
,ExtractMappingDataAlgorithm
,FindReplaceDialog
,FishEyeLayout
,ForceDirectedEdgeLayout
,GraphTreeLayout
,GridLayoutAlgorithm
,GridLayouterAlgorithm
,GridPlacementAlgorithm
,GrubbsTestAlgorithm
,HammingDistanceAlgorithm
,HideOrShowChildNodes
,HierarchyAlgorithm
,HierarchyWizard
,ImageAssignmentCommand
,InterpreteGOtermsAlgorithm
,InterpreteParentGOtermsAlgorithm
,IntroduceBendsAlgorithm
,IntroduceParallelEdgeBends
,IntroduceSelfEdgeBends
,InverseGraphPluginAlgorithm
,InvertSelectionAlgorithm
,IterateGridPlacementLayout
,LinesToSubstancesAlgorithm
,MergeNodes
,MergeWindowsAlgorithm
,MultiDataView
,MultiTreeLayout
,NaivePatternFinderAlgorithm
,NoOverlappLayoutAlgorithm
,NoOverlappLayoutAlgorithmAS
,NoOverlappOfClustersAlgorithm
,NullLayoutAlgorithm
,NumberNodesAndEdgesAlgorithm
,PajekClusterColor
,PathwayReferenceAlgorithm
,PathwayReferenceAutoCreationAlgorithm
,PDFAlgorithm
,PDFSVGAlgorithm
,PngJpegAlgorithm
,PPTAlgorithm
,PrintAlgorithm
,PruneTreeAlgorithm
,RadialTreeLayout
,RandomLayouterAlgorithm
,RatioViewAlgorithm
,RecolorEdgesAlgorithm
,RemoveBendsAlgorithm
,RemoveHiddenLabelsAlgorithm
,RemoveMappingDataAlgorithm
,RemoveParenthesisLabels
,RemoveSelectedNodesPreserveEdgesAlgorithm
,ReplaceDiagramTitleFromAlternativeSubstanceNames
,ReplaceLabelAlgorithm
,ReplaceLabelFromAlternativeSubstanceNames
,ResizeFromMappingCountLayoutAlgorithm
,ResizeNodesDepDegreeAlgorithm
,RestoreLabelAlgorithm
,RTTreeLayout
,SelectCompoundsAlgorithm
,SelectEdgesAlgorithm
,SelectEnzymesAlgorithm
,SelectGenesAlgorithm
,SelectLeafNodesAlgorithm
,SelectMapNodesAlgorithm
,SelectMapTitleNodesAlgorithm
,SelectNodesWithExperimentalDataAlgorithm
,SelectReactionsAlgorithm
,SelectWindowsAlgorithm
,SetClusterInfoAlgorithm
,SetClusterInfoFromLabelAlgorithm
,SetClusterInfoFromSubgraphAlgorithm
,SetNumericAttributeFromDataAlgorithm
,SetToolTipAlgorithm
,SetURLAlgorithm
,ShortestPathSelectionAlgorithm
,ShowClusterGraphAlgorithm
,ShowOrHideImageAttributesAlgorithm
,ShowStatisticsTab
,SOMclusterAnalysis
,SOMclusterAnalysisDoCluster
,SOMprintDataset
,SortIntoCluster
,SplitNodeForSingleMappingData
,SpringEmbedderAlgorithm
,StartLayoutAlgorithm
,SubstanceRatioCalculationAlgorithm
,SVGAlgorithm
,TranspathPathwayLoader
,UserMappingAlgorithm
,WattsStrogatzGraphGenerator
,WeightedShortestPathSelectionAlgorithm
,WindowSettings
public abstract class AbstractAlgorithm extends Object implements Algorithm, UndoableEdit
Implements some empty versions of non-obligatory methods.
- Version:
- 2.0
- Recent revisions:
- 2.7.0 Default support for Undo, Redo.
-
Constructor Summary
Constructors Constructor Description AbstractAlgorithm()
-
Method Summary
Modifier and Type Method Description boolean
addEdit(UndoableEdit anEdit)
void
attach(Graph graph, Selection selection)
Attaches the given graph to this algorithm.boolean
canRedo()
boolean
canUndo()
void
check()
Checks whether all preconditions of the current graph are satisfied.void
die()
boolean
doesUndo()
Must returntrue
to allow Undo/Redo edits.KeyStroke
getAcceleratorKeyStroke()
Default: no accelerator for the menu item, created for this algorithm.ActionEvent
getActionEvent()
String
getCategory()
Returns the category an algorithm should assigned to.String
getDescription()
The algorithm description.String
getMenuCategory()
For backwards compatibility the standard implementation will return the CategoryParameter[]
getParameters()
Returns a list ofParameter
that are set for this algorithm.String
getPresentationName()
String
getRedoPresentationName()
Set<Category>
getSetCategory()
Returns a set of categories to classify this algorithm .String
getUndoPresentationName()
boolean
isAlwaysExecutable()
Indicates, if an algorithm is always executable - even without an active session.boolean
isLayoutAlgorithm()
A LayoutAlgorithm should return true.boolean
isSignificant()
Whether this UndoableEdit should be considered on its own for Undo/Redo, when performing any of them.void
markExecutionDone()
Marks the performed algorithm execution as done, so that the operation can later undo.void
markRedoDone()
Marks the performed algorithm redo as done, so that the operation can later undo.void
markUndoDone()
Marks the performed algorithm undo as done, so that the operation can later redo.boolean
mayWorkOnMultipleGraphs()
void
redo()
Default behaviour is to runexecute()
again.boolean
replaceEdit(UndoableEdit anEdit)
void
reset()
Resets the internal state of the algorithm.void
setActionEvent(ActionEvent a)
void
setParameters(Parameter[] params)
Sets the parameters for this algorithm.boolean
showMenuIcon()
Default: no icon next to the menu item, which is created for this algorithm.void
undo()
Extend with your Undo functionality.
-
Constructor Details
-
AbstractAlgorithm
public AbstractAlgorithm()
-
-
Method Details
-
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
- Parameters:
params
- Parameter array
-
getAcceleratorKeyStroke
Default: no accelerator for the menu item, created for this algorithm.- Specified by:
getAcceleratorKeyStroke
in interfaceAlgorithm
- Returns:
- NULL (default) if no accelerator should be assigned for this algorithm.
-
getDescription
The algorithm description.- Specified by:
getDescription
in interfaceAlgorithm
- Returns:
- String, could be HTML-styled.
-
showMenuIcon
public boolean showMenuIcon()Default: no icon next to the menu item, which is created for this algorithm.- Specified by:
showMenuIcon
in interfaceAlgorithm
- 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.
-
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
.
-
attach
Description copied from interface:Algorithm
Attaches the given graph to this algorithm. A ttaches the given Selection information to the algorithm. -
check
Description copied from interface:Algorithm
Checks whether all preconditions of the current graph are satisfied.- Specified by:
check
in interfaceAlgorithm
- Throws:
PreconditionException
-
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
For backwards compatibility the standard implementation will return the Category- Specified by:
getMenuCategory
in interfaceAlgorithm
- Returns:
-
reset
public void reset()Description copied from interface:Algorithm
Resets the internal state of the algorithm. -
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:
-
getActionEvent
- Specified by:
getActionEvent
in interfaceAlgorithm
-
setActionEvent
- Specified by:
setActionEvent
in interfaceAlgorithm
-
mayWorkOnMultipleGraphs
public boolean mayWorkOnMultipleGraphs()- Specified by:
mayWorkOnMultipleGraphs
in interfaceAlgorithm
-
isAlwaysExecutable
public boolean isAlwaysExecutable()Indicates, if an algorithm is always executable - even without an active session.- Returns:
- true, when there are no preconditions
-
doesUndo
public boolean doesUndo()Must return
Important: If you use GraphHelper for undoable edits or any other UndoableEdit tools, do NOT returntrue
to allow Undo/Redo edits.true
, as those are handled in that given class.- Returns:
false
by default, meaning the algorithm is not undoable
-
canUndo
public boolean canUndo()- Specified by:
canUndo
in interfaceUndoableEdit
-
canRedo
public boolean canRedo()- Specified by:
canRedo
in interfaceUndoableEdit
-
markExecutionDone
public void markExecutionDone()Marks the performed algorithm execution as done, so that the operation can later undo. -
markUndoDone
public void markUndoDone()Marks the performed algorithm undo as done, so that the operation can later redo. -
markRedoDone
public void markRedoDone()Marks the performed algorithm redo as done, so that the operation can later undo. -
die
public void die()- Specified by:
die
in interfaceUndoableEdit
-
getPresentationName
- Specified by:
getPresentationName
in interfaceUndoableEdit
-
getRedoPresentationName
- Specified by:
getRedoPresentationName
in interfaceUndoableEdit
-
getUndoPresentationName
- Specified by:
getUndoPresentationName
in interfaceUndoableEdit
-
isSignificant
public boolean isSignificant()Whether this UndoableEdit should be considered on its own for Undo/Redo, when performing any of them. Otherwise, it will get undone/redone once a significant edit takes place. Default is true, as all algorithms represent complex atomic actions.- Specified by:
isSignificant
in interfaceUndoableEdit
-
redo
Default behaviour is to run
If implementing, don't forget to callexecute()
again.super()
at the top of your implementation.- Specified by:
redo
in interfaceUndoableEdit
- Throws:
CannotRedoException
-
undo
Extend with your Undo functionality.
Don't forget to callsuper()
at the top of your implementation.- Specified by:
undo
in interfaceUndoableEdit
- Throws:
CannotUndoException
-
addEdit
- Specified by:
addEdit
in interfaceUndoableEdit
-
replaceEdit
- Specified by:
replaceEdit
in interfaceUndoableEdit
-