public class RectangleHandle extends Object implements IMutablePoint, IHandle
IHandle
implementation that modifies a rectangle.
Implementations of this class work on a mutable rectangle instance for handling drags of the handle. A separate point
implementation is used for specifying the position of the handle. As a convenience this class also implements the IMutablePoint
interface which modifies the handle's position.
Constructor and Description |
---|
RectangleHandle(HandlePositions position,
IMutableRectangle rectangle)
Subclass constructor that creates a handle for the given position using the location instance as the
Location
for the handle. |
Modifier and Type | Method and Description |
---|---|
void |
cancelDrag(IInputModeContext context,
PointD originalLocation)
Delegates the original values to
set(double, double) . |
void |
dragFinished(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
This implementation does nothing.
|
Cursor |
getCursor()
Gets the cursor to display when the mouse hovers over or drags this handle.
|
IPoint |
getLocation()
Returns a view of the center of the handle.
|
ISize |
getMaximumSize()
Gets the maximum size allowed for the reshapeable.
|
IRectangle |
getMinimumEnclosedArea()
Gets the minimum enclosed area that needs to be encompassed by this reshapeable.
|
ISize |
getMinimumSize()
Gets the minimum size allowed for the reshapeable.
|
protected HandlePositions |
getPosition()
The position of the handle.
|
protected IMutableRectangle |
getRectangle()
The rectangle instance to modify.
|
HandleTypes |
getType()
Gets the type of the handle that can be used by the rendering engine to render types differently.
|
double |
getX()
Gets the x coordinate.
|
double |
getY()
Gets the y coordinate.
|
void |
handleMove(IInputModeContext context,
PointD originalLocation,
PointD newLocation)
Delegates to
set(double, double) . |
void |
initializeDrag(IInputModeContext context)
This implementation does nothing.
|
void |
moveBy(PointD delta)
Delegates the work to the reshapeable.
|
void |
set(double x,
double y)
Delegates to
moveBy(PointD) . |
void |
setCursor(Cursor value)
Sets the cursor to display when the mouse hovers over or drags this handle.
|
void |
setMaximumSize(ISize value)
Sets the maximum size allowed for the reshapeable.
|
void |
setMinimumEnclosedArea(IRectangle value)
Sets the minimum enclosed area that needs to be encompassed by this reshapeable.
|
void |
setMinimumSize(ISize value)
Sets the minimum size allowed for the reshapeable.
|
void |
setType(HandleTypes value)
Sets the type of the handle that can be used by the rendering engine to render types differently.
|
void |
setX(double value)
Sets the x coordinate.
|
void |
setY(double value)
Sets the y coordinate.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
relocate, relocate, relocate
distanceTo, toPointD
public RectangleHandle(HandlePositions position, IMutableRectangle rectangle)
Location
for the handle.
The instance modifies the instances using the reshapeable interface and reads the current state using the rect. The handle will automatically trim changes of the rectangle to the specified minimum and maximum size.
position
- The position of the handle.rectangle
- The rectangle to change.public void cancelDrag(IInputModeContext context, PointD originalLocation)
set(double, double)
.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)
.public void dragFinished(IInputModeContext context, PointD originalLocation, PointD newLocation)
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)
public final IPoint getLocation()
The point describes the current world coordinate of the element that can be modified by this handle.
getLocation
in interface IDragHandler
public final ISize getMaximumSize()
The value is stored by reference. The default is SizeD.INFINITE
.
setMaximumSize(ISize)
public final IRectangle getMinimumEnclosedArea()
The value is stored by reference. The default is SizeD.ZERO
, which does not restrict the area at all.
setMinimumEnclosedArea(IRectangle)
public final ISize getMinimumSize()
The value is stored by reference. The default is SizeD.ZERO
.
setMinimumSize(ISize)
protected final HandlePositions getPosition()
protected final IMutableRectangle getRectangle()
public final HandleTypes getType()
getType
in interface IHandle
setType(HandleTypes)
public final double getX()
The setter delegates to moveBy(PointD)
getX
in interface IMutablePoint
getX
in interface IPoint
setX(double)
public final double getY()
The setter delegates to moveBy(PointD)
getY
in interface IMutablePoint
getY
in interface IPoint
setY(double)
public void handleMove(IInputModeContext context, PointD originalLocation, PointD newLocation)
set(double, double)
.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)
initializeDrag
in interface IDragHandler
context
- The context to retrieve information about the drag from.public void moveBy(PointD delta)
public void set(double x, double y)
moveBy(PointD)
.public final void setCursor(Cursor value)
value
- The Cursor to set.getCursor()
public final void setMaximumSize(ISize value)
The value is stored by reference. The default is SizeD.INFINITE
.
value
- The MaximumSize to set.getMaximumSize()
public final void setMinimumEnclosedArea(IRectangle value)
The value is stored by reference. The default is SizeD.ZERO
, which does not restrict the area at all.
value
- The MinimumEnclosedArea to set.getMinimumEnclosedArea()
public final void setMinimumSize(ISize value)
The value is stored by reference. The default is SizeD.ZERO
.
value
- The MinimumSize to set.getMinimumSize()
public final void setType(HandleTypes value)
value
- The Type to set.getType()
public final void setX(double value)
The setter delegates to moveBy(PointD)
setX
in interface IMutablePoint
value
- The X to set.getX()
public final void setY(double value)
The setter delegates to moveBy(PointD)
setY
in interface IMutablePoint
value
- The Y to set.getY()