public class PortLocationModelParameterHandle extends Object implements IHandle
IHandle
that can be used to move an IPort
interactively by assigning new
IPortLocationModelParameter
s to the LocationParameter
.
This class also provides snapping facilities and can be used in conjunction with both
OrthogonalEdgeEditingContext
, as well as GraphSnapContext
.
Constructor and Description |
---|
PortLocationModelParameterHandle(IPort port)
Initializes a new instance of the
PortLocationModelParameterHandle class to change the IPortLocationModelParameter
of the given . |
Modifier and Type | Method and Description |
---|---|
void |
cancelDrag(IInputModeContext context,
PointD originalLocation)
Called by clients to indicate that the dragging has been canceled by the user.
|
protected void |
collectSnapResults(Object source,
CollectSnapResultsEventArgs args)
Called during the drag to collect snap results.
|
void |
dragFinished(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Called by clients to indicate that the repositioning has just been finished.
|
Cursor |
getCursor()
Gets the cursor to display when the mouse hovers over or drags this handle.
|
protected IGraph |
getGraph(IInputModeContext context)
Gets the graph to use for
setting the parameter
from the context. |
IPoint |
getLocation()
Returns a view of the location of the item.
|
protected MoveTypes |
getMoveType(IPort port)
Determines the type of the movement for the given port.
|
protected IPortLocationModelParameter |
getNewParameter(IPort port,
IPortLocationModel model,
PointD location)
Callback method that obtains the new parameter for the given location and port.
|
protected IPort |
getPort()
Gets the port this instance acts on.
|
HandleTypes |
getType()
Gets the type of the handle that can be used by the rendering engine to render types differently.
|
void |
handleMove(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Called by clients to indicate that the element has been dragged and its position should be updated.
|
void |
initializeDrag(IInputModeContext context)
Called by clients to indicate that the element is going to be dragged.
|
void |
setCursor(Cursor value)
Sets the cursor to display when the mouse hovers over or drags this handle.
|
protected void |
setParameter(IGraph graph,
IPort port,
IPortLocationModelParameter locationParameter)
Callback method that applies the parameter.
|
void |
setType(HandleTypes value)
Sets the type of the handle that can be used by the rendering engine to render types differently.
|
public PortLocationModelParameterHandle(IPort port)
PortLocationModelParameterHandle
class to change the IPortLocationModelParameter
of the given .port
port
- The port to adjust the location parameter of.public void cancelDrag(IInputModeContext context, PointD originalLocation)
IDragHandler
This method may be called after the initial IDragHandler.initializeDrag(IInputModeContext)
and zero or more invocations of
IDragHandler.handleMove(IInputModeContext, PointD, PointD)
. Implementations should reset the position of the items they
modify to their initial state. Alternatively to this method the IDragHandler.dragFinished(IInputModeContext, PointD, PointD)
method might be called.
cancelDrag
in interface IDragHandler
context
- The context to retrieve information about the drag from.originalLocation
- The value of the coordinate of the Location
property at the time of
IDragHandler.initializeDrag(IInputModeContext)
.protected void collectSnapResults(Object source, CollectSnapResultsEventArgs args)
This implementation will delegate to the IPortSnapResultProvider
that has been received from the port this
instance is bound to.
source
- The source of the event.args
- The CollectSnapResultsEventArgs
instance containing the event data.public void dragFinished(IInputModeContext context, PointD originalLocation, PointD newLocation)
IDragHandler
This method may be called after the initial IDragHandler.initializeDrag(IInputModeContext)
and zero or more invocations of
IDragHandler.handleMove(IInputModeContext, PointD, PointD)
. Alternatively to this method the IDragHandler.cancelDrag(IInputModeContext, PointD)
method might be called.
dragFinished
in interface IDragHandler
context
- The context to retrieve information about the drag from.originalLocation
- The value of the Location
property at the time of IDragHandler.initializeDrag(IInputModeContext)
.newLocation
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the
implementation the Location
may or may not be modified to reflect the new value. This is the same
value as delivered in the last invocation of IDragHandler.handleMove(IInputModeContext, PointD, PointD)
public final Cursor getCursor()
getCursor
in interface IHandle
setCursor(Cursor)
protected IGraph getGraph(IInputModeContext context)
setting the parameter
from the context.context
- The input mode context to use.null
if the graph could not be obtained.IInputModeContext.getGraph()
public final IPoint getLocation()
IDragHandler
The point describes the current world coordinate of the element that can be modified by this handler.
getLocation
in interface IDragHandler
protected MoveTypes getMoveType(IPort port)
This is used for the MovementInfo
that is passed to the OrthogonalEdgeEditingContext.addMovedPort(com.yworks.yfiles.view.input.MovementInfo)
method.
port
- The port to determine the move type for.MoveTypes.LINEAR_MOVE
for models of type FreeNodePortLocationModel
and MoveTypes.ARBITRARY_MOVE
for all others.protected IPortLocationModelParameter getNewParameter(IPort port, IPortLocationModel model, PointD location)
port
- The port to obtain a parameter for.model
- The model to use.location
- The new location.protected final IPort getPort()
public final HandleTypes getType()
getType
in interface IHandle
setType(HandleTypes)
public void handleMove(IInputModeContext context, PointD originalLocation, PointD newLocation)
IDragHandler
This method may be called more than once after an initial IDragHandler.initializeDrag(IInputModeContext)
and will the final
call will be followed by either one IDragHandler.dragFinished(IInputModeContext, PointD, PointD)
or one IDragHandler.cancelDrag(IInputModeContext, PointD)
call.
handleMove
in interface IDragHandler
context
- The context to retrieve information about the drag from.originalLocation
- The value of the Location
property at the time of IDragHandler.initializeDrag(IInputModeContext)
.newLocation
- The coordinates in the world coordinate system that the client wants the handle to be at. Depending on the
implementation the Location
may or may not be modified to reflect the new value.public void initializeDrag(IInputModeContext context)
IDragHandler
This call will be followed by one or more calls to IDragHandler.handleMove(IInputModeContext, PointD, PointD)
, and a final IDragHandler.dragFinished(IInputModeContext, PointD, PointD)
or IDragHandler.cancelDrag(IInputModeContext, PointD)
.
initializeDrag
in interface IDragHandler
context
- The context to retrieve information about the drag from.public final void setCursor(Cursor value)
value
- The cursor to display.getCursor()
protected void setParameter(IGraph graph, IPort port, IPortLocationModelParameter locationParameter)
graph
- The graph to use for applying.port
- The port to apply the parameter to.locationParameter
- The new parameter to apply.public final void setType(HandleTypes value)
value
- The type for rendering.getType()