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
FieldsModifier and TypeFieldDescriptionprotected intDeprecated.protected intDeprecated.uselastXReleased()protected intDeprecated.uselastYPressed()protected intDeprecated.uselastYReleased() -
Constructor Summary
ConstructorsConstructorDescriptionTLcdGXYDragRectangleController(boolean aRegisterInstance) Deprecated.use the constructor without parameters. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidadaptRectangle(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 voiddoPanGXYView(int aDeltaX, int aDeltaY) Performs the pan of thisILcdGXYControllerILcdGXYViewprotected voiddoZoomGXYView(double aDoubleFactor) Performs the zoom of thisILcdGXYControllerILcdGXYViewprotected voidDraws the given rectangle on aGraphics.intReturns the color of the dragged rectangle's halo.intReturns the dragged rectangle's halo thickness.intThis property defines the mouse dragged sensitivity.Returns the XOR mode color of the dragged rectangle.booleanbooleanbooleanReturns if the dragged rectangle is painted with a halo.booleanbooleanDeprecated.This method has been deprecated.booleanReturns if the dragged rectangle is drawn in XOR mode.intintintintvoidvoidmouseMoved(MouseEvent me) No operationvoidvoidvoidDraws a rectangle on the given graphics ifALcdGXYSmartController.isDragging()returns true and if the rectangle is larger asgetMouseDraggedSensitivity().voidsetDragCentered(boolean aDragCentered) voidsetForceToSquare(boolean aForceToSquare) voidsetGhostColor(Color aGhostColor) voidsetGhostLineWidth(int aGhostLineWidth) voidsetHaloColor(Color aColor) Sets the color of the dragged rectangle's halo.voidsetHaloEnabled(boolean aHaloEnabled) Sets if the dragged rectangle should be painted with a halo.voidsetHaloThickness(int aThickness) Sets the thickness of the dragged rectangle's halovoidsetMouseDraggedSensitivity(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.voidsetRepaintOnReleased(boolean aRepaintOnReleased) voidsetTraceOn(boolean aTraceOn) Deprecated.This method has been deprecated.voidsetXORMode(boolean aXORMode) Sets if the dragged rectangle should be drawn in XOR mode.voidsetXORModeColor(Color aXORModeColor) Sets the XOR mode color of the dragged rectangle.voidtrigger(MouseEvent aMouseEvent, Rectangle aRectangleDragged) This method is called on mouseReleased.voidundo()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, updateViewLocationAfterZoomSFCTMethods 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, viewRepaintMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.luciad.view.gxy.ILcdGXYController
getLayeredMethods 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 eithertrueorfalseas argument automatically turns off tracing for all other class instances for whichsetTraceOnhas not been called. If the argument isfalsethen only the informative, warning and error log messages are recorded.- Overrides:
setTraceOnin 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.Returnstrueif tracing is enabled for this class.- Overrides:
isTraceOnin 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
Colorof 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
TLcdGXYDragRectangleControllerforce 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, thisTLcdGXYDragRectangleControllerwill repaint theILcdGXYViewon 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.
falseif 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:
mouseMovedin interfaceMouseMotionListener- Overrides:
mouseMovedin classALcdGXYSmartController
-
doPanGXYView
protected void doPanGXYView(int aDeltaX, int aDeltaY) Description copied from class:ALcdGXYSmartControllerPerforms the pan of thisILcdGXYControllerILcdGXYView- Overrides:
doPanGXYViewin 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:ALcdGXYSmartControllerPerforms the zoom of thisILcdGXYControllerILcdGXYView- Overrides:
doZoomGXYViewin classALcdGXYSmartController- Parameters:
aDoubleFactor- zoom factor with which to multiply the view's scale
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener- Overrides:
mouseDraggedin 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:
paintin interfaceILcdGXYController- Overrides:
paintin classALcdGXYController- Parameters:
aGraphics- The graphics to draw on.
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener- Overrides:
mousePressedin 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:
mouseReleasedin interfaceMouseListener- Overrides:
mouseReleasedin 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- theMouseEventreceived on mouseReleased.aRectangleDragged- the dragged java.awt.Rectangle. Do not reuse this instance directly, make a copy instead.
-
undo
public void undo()
-
lastXPressed()