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 Details

    • AbstractAlgorithm

      public AbstractAlgorithm()
  • Method Details

    • setParameters

      public void setParameters​(Parameter[] params)
      Description copied from interface: Algorithm
      Sets the parameters for this algorithm. Must have the same types and order as the array returned by getParameter.
      Specified by:
      setParameters in interface Algorithm
      Parameters:
      params - Parameter array
    • getAcceleratorKeyStroke

      public KeyStroke getAcceleratorKeyStroke()
      Default: no accelerator for the menu item, created for this algorithm.
      Specified by:
      getAcceleratorKeyStroke in interface Algorithm
      Returns:
      NULL (default) if no accelerator should be assigned for this algorithm.
    • getDescription

      public String getDescription()
      The algorithm description.
      Specified by:
      getDescription in interface Algorithm
      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 interface Algorithm
      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

      public Parameter[] getParameters()
      Description copied from interface: Algorithm
      Returns a list of Parameter that are set for this algorithm.
      Specified by:
      getParameters in interface Algorithm
      Returns:
      a collection of Parameter that are needed by the Algorithm.
    • attach

      public void attach​(Graph graph, Selection selection)
      Description copied from interface: Algorithm
      Attaches the given graph to this algorithm. A ttaches the given Selection information to the algorithm.
      Specified by:
      attach in interface Algorithm
      Parameters:
      graph - the graph to attach.
      selection - the selection to attach.
    • check

      public void check() throws PreconditionException
      Description copied from interface: Algorithm
      Checks whether all preconditions of the current graph are satisfied.
      Specified by:
      check in interface Algorithm
      Throws:
      PreconditionException
    • getCategory

      public String 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 interface Algorithm
      Returns:
      The category an algorithm should assigned to.
    • getSetCategory

      public Set<Category> 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 interface Algorithm
      Returns:
      Set of Category Enums that classify this algorithm.
    • getMenuCategory

      public String getMenuCategory()
      For backwards compatibility the standard implementation will return the Category
      Specified by:
      getMenuCategory in interface Algorithm
      Returns:
    • reset

      public void reset()
      Description copied from interface: Algorithm
      Resets the internal state of the algorithm.
      Specified by:
      reset in interface 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 interface Algorithm
      Returns:
    • getActionEvent

      public ActionEvent getActionEvent()
      Specified by:
      getActionEvent in interface Algorithm
    • setActionEvent

      public void setActionEvent​(ActionEvent a)
      Specified by:
      setActionEvent in interface Algorithm
    • mayWorkOnMultipleGraphs

      public boolean mayWorkOnMultipleGraphs()
      Specified by:
      mayWorkOnMultipleGraphs in interface Algorithm
    • 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 true to allow Undo/Redo edits.

      Important: If you use GraphHelper for undoable edits or any other UndoableEdit tools, do NOT return 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 interface UndoableEdit
    • canRedo

      public boolean canRedo()
      Specified by:
      canRedo in interface UndoableEdit
    • 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 interface UndoableEdit
    • getPresentationName

      public String getPresentationName()
      Specified by:
      getPresentationName in interface UndoableEdit
    • getRedoPresentationName

      public String getRedoPresentationName()
      Specified by:
      getRedoPresentationName in interface UndoableEdit
    • getUndoPresentationName

      public String getUndoPresentationName()
      Specified by:
      getUndoPresentationName in interface UndoableEdit
    • 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 interface UndoableEdit
    • redo

      public void redo() throws CannotRedoException

      Default behaviour is to run execute() again.

      If implementing, don't forget to call super() at the top of your implementation.
      Specified by:
      redo in interface UndoableEdit
      Throws:
      CannotRedoException
    • undo

      public void undo() throws CannotUndoException

      Extend with your Undo functionality.

      Don't forget to call super() at the top of your implementation.
      Specified by:
      undo in interface UndoableEdit
      Throws:
      CannotUndoException
    • addEdit

      public boolean addEdit​(UndoableEdit anEdit)
      Specified by:
      addEdit in interface UndoableEdit
    • replaceEdit

      public boolean replaceEdit​(UndoableEdit anEdit)
      Specified by:
      replaceEdit in interface UndoableEdit