Package com.luciad.view.gxy.controller
Class TLcdGXYDragRectangleController
java.lang.Object
com.luciad.view.gxy.controller.ALcdGXYController
com.luciad.view.gxy.controller.ALcdGXYSmartController
com.luciad.view.gxy.controller.TLcdGXYDragRectangleController
- All Implemented Interfaces:
ILcdUndoableSource
,ILcdStatusSource
,ILcdGXYController
,KeyListener
,MouseListener
,MouseMotionListener
,Serializable
,EventListener
- Direct Known Subclasses:
TLcdGXYSelectController
,TLcdGXYSelectController2
,TLcdGXYZoomController
public class TLcdGXYDragRectangleController
extends ALcdGXYSmartController
implements MouseListener, MouseMotionListener
This is an
ILcdGXYController
that interprets mouse events
for dragging a rectangle on a ILcdGXYView
. Redefine trigger
for implementing specific behavior with the "created" java.awt.Rectangle
given as argument.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
Deprecated.protected int
Deprecated.uselastXReleased()
protected int
Deprecated.uselastYPressed()
protected int
Deprecated.uselastYReleased()
-
Constructor Summary
ConstructorDescriptionTLcdGXYDragRectangleController
(boolean aRegisterInstance) Deprecated.use the constructor without parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
adaptRectangle
(MouseEvent me, int aXPressed, int aYPressed) Adapts the rectangle to span the area that is marked by the coordinates the location of the mouse, and another position taking into account the properties forceToSquare and dragCentered.protected void
doPanGXYView
(int aDeltaX, int aDeltaY) Performs the pan of thisILcdGXYController
ILcdGXYView
protected void
doZoomGXYView
(double aDoubleFactor) Performs the zoom of thisILcdGXYController
ILcdGXYView
protected void
Draws the given rectangle on aGraphics.int
Returns the color of the dragged rectangle's halo.int
Returns the dragged rectangle's halo thickness.int
This property defines the mouse dragged sensitivity.Returns the XOR mode color of the dragged rectangle.boolean
boolean
boolean
Returns if the dragged rectangle is painted with a halo.boolean
boolean
Deprecated.This method has been deprecated.boolean
Returns if the dragged rectangle is drawn in XOR mode.int
int
int
int
void
void
mouseMoved
(MouseEvent me) No operationvoid
void
void
Draws a rectangle on the given graphics ifALcdGXYSmartController.isDragging()
returns true and if the rectangle is larger asgetMouseDraggedSensitivity()
.void
setDragCentered
(boolean aDragCentered) void
setForceToSquare
(boolean aForceToSquare) void
setGhostColor
(Color aGhostColor) void
setGhostLineWidth
(int aGhostLineWidth) void
setHaloColor
(Color aColor) Sets the color of the dragged rectangle's halo.void
setHaloEnabled
(boolean aHaloEnabled) Sets if the dragged rectangle should be painted with a halo.void
setHaloThickness
(int aThickness) Sets the thickness of the dragged rectangle's halovoid
setMouseDraggedSensitivity
(int aMouseDraggedSensitivity) Sets the minimal width or height that a user needs to drag the mouse before the rectangle is taken into account for painting.void
setRepaintOnReleased
(boolean aRepaintOnReleased) void
setTraceOn
(boolean aTraceOn) Deprecated.This method has been deprecated.void
setXORMode
(boolean aXORMode) Sets if the dragged rectangle should be drawn in XOR mode.void
setXORModeColor
(Color aXORModeColor) Sets the XOR mode color of the dragged rectangle.void
trigger
(MouseEvent aMouseEvent, Rectangle aRectangleDragged) This method is called on mouseReleased.void
undo()
Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYSmartController
addUndoableListener, fireUndoableEvent, getDownPanChars, getDownPanCodes, getLeftPanChars, getLeftPanCodes, getPanAbsDelta, getPanAbsDelta, getRightPanChars, getRightPanCodes, getUndoableListenerCount, getUpPanChars, getUpPanCodes, getZoomInChars, getZoomInCodes, getZoomOutChars, getZoomOutCodes, isDragging, isPanOnMouseDragExit, isPanOnMouseMoveExit, isPanUndoable, isRequestFocusOnMouseEntered, isRequestFocusOnMousePressed, isZoomUndoable, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, removeUndoableListener, setDownPanChars, setDownPanCodes, setIsDragging, setLeftPanChars, setLeftPanCodes, setPanAbsDelta, setPanOnMouseDragExit, setPanOnMouseMoveExit, setPanUndoable, setRequestFocusOnMouseEntered, setRequestFocusOnMousePressed, setRightPanChars, setRightPanCodes, setUpPanChars, setUpPanCodes, setZoomInChars, setZoomInCodes, setZoomOutChars, setZoomOutCodes, setZoomUndoable, startInteraction, terminateInteraction, updateViewLocationAfterZoomSFCT
Methods inherited from class com.luciad.view.gxy.controller.ALcdGXYController
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, viewRepaint
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.view.gxy.ILcdGXYController
getLayered
Methods inherited from interface java.awt.event.MouseListener
mouseClicked, mouseEntered, mouseExited
-
Field Details
-
fXPressed
Deprecated.uselastXPressed()
-
fYPressed
Deprecated.uselastYPressed()
-
fXReleased
Deprecated.uselastXReleased()
-
fYReleased
Deprecated.uselastYReleased()
-
-
Constructor Details
-
TLcdGXYDragRectangleController
public TLcdGXYDragRectangleController() -
TLcdGXYDragRectangleController
public TLcdGXYDragRectangleController(boolean aRegisterInstance) Deprecated.use the constructor without parameters.
-
-
Method Details
-
setTraceOn
public void setTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Enables tracing for this class instance. Calling this method with eithertrue
orfalse
as argument automatically turns off tracing for all other class instances for whichsetTraceOn
has not been called. If the argument isfalse
then only the informative, warning and error log messages are recorded.- Overrides:
setTraceOn
in classALcdGXYSmartController
- Parameters:
aTraceOn
- if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
-
isTraceOn
public boolean isTraceOn()Deprecated.This method has been deprecated. It is recommended to use the standard Java logging framework directly.Returnstrue
if tracing is enabled for this class.- Overrides:
isTraceOn
in classALcdGXYSmartController
- Returns:
- true if tracing is enabled for this class, false otherwise.
-
setGhostLineWidth
public void setGhostLineWidth(int aGhostLineWidth) - Parameters:
aGhostLineWidth
- the line width of the dragged rectangle
-
getGhostLineWidth
public int getGhostLineWidth()- See Also:
-
setGhostColor
- Parameters:
aGhostColor
- the Color of the dragged rectangle
-
getGhostColor
- Returns:
- the
Color
of the dragged rectangle.
-
setForceToSquare
public void setForceToSquare(boolean aForceToSquare) - Parameters:
aForceToSquare
- if true, force the rectangle to be a square.
-
isForceToSquare
public boolean isForceToSquare()- Returns:
- true, if this
TLcdGXYDragRectangleController
force the rectangle to be a square. Default value if false.
-
setDragCentered
public void setDragCentered(boolean aDragCentered) - Parameters:
aDragCentered
- if true, the center of the dragged rectangle will stay where the mouse has been pressed. If false, it will be at the center of the rectangle defined by where the mouse has been pressed, and it current location. Default value if true.
-
isDragCentered
public boolean isDragCentered()- See Also:
-
setRepaintOnReleased
public void setRepaintOnReleased(boolean aRepaintOnReleased) - Parameters:
aRepaintOnReleased
- if true, thisTLcdGXYDragRectangleController
will repaint theILcdGXYView
on mouseReleased. Default if true.
-
isRepaintOnReleased
public boolean isRepaintOnReleased()- See Also:
-
setXORMode
public void setXORMode(boolean aXORMode) Sets if the dragged rectangle should be drawn in XOR mode.- Parameters:
aXORMode
- if true, the dragged rectangle is drawn in XORMode. If false, the rectangle is drawn using the graphics' paint mode.
-
isXORMode
public boolean isXORMode()Returns if the dragged rectangle is drawn in XOR mode.- Returns:
- true if the dragged rectangle is drawn in XORMode.
false
if the rectangle is drawn using the graphics' paint mode. - See Also:
-
setXORModeColor
Sets the XOR mode color of the dragged rectangle. Only applies to the XOR mode.- Parameters:
aXORModeColor
- the new color to use- See Also:
-
getXORModelColor
Returns the XOR mode color of the dragged rectangle. Only applies to the XOR mode.- Returns:
- the XOR mode color of the dragged rectangle
- See Also:
-
isHaloEnabled
public boolean isHaloEnabled()Returns if the dragged rectangle is painted with a halo.- Returns:
- true if the dragged rectangle is painted with a halo
- See Also:
-
setHaloEnabled
public void setHaloEnabled(boolean aHaloEnabled) Sets if the dragged rectangle should be painted with a halo. A halo is an outline of constant width and color around shapes or text, which is typically drawn in a contrasting color to ensure that the shapes or text are clearly visible on any background.
Note that the halo functionality cannot be combined with XOR mode painting.- Parameters:
aHaloEnabled
- if true, the dragged rectangle is drawn with a halo- See Also:
-
getHaloColor
Returns the color of the dragged rectangle's halo.- Returns:
- the color of the dragged rectangle's halo
- See Also:
-
setHaloColor
Sets the color of the dragged rectangle's halo.- Parameters:
aColor
- the new halo color to use. If the halo is enabled, the dragged rectangle will be outlined on both sides using this color.- See Also:
-
getHaloThickness
public int getHaloThickness()Returns the dragged rectangle's halo thickness.- Returns:
- the current halo thickness in pixels
- See Also:
-
setHaloThickness
public void setHaloThickness(int aThickness) Sets the thickness of the dragged rectangle's halo- Parameters:
aThickness
- the new halo thickness in pixels
-
getCurrentRectangle
- Returns:
- the current dragged rectangle as a java.awt.Rectangle Do not attempt to keep reference of or change the returned Rectangle. Make a copy if necessary.
-
getMouseDraggedSensitivity
public int getMouseDraggedSensitivity()This property defines the mouse dragged sensitivity. When a rectangle is dragged with a height or width smaller than the mouse pressed sensitivity it is not taken into account for painting. Note thattrigger(java.awt.event.MouseEvent, java.awt.Rectangle)
is invoked, regardless the sensitivity.- See Also:
-
setMouseDraggedSensitivity
public void setMouseDraggedSensitivity(int aMouseDraggedSensitivity) Sets the minimal width or height that a user needs to drag the mouse before the rectangle is taken into account for painting. Note thattrigger(java.awt.event.MouseEvent, java.awt.Rectangle)
is invoked, regardless the sensitivity.- Parameters:
aMouseDraggedSensitivity
- The new sensitivity, in pixels.- See Also:
-
drawGhost
Draws the given rectangle on aGraphics. Can be redefined. -
mouseMoved
No operation- Specified by:
mouseMoved
in interfaceMouseMotionListener
- Overrides:
mouseMoved
in classALcdGXYSmartController
-
doPanGXYView
protected void doPanGXYView(int aDeltaX, int aDeltaY) Description copied from class:ALcdGXYSmartController
Performs the pan of thisILcdGXYController
ILcdGXYView
- Overrides:
doPanGXYView
in classALcdGXYSmartController
- Parameters:
aDeltaX
- delta along the X axis, in AWT pixelsaDeltaY
- delta along the Y axis, in AWT pixels
-
doZoomGXYView
protected void doZoomGXYView(double aDoubleFactor) Description copied from class:ALcdGXYSmartController
Performs the zoom of thisILcdGXYController
ILcdGXYView
- Overrides:
doZoomGXYView
in classALcdGXYSmartController
- Parameters:
aDoubleFactor
- zoom factor with which to multiply the view's scale
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
- Overrides:
mouseDragged
in classALcdGXYSmartController
-
adaptRectangle
Adapts the rectangle to span the area that is marked by the coordinates the location of the mouse, and another position taking into account the properties forceToSquare and dragCentered.- Parameters:
me
-aXPressed
-aYPressed
-
-
paint
Draws a rectangle on the given graphics ifALcdGXYSmartController.isDragging()
returns true and if the rectangle is larger asgetMouseDraggedSensitivity()
.- Specified by:
paint
in interfaceILcdGXYController
- Overrides:
paint
in classALcdGXYController
- Parameters:
aGraphics
- The graphics to draw on.
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
- Overrides:
mousePressed
in classALcdGXYSmartController
-
lastXPressed
public int lastXPressed()- Returns:
- the x coordinate where the last mousePressed occurred. This value is only valid between a mousePressed and a following mouseReleased. Then it is set to -1.
-
lastYPressed
public int lastYPressed()- Returns:
- the y coordinate where the last mousePressed occurred. This value is only valid between a mousePressed and a following mouseReleased. Then it is set to -1.
-
lastXReleased
public int lastXReleased()- Returns:
- the x coordinate where the last mouseReleased occurred. This value is only valid between a mouseReleased and a following mousePressed. Then it is set to -1.
-
lastYReleased
public int lastYReleased()- Returns:
- the y coordinate where the last mouseReleased occurred. This value is only valid between a mouseReleased and a following mousePressed. Then it is set to -1.
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
- Overrides:
mouseReleased
in classALcdGXYSmartController
-
trigger
This method is called on mouseReleased. It can be redefined to implement specific behavior with the "created" java.awt.Rectangle given as argument. Extensions might want to verify if the given rectangle is larger as the drag sensitivity, e.g.:aRectangleDragged.width >= getMouseDraggedSensitivity() || aRectangleDragged.height >= getMouseDraggedSensitivity()
- Parameters:
aMouseEvent
- theMouseEvent
received on mouseReleased.aRectangleDragged
- the dragged java.awt.Rectangle. Do not reuse this instance directly, make a copy instead.
-
undo
public void undo()
-
lastXPressed()