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
Data for draggable renderable.
-
Field Summary
Fields inherited from interface org.opentrafficsim.base.geometry.OtsShape
DEFAULT_POLYGON_SEGMENTS, WORLD_MARGIN_LINE -
Constructor Summary
ConstructorsConstructorDescriptionDraggable(Point2d initialLocation, PolyLine2d annotation, UnaryOperator<Point2d> snapper, Function<Point2d, T> valueFunction, Consumer<T> valueWriter) Constructor. -
Method Summary
Modifier and TypeMethodDescriptiongetValue()Returns the current value based on the draggable location.doublegetZ()setDefaultValue(T defaultValue) Set default value (which is set after the user double clicks the draggable).setDeleter(Runnable deleter) Sets a deleter which deletes something in the data structure when the draggable is deleted by the user.setNode(XsdTreeNode node) Sets node of which this draggable affects the value.setNodeAttribute(XsdTreeNode node, String attribute) Sets node and attribute of the node of which this draggable affects the value.voidsetPointSnapped(Point2d mousePoint) Set the point based on mouse world coordinate.voidsetValue()Sets the value typically in anXsdTreeNode.voidWrites the default value.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.opentrafficsim.base.geometry.OtsShape
contains, contains, getAbsoluteBounds, getAbsoluteContour, getAbsoluteContour, getDirZ, signedDistance, signedDistance
-
Constructor Details
-
Draggable
public Draggable(Point2d initialLocation, PolyLine2d annotation, UnaryOperator<Point2d> snapper, Function<Point2d, T> valueFunction, Consumer<T> valueWriter) Constructor.- Parameters:
initialLocation- initial locationannotation- annotation shape around pointsnapper- logic to snap mouse world coordinate to world point of draggablevalueFunction- function that determines the value from the draggable pointvalueWriter- set the value typically in anXsdTreeNode
-
-
Method Details
-
setDefaultValue
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
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 valueattribute- attribute name- Returns:
- this, for method chaining
-
setDeleter
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
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 anXsdTreeNode. -
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 aXsdTreeNode). 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:
getZin interfacenl.tudelft.simulation.dsol.animation.Locatable
-
getLocation
- Specified by:
getLocationin interfacenl.tudelft.simulation.dsol.animation.Locatable- Specified by:
getLocationin interfaceOtsShape
-
getRelativeBounds
- Specified by:
getRelativeBoundsin interfacenl.tudelft.simulation.dsol.animation.Locatable- Specified by:
getRelativeBoundsin interfaceOtsShape
-
getRelativeContour
- Specified by:
getRelativeContourin interfaceOtsShape
-