Class DraggableAnnotation.Draggable<T>

java.lang.Object
org.opentrafficsim.editor.extensions.map.edit.DraggableAnnotation.Draggable<T>
Type Parameters:
T - value type that the draggable sets
All Implemented Interfaces:
nl.tudelft.simulation.dsol.animation.Locatable, OtsShape
Enclosing class:
DraggableAnnotation

public static class DraggableAnnotation.Draggable<T> extends Object implements OtsShape
Data for draggable renderable.
  • Constructor Details

    • Draggable

      public Draggable(Point2d initialLocation, PolyLine2d annotation, UnaryOperator<Point2d> snapper, Function<Point2d,T> valueFunction, Consumer<T> valueWriter)
      Constructor.
      Parameters:
      initialLocation - initial location
      annotation - annotation shape around point
      snapper - logic to snap mouse world coordinate to world point of draggable
      valueFunction - function that determines the value from the draggable point
      valueWriter - set the value typically in an XsdTreeNode
  • Method Details

    • setDefaultValue

      public DraggableAnnotation.Draggable<T> setDefaultValue(T defaultValue)
      Set default value (which is set after the user double clicks the draggable).
      Parameters:
      defaultValue - default value
      Returns:
      this, for method chaining
    • setNode

      Sets node of which this draggable affects the value. This is for display purposes (shift-click draggable to show in tree).
      Parameters:
      node - node of which this draggable affects the value
      Returns:
      this, for method chaining
    • setNodeAttribute

      public DraggableAnnotation.Draggable<T> setNodeAttribute(XsdTreeNode node, String attribute)
      Sets node and attribute of the node of which this draggable affects the value. This is for display purposes (shift-click draggable to show in tree).
      Parameters:
      node - node of which this draggable affects an attribute value
      attribute - attribute name
      Returns:
      this, for method chaining
    • setDeleter

      public DraggableAnnotation.Draggable<T> setDeleter(Runnable deleter)
      Sets a deleter which deletes something in the data structure when the draggable is deleted by the user.
      Parameters:
      deleter - deletes something in the data structure
      Returns:
      this, for method chaining
    • writeDefaultValue

      public void writeDefaultValue()
      Writes the default value.
    • setPointSnapped

      public void setPointSnapped(Point2d mousePoint)
      Set the point based on mouse world coordinate. Also updates the internal draggable value, but not the value in the data tree.
      Parameters:
      mousePoint - mouse world coordinate
    • setValue

      public void setValue()
      Sets the value typically in an XsdTreeNode.
    • getValue

      public T getValue()
      Returns the current value based on the draggable location. That can be regarded as a continuous and temporary value that is coupled to the live location of the draggable. This live value may be, and likely is, inconsistent with the current value in the data structure (e.g. value in a XsdTreeNode). The live value is intended to be used by live visual aides that indicate to the user what the draggable location will result in. For example, a dashed line indicating a new centerline.
      Returns:
      current value based on the draggable location
    • getZ

      public double getZ()
      Specified by:
      getZ in interface nl.tudelft.simulation.dsol.animation.Locatable
    • getLocation

      public DirectedPoint2d getLocation()
      Specified by:
      getLocation in interface nl.tudelft.simulation.dsol.animation.Locatable
      Specified by:
      getLocation in interface OtsShape
    • getRelativeBounds

      public Bounds2d getRelativeBounds()
      Specified by:
      getRelativeBounds in interface nl.tudelft.simulation.dsol.animation.Locatable
      Specified by:
      getRelativeBounds in interface OtsShape
    • getRelativeContour

      public Polygon2d getRelativeContour()
      Specified by:
      getRelativeContour in interface OtsShape