Interface MTCompleteModel

All Superinterfaces:
Comparable<MTNamedObject>, MTDataObject, MTHistoryEnabled, MTModel, MTModelHeader, MTNamedObject
All Known Subinterfaces:
MTCompleteSwimlaneModel

public interface MTCompleteModel extends MTModel
A completely loaded model. This can be obtained by calling loadCompleteModel() on a MTModelHeader. The methods does not require accessing the database. Note that the interface extends MTModel and that using the "find" methods in this interface will still access the database.
  • Method Details

    • getPluginData

      Object getPluginData(MTDataProvider provider)
      Returns the plugin data created for the model by a given provider. The returned object is transient and will only be kept for this model reference.
      Parameters:
      provider - The provider.
      Returns:
      The plugin data created by the provider.
    • setPluginData

      void setPluginData(MTDataProvider provider, Object data)
      Sets plugin data for a provider. This is automatically set to the object returned by the provider when the model is loaded, but the value can be overridden by the plugin at any time.
      Parameters:
      provider - The provider.
      data - The new data to store for the provider.
    • getVertices

      Returns the models vertices as a read-only collection.
      Returns:
      The models vertices.
      Since:
      3.0
    • getEdges

      Returns the models edges as a read-only collection.
      Returns:
      The models edges.
      Since:
      3.0
    • getSortedEdges

      List<MTCompleteEdge> getSortedEdges()
      Returns the models edges as a sorted list.
      Returns:
      The models edges.
      Since:
      3.0
    • getSymbols

      Returns the models symbols as a read-only collection.
      Returns:
      The models symbols.
      Since:
      3.0
    • getBounds

      Rectangle getBounds()
      Returns the bounds of the model.
      Returns:
      The model bounds.
      Since:
      3.0
    • getBounds

      default Rectangle getBounds(Collection<MTLayerTypeHeader> layers)
    • getLayerTypes

      Collection<MTLayerType> getLayerTypes()
      Returns the layer types available for this model, as a read-only collection.
      Returns:
      The available layer types.
    • getLayers

      Returns the models layers that currently exists for this model, sorted in ascending order. The returned collection is read-only.
      Returns:
      The models layers.
      Since:
      3.0
    • getDocuments

      List<MTDocument> getDocuments()
      Returns the documents connected to the model as a read-only list.
      Returns:
      The documents connected to the model.
      Since:
      3.0
    • getConnectedDocumentIDs

      default List<Document.DocumentID> getConnectedDocumentIDs()
    • findConnectedDocuments

      default List<Document> findConnectedDocuments()
      Finds the documents connected to the model as a read-only list.
      Returns:
      The found documents.
    • getConnectedDocuments

      @Deprecated(forRemoval=true) default List<Document> getConnectedDocuments()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Renamed to findConnectedDocuments() since this now loads the documents from the source and thus entails a cost and should be run on a background thread.
      Returns:
      Calls findConnectedDocuments()
    • getExtensionDocuments

      List<MTExtensionDocument> getExtensionDocuments(String provider)
      Returns the extension documents connected to the model. Changes made to the returned list will not write through to the internal representation in this complete model.
      Parameters:
      provider - The provider to get documents for.
      Returns:
      The extension documents connected to the model.
      Since:
      3.0
    • getExtensionDocumentProviders

      Set<String> getExtensionDocumentProviders()
      Returns the available providers of extension documents for this model.
      Returns:
      A list of provider strings.
    • createEdge

      MTCompleteEdge createEdge(String uuid, EdgeType type, EdgeRouter router, MTCompleteVertex from, MTCompleteVertex to, List<Point> points) throws MTAccessException
      Creates a new edge and adds it to the model. This method should called from a worker thread since it will create the edge in storage before returning.
      Parameters:
      uuid - The UUID of the edge
      type - The edge type.
      router - The edge router used to create a edge path for this edge
      from - The vertex the edge comes from
      to - The vertex the edge goes to
      points - The control points of the edge
      Returns:
      The vertex for the created symbol.
      Throws:
      MTAccessException
    • createEdge

      MTCompleteEdge createEdge(EdgeType type, EdgeRouter router, MTCompleteVertex from, MTCompleteVertex to, List<Point> points) throws MTAccessException
      Creates a new edge and adds it to the model. This method should called from a worker thread since it will create the edge in storage before returning.
      Parameters:
      type - The edge type.
      router - The edge router used to create a edge path for this edge
      from - The vertex the edge comes from
      to - The vertex the edge goes to
      points - The control points of the edge
      Returns:
      The vertex for the created symbol.
      Throws:
      MTAccessException
    • addSymbol

      MTCompleteVertex addSymbol(MTSymbol symbol, Point location) throws MTAccessException
      Adds an existing symbol to the model and returns a new MTCompleteVertex that will reference a symbol equal to the sent in symbol. Note that this means that vertex.getSymbol() == symbol might evaluate to false. However vertex.getSymbol().equals(symbol) will always return true.

      NOTE: The returned vertex will not be persisted. It is up to the caller to persist this object.
      Parameters:
      symbol - The symbol to add to the model.
      location - The location to place the resulting vertex at.
      Returns:
      The vertex for the added symbol.
      Throws:
      MTAccessException
    • addSymbol

      MTCompleteVertex addSymbol(MTSymbol symbol, Point location, String vertexUUID) throws MTAccessException
      Adds an existing symbol to the model and returns a new MTCompleteVertex that will reference a symbol equal to the sent in symbol. Note that this means that vertex.getSymbol() == symbol might evaluate to false. However vertex.getSymbol().equals(symbol) will always return true.

      NOTE: The returned vertex will not be persisted. It is up to the caller to persist this object.
      Parameters:
      symbol - The symbol to add to the model.
      location - The location to place the resulting vertex at.
      vertexUUID - The UUID of the created vertex for the symbol.
      Returns:
      The vertex for the added symbol.
      Throws:
      MTAccessException
    • insertVertex

      void insertVertex(MTCompleteVertex vertex)
      Inserts the vertex to this model. The vertex's getModel() will return this model after the call completes. Also, getVertices() will return a collection containing the vertex parameter.

      Parameters:
      vertex - The vertex to insert.
      Throws:
      IllegalArgumentException - if the vertex is already part of a different model, that is, if it already belongs to another model.
      NullPointerException - if the vertex parameter is null
    • insertEdge

      void insertEdge(MTCompleteEdge edge)
      Inserts the edge to this model. The edge's getModel() will return this model after the call completes. Also, getEdges() will return a collection containing the edge parameter.
      Parameters:
      edge - The edge to insert.
      Throws:
      IllegalStateException - if the edge is in an invalid state. An edge is in an invalid state if either its from or to vertex is null or if any of its from or to vertex does not belong to this model.
      IllegalArgumentException - if the edge is already part of a different model, that is, if it already belongs to another model.
      NullPointerException - if the edge parameter is null
    • addLayerType

      void addLayerType(MTLayerType layerType)
      Adds a layer type to this complete model instance.

      NOTE: This change will not be persisted. The effect is local to this instance only and future calls to save() will not take this change into account and no calls to save() will be performed on any layers or layer types. The new layer type might however be used to create new layers when inserting or adding new vertices - if the layer type states that vertices of that type should be in a layer of the specified layer type.
      Parameters:
      layerType - the layer type to add
    • removeLayerType

      void removeLayerType(MTLayerType layerType)
      Removes the layer type from this complete model instance.

      NOTE: This change will not be persisted. The effect is local to this instance only and future calls to save() will not take this change into account and no calls to remove() will be performed on any layers or layer types.
      Parameters:
      layerType - The layer type to be internally removed from this complete model.
    • moveVertexToLayerType

      void moveVertexToLayerType(MTCompleteVertex vertex, MTLayerType layerType)
      Moves a vertex to a layer in the model.
      Parameters:
      vertex - The vertex to move to a new layer.
      layerType - The type of the layer to move the vertex to.
      Throws:
      IllegalArgumentException - If the layer type does not belong to the model type of this model, or if the vertex does not belong to this model, or if the vertex was not created through this API.
    • getEditState

      MTEditState getEditState()
      Returns the "editable" state of the model when it was loaded from storage. This might have changed since then.
      Returns:
      The "editable" state of the model.
      Since:
      3.3
    • alignEdges

      void alignEdges(Collection<MTCompleteEdge> edges, boolean avoidObstacles)
      Aligns a set of edges in the model to each other. The edges will be aligned in groups by router type, and it is up to the router implementations to decide how to align the edges in the group.
      Parameters:
      edges - The edges to adjust.
      avoidObstacles - If true this should be considered as a hint by the edge router to try and avoid other objects in the model (such as other vertices and labels).