Class ModelView

java.lang.Object
com.structurizr.view.View
com.structurizr.view.ModelView
All Implemented Interfaces:
PropertyHolder
Direct Known Subclasses:
CustomView, DeploymentView, DynamicView, StaticView

public abstract class ModelView extends View
The superclass for all views that show elements/relationships from the model, namely: - System landscape views - System context views - Container views - Dynamic views - 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 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)
    • 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)
    • getDimensions

      public Dimensions getDimensions()
    • setDimensions

      public void setDimensions(Dimensions dimensions)
    • 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.
    • getMergeFromRemote

      public boolean getMergeFromRemote()
      Gets whether layout information for this view should be merged from a remote version of the workspace.
      Returns:
      true if layout information should be merged from the remote workspace, false otherwise
    • setMergeFromRemote

      public void setMergeFromRemote(boolean mergeFromRemote)
      Specifies whether layout information for this view should be merged from a remote version of the workspace.
      Parameters:
      mergeFromRemote - true if layout information should be merged from the remote workspace, false otherwise
    • addElement

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

      protected abstract void checkElementCanBeAdded(Element element)
    • 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 Set<ElementView> getElements()
      Gets the set of elements in this view.
      Returns:
      a Set of ElementView objects
    • getRelationships

      public 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:
      a 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.
      Overrides:
      getViewSet in class View
      Returns:
      a ViewSet object
    • canBeRemoved

      protected abstract boolean canBeRemoved(Element element)
    • addNearestNeighbours

      protected <T extends Element> void addNearestNeighbours(Element element, Class<T> typeOfElement)