Class View

java.lang.Object
com.structurizr.view.View
Direct Known Subclasses:
DeploymentView, DynamicView, StaticView

public abstract class View
extends java.lang.Object
The superclass for all views (static views, dynamic views and deployment views).
  • Method Details

    • getModel

      public Model getModel()
      Gets the model that this view belongs to.
      Returns:
      a Model object
    • getSoftwareSystem

      public SoftwareSystem getSoftwareSystem()
      Gets the software system that this view is associated with.
      Returns:
      a SoftwareSystem object, or null if this view is not associated with a software system (e.g. it's a system landscape view)
    • getSoftwareSystemId

      public java.lang.String getSoftwareSystemId()
      Gets the ID of the software system this view is associated with.
      Returns:
      the ID, as a String, or null if this view is not associated with a software system (e.g. it's a system landscape view)
    • getDescription

      public java.lang.String getDescription()
      Gets the description of this view.
      Returns:
      the description, as a String
    • setDescription

      public void setDescription​(java.lang.String description)
    • getKey

      public java.lang.String getKey()
      Gets the identifier for this view.
      Returns:
      the identifier, as a String
    • getPaperSize

      public PaperSize getPaperSize()
      Gets the paper size that should be used to render this view.
      Returns:
      a PaperSize
    • setPaperSize

      public void setPaperSize​(PaperSize paperSize)
    • getAutomaticLayout

      public AutomaticLayout getAutomaticLayout()
      Gets the automatic layout settings for this view.
      Returns:
      an AutomaticLayout object, or null if not enabled
    • enableAutomaticLayout

      public void enableAutomaticLayout()
      Enables automatic layout for this view, with some default settings.
    • enableAutomaticLayout

      public void enableAutomaticLayout​(AutomaticLayout.RankDirection rankDirection, int rankSeparation, int nodeSeparation, int edgeSeparation, boolean vertices)
      Enables automatic layout for this view, with the specified settings, using the Dagre implementation.
      Parameters:
      rankDirection - the rank direction
      rankSeparation - the separation between ranks (in pixels, a positive integer)
      nodeSeparation - the separation between nodes within the same rank (in pixels, a positive integer)
      edgeSeparation - the separation between edges (in pixels, a positive integer)
      vertices - whether vertices should be created during automatic layout
    • enableAutomaticLayout

      public void enableAutomaticLayout​(AutomaticLayout.RankDirection rankDirection)
      Enables automatic layout for this view, with the specified direction, using the Graphviz implementation.
      Parameters:
      rankDirection - the rank direction
    • enableAutomaticLayout

      public void enableAutomaticLayout​(AutomaticLayout.RankDirection rankDirection, int rankSeparation, int nodeSeparation)
      Enables automatic layout for this view, with the specified settings, using the Graphviz implementation.
      Parameters:
      rankDirection - the rank direction
      rankSeparation - the separation between ranks (in pixels, a positive integer)
      nodeSeparation - the separation between nodes within the same rank (in pixels, a positive integer)
    • disableAutomaticLayout

      public void disableAutomaticLayout()
      Disables automatic layout for this view.
    • getTitle

      public java.lang.String getTitle()
      Gets the title of this view, if one has been set.
      Returns:
      the title, as a String
    • setTitle

      public void setTitle​(java.lang.String title)
      Sets the title for this view.
      Parameters:
      title - the title, as a String
    • getName

      public abstract java.lang.String getName()
      Gets the (computed) name of this view.
      Returns:
      the name, as a String
    • addElement

      protected final void addElement​(Element element, boolean addRelationships)
    • removeElement

      protected void removeElement​(Element element)
    • addRelationship

      protected RelationshipView addRelationship​(Relationship relationship)
    • isElementInView

      public boolean isElementInView​(Element element)
    • remove

      public void remove​(Relationship relationship)
      Removes a relationship from this view.
      Parameters:
      relationship - the Relationship to remove
    • removeRelationshipsNotConnectedToElement

      public void removeRelationshipsNotConnectedToElement​(Element element)
      Removes relationships that are not connected to the specified element.
      Parameters:
      element - the Element to test against
    • getElements

      public java.util.Set<ElementView> getElements()
      Gets the set of elements in this view.
      Returns:
      a Set of ElementView objects
    • getRelationships

      public java.util.Set<RelationshipView> getRelationships()
      Gets the set of relationships in this view.
      Returns:
      a Set of RelationshipView objects
    • removeElementsWithNoRelationships

      public void removeElementsWithNoRelationships()
      Removes all elements that have no relationships to other elements in this view.
    • setLayoutMergeStrategy

      public void setLayoutMergeStrategy​(LayoutMergeStrategy layoutMergeStrategy)
      Sets the strategy used for merging layout information (paper size, x/y positioning, etc) from one version of this view to another.
      Parameters:
      layoutMergeStrategy - an instance of LayoutMergeStrategy
    • getElementView

      public ElementView getElementView​(@Nonnull Element element)
      Gets the element view for the given element.
      Parameters:
      element - the Element to find the ElementView for
      Returns:
      an ElementView object, or null if the element doesn't exist in the view
    • getRelationshipView

      public RelationshipView getRelationshipView​(@Nonnull Relationship relationship)
      Gets the relationship view for the given relationship.
      Parameters:
      relationship - the Relationship to find the RelationshipView for
      Returns:
      an RelationshipView object, or null if the relationship doesn't exist in the view
    • getViewSet

      public ViewSet getViewSet()
      Gets the view set that this view belongs to.
      Returns:
      a ViewSet object
    • canBeRemoved

      protected abstract boolean canBeRemoved​(Element element)