Interface MTEdge

All Superinterfaces:
Comparable<MTNamedObject>, MTEdgeHeader, MTHistoryEnabled, MTNamedObject
All Known Subinterfaces:
MTCompleteEdge

public interface MTEdge extends MTEdgeHeader, MTHistoryEnabled
Full interface for edges. An edge defines a relation between two symbols (represented by vertices) in a model. Graphically it is displayed as an arrow defined by a list of control points and with appearance according to the type of the relation.
Since:
3.0
  • Method Details

    • getLabelFont

      Font getLabelFont()
      Returns the font of the label text.
      Returns:
      The font of the label text.
      Since:
      3.0
    • getLabelColor

      Color getLabelColor()
      Returns the color of the label text.
      Returns:
      The color of the label text.
      Since:
      3.0
    • getLabelBounds

      Rectangle getLabelBounds()
      Returns the bounds of the label in the current language.
      Returns:
      The bounds of the label in the current language.
      Since:
      3.0
    • getLabelBounds

      Rectangle getLabelBounds(MTLanguageHeader lang)
      Returns the bounds of the label in a given language.
      Parameters:
      lang - The language.
      Returns:
      The bounds of the label in the language language.
      Since:
      3.0
    • isLabelAlongLine

      boolean isLabelAlongLine()
      Returns true if the label is aligned along the edge path line, false otherwise.
      Returns:
      true if the label is aligned along the edge path line, false otherwise.
      See Also:
    • setLabelAlongLine

      void setLabelAlongLine(boolean followLine)
      Sets the label alignment to follow the line (true) or not (false). What it means for the label to follow the line depends on the edge router of this edge, so no guarantees about behaviour can be made on part of this edge.
      Parameters:
      followLine - if true, the router will be asked to position and (possibly) rotate the label bounds so that the bounds follow the path of the edge.
    • getLanguages

      Collection<MTLanguage> getLanguages()
      Returns the currently available languages. This is a convenience method so that users of this object should not have to use a store to get the languages.
      Returns:
      the currently available languages.
    • getUserData

      @Deprecated(forRemoval=true) String getUserData(String uuid)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This API was created a long time ago and isn't currently used by anything. It also occupies a table in the database, so it would be nice if we could remove it at some point.
      Returns custom user data connected to this edge.
      Parameters:
      uuid - The uuid used when setting the custom data.
      Returns:
      The custom data set on this edge, identified by uuid.
      Since:
      3.0
    • getPath

      MTEdgePath getPath()
    • getEdgeRouter

      EdgeRouter getEdgeRouter()
      Returns the current edge router for the edge.
      Returns:
      the current edge router for the edge.
    • setEdgeRouter

      void setEdgeRouter(EdgeRouter router)
      Sets the edge router for this edge. The edge router is used internally by MTEdgePath to route edges by 'CRUD-ing' points and segments.
      Parameters:
      router - The router to use by this edge's MTEdgePath.
    • getEdgeRouterID

      default String getEdgeRouterID()
      Returns the edge router ID for the edge.
      Returns:
      the edge router ID for the edge.
    • getFrom

      MTVertexHeader getFrom()
      Retruns the vertex that starts the edge.
      Returns:
      The edge's start vertex.
      Since:
      3.0
    • getTo

      Returns the vertex that ends the edge.
      Returns:
      The edge's end vertex.
      Since:
      3.0
    • getBreakdownUUIDs

      Collection<String> getBreakdownUUIDs()
      Returns the UUID:s for all models that this edge breaks down to. The result does not take workspaces into account, so it is not guaranteed that all of the models exist in the current workspace.
      Returns:
      The UUID:s of all models that this edge breaks down to.
      Since:
      3.0
    • setBreakdownUUIDs

      void setBreakdownUUIDs(Collection<String> models)
      Sets the UUID:s for all models that this symbol breaks down to. The new breakdowns will be saved when the symbol is saved.
      Parameters:
      models - The models.
      Since:
      3.0
    • setTitle

      void setTitle(String title)
      Sets the label text in the current language.
      Parameters:
      title - The new label text.
      Since:
      3.0
    • setTitle

      void setTitle(MTLanguageHeader lang, String title)
      Sets the label text in a given language.
      Parameters:
      lang - The language.
      title - The title.
      Since:
      3.0
    • setType

      void setType(EdgeType type)
      Sets the type of the edge.
      Parameters:
      type - The new type.
      Since:
      3.3
    • setLabelFont

      void setLabelFont(Font font)
      Sets the font of the label text.
      Parameters:
      font - The new label font.
      Since:
      3.0
    • setLabelColor

      void setLabelColor(Color color)
      Sets the color of the label text.
      Parameters:
      color - The new color.
      Since:
      3.0
    • setLabelBounds

      void setLabelBounds(Rectangle bounds)
      Sets the bounds of the label in the current language.
      Parameters:
      bounds - The new bounds.
      Since:
      3.0
    • setLabelBounds

      void setLabelBounds(MTLanguageHeader language, Rectangle bounds)
      Sets the bounds of the label in a given language.
      Parameters:
      language - The language.
      bounds - The new bounds.
      Since:
      3.0
    • setUserData

      @Deprecated(forRemoval=true) void setUserData(String uuid, String data)
      Deprecated, for removal: This API element is subject to removal in a future version.
      This API was created a long time ago and isn't currently used by anything. It also occupies a table in the database, so it would be nice if we could remove it at some point.
      Stores custom user data on the edge.
      Parameters:
      uuid - An UUID to identify the data by.
      data - The data to store on the edge.
    • setTranslated

      void setTranslated(MTLanguage lang, boolean translated)
      Marks this edge as translated in the given language.
      Parameters:
      lang - The language.
      translated - The state.
      Since:
      3.1
    • setHideArrows

      void setHideArrows(boolean hideArrows)
      Sets whether the arrow(s) should be hidden for this edge.
      Parameters:
      hideArrows - true if arrows should not be drawn.
    • setStrokeColor

      void setStrokeColor(Color color)
      Sets the stroke color for the edge. This will only be used if the edge has a stroke set.
      Parameters:
      color - The new stroke color or @code{null}.
    • setStroke

      void setStroke(BasicStroke stroke)
      Sets the stroke for the edge. This will override any stroke settings specified in the currently used color scheme for this edge. It is up to the @code{Drawable} implementation used to draw the edge whether to use this stroke. There might be edge routers implemented where a stroke makes no sense when drawing the edge, in which this settings may be ignored.
      Parameters:
      stroke - The new stroke or @code{null} to specify that no specific stroke should be used for this edge.
    • setDefaultLabelBounds

      void setDefaultLabelBounds(MTLanguage language)
      Sets the label bounds of this edge to the default, based on the title and the current edge router. How the bounds of the title is calculated is implementation dependant and may depend on the current screen device and must depend on this edge's current font. Once the implementation has decided the bounds of the title, the result of this method should be equivalent to
       setLabelBounds(
            language,
            getEdgeRouter().getDefaultLabelBounds(titleBounds.getSize(), getPath().getControlPoints())
       );
       
      Parameters:
      language - The language to set the bounds for.
    • removeUserData

      void removeUserData(String uuid)
      Removes custom user data stored on the edge.
      Parameters:
      uuid - The UUID used to identify the data to remove.
      Since:
      3.0
    • queueSave

      void queueSave(MTRemoteChangeHandler errorHandler)
      Puts this edge on a save queue, making this call safe to do from the event dispatch thread.
      Parameters:
      errorHandler - an exception handler that is called if an exception is raised during save, or null to let the saving thread's own exception handler deal with an uncaught (wrapping) runtime exception.
    • prepareSave

      default MTEdit prepareSave(MTRemoteChangeHandler errorHandler)
      Prepares this edge for saving. The returned edit can be batched together with other edits that needs to be saved in a single transaction. These can later be queued for saving with MTStore.queueEdits().
      Parameters:
      errorHandler - an exception handler that is called if an exception is raised during save, or null to let the saving thread's own exception handler deal with an uncaught (wrapping) runtime exception.
      Returns:
      An edit that can be queued to save the changes to the edge.
    • save

      Saves a new edge or stores changes to an existing one.
      Throws:
      MTAccessException - If an MTAccessException occurs.
      MTRemoteChangeException - If an MTRemoteChangeException occurs.
      Since:
      3.0
    • isVisible

      boolean isVisible()
      Returns false for a non-visible edge such as an edge defining a relation within a swimlane.
      Returns:
      false for non-visible edges.
      Since:
      3.0
    • reverse

      void reverse()
      Reverses the direction of the edge by setting the "from" vertex as the "to" vertex and the other way around.