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 booleanaddEdit(UndoableEdit anEdit)voidattach(Graph graph, Selection selection)Attaches the given graph to this algorithm.booleancanRedo()booleancanUndo()voidcheck()Checks whether all preconditions of the current graph are satisfied.voiddie()booleandoesUndo()Must returntrueto allow Undo/Redo edits.KeyStrokegetAcceleratorKeyStroke()Default: no accelerator for the menu item, created for this algorithm.ActionEventgetActionEvent()StringgetCategory()Returns the category an algorithm should assigned to.StringgetDescription()The algorithm description.StringgetMenuCategory()For backwards compatibility the standard implementation will return the CategoryParameter[]getParameters()Returns a list ofParameterthat are set for this algorithm.StringgetPresentationName()StringgetRedoPresentationName()Set<Category>getSetCategory()Returns a set of categories to classify this algorithm .StringgetUndoPresentationName()booleanisAlwaysExecutable()Indicates, if an algorithm is always executable - even without an active session.booleanisLayoutAlgorithm()A LayoutAlgorithm should return true.booleanisSignificant()Whether this UndoableEdit should be considered on its own for Undo/Redo, when performing any of them.voidmarkExecutionDone()Marks the performed algorithm execution as done, so that the operation can later undo.voidmarkRedoDone()Marks the performed algorithm redo as done, so that the operation can later undo.voidmarkUndoDone()Marks the performed algorithm undo as done, so that the operation can later redo.booleanmayWorkOnMultipleGraphs()voidredo()Default behaviour is to runexecute()again.booleanreplaceEdit(UndoableEdit anEdit)voidreset()Resets the internal state of the algorithm.voidsetActionEvent(ActionEvent a)voidsetParameters(Parameter[] params)Sets the parameters for this algorithm.booleanshowMenuIcon()Default: no icon next to the menu item, which is created for this algorithm.voidundo()Extend with your Undo functionality.
-
Constructor Details
-
AbstractAlgorithm
public AbstractAlgorithm()
-
-
Method Details
-
setParameters
Description copied from interface:AlgorithmSets the parameters for this algorithm. Must have the same types and order as the array returned bygetParameter.- Specified by:
setParametersin interfaceAlgorithm- Parameters:
params- Parameter array
-
getAcceleratorKeyStroke
Default: no accelerator for the menu item, created for this algorithm.- Specified by:
getAcceleratorKeyStrokein interfaceAlgorithm- Returns:
- NULL (default) if no accelerator should be assigned for this algorithm.
-
getDescription
The algorithm description.- Specified by:
getDescriptionin 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:
showMenuIconin 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:AlgorithmReturns a list ofParameterthat are set for this algorithm.- Specified by:
getParametersin interfaceAlgorithm- Returns:
- a collection of
Parameterthat are needed by theAlgorithm.
-
attach
Description copied from interface:AlgorithmAttaches the given graph to this algorithm. A ttaches the given Selection information to the algorithm. -
check
Description copied from interface:AlgorithmChecks whether all preconditions of the current graph are satisfied.- Specified by:
checkin interfaceAlgorithm- Throws:
PreconditionException
-
getCategory
Description copied from interface:AlgorithmReturns the category an algorithm should assigned to. Return NULL if the algorithm should be sorted directly in the plugin menu.- Specified by:
getCategoryin interfaceAlgorithm- Returns:
- The category an algorithm should assigned to.
-
getSetCategory
Description copied from interface:AlgorithmReturns 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:
getSetCategoryin interfaceAlgorithm- Returns:
- Set of Category Enums that classify this algorithm.
-
getMenuCategory
For backwards compatibility the standard implementation will return the Category- Specified by:
getMenuCategoryin interfaceAlgorithm- Returns:
-
reset
public void reset()Description copied from interface:AlgorithmResets the internal state of the algorithm. -
isLayoutAlgorithm
public boolean isLayoutAlgorithm()Description copied from interface:AlgorithmA LayoutAlgorithm should return true. All other types of algorithms should return false.- Specified by:
isLayoutAlgorithmin interfaceAlgorithm- Returns:
-
getActionEvent
- Specified by:
getActionEventin interfaceAlgorithm
-
setActionEvent
- Specified by:
setActionEventin interfaceAlgorithm
-
mayWorkOnMultipleGraphs
public boolean mayWorkOnMultipleGraphs()- Specified by:
mayWorkOnMultipleGraphsin 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 returntrueto allow Undo/Redo edits.true, as those are handled in that given class.- Returns:
falseby default, meaning the algorithm is not undoable
-
canUndo
public boolean canUndo()- Specified by:
canUndoin interfaceUndoableEdit
-
canRedo
public boolean canRedo()- Specified by:
canRedoin 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:
diein interfaceUndoableEdit
-
getPresentationName
- Specified by:
getPresentationNamein interfaceUndoableEdit
-
getRedoPresentationName
- Specified by:
getRedoPresentationNamein interfaceUndoableEdit
-
getUndoPresentationName
- Specified by:
getUndoPresentationNamein 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:
isSignificantin interfaceUndoableEdit
-
redo
Default behaviour is to run
If implementing, don't forget to callexecute()again.super()at the top of your implementation.- Specified by:
redoin interfaceUndoableEdit- Throws:
CannotRedoException
-
undo
Extend with your Undo functionality.
Don't forget to callsuper()at the top of your implementation.- Specified by:
undoin interfaceUndoableEdit- Throws:
CannotUndoException
-
addEdit
- Specified by:
addEditin interfaceUndoableEdit
-
replaceEdit
- Specified by:
replaceEditin interfaceUndoableEdit
-