public class TLcdGXYDragRectangleController extends ALcdGXYSmartController implements MouseListener, MouseMotionListener
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.Modifier and Type | Field and Description |
---|---|
protected int |
fXPressed
Deprecated.
use
lastXPressed() |
protected int |
fXReleased
Deprecated.
use
lastXReleased() |
protected int |
fYPressed
Deprecated.
use
lastYPressed() |
protected int |
fYReleased
Deprecated.
use
lastYReleased() |
Constructor and Description |
---|
TLcdGXYDragRectangleController() |
TLcdGXYDragRectangleController(boolean aRegisterInstance)
Deprecated.
use the constructor without parameters.
|
Modifier and Type | Method and Description |
---|---|
protected 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 this
ILcdGXYController
ILcdGXYView |
protected void |
doZoomGXYView(double aDoubleFactor)
Performs the zoom of this
ILcdGXYController
ILcdGXYView |
protected void |
drawGhost(int aX,
int aY,
int aWidth,
int aHeight,
Graphics aGraphics)
Draws the given rectangle on aGraphics.
|
Rectangle |
getCurrentRectangle() |
Color |
getGhostColor() |
int |
getGhostLineWidth() |
Color |
getHaloColor()
Returns the color of the dragged rectangle's halo.
|
int |
getHaloThickness()
Returns the dragged rectangle's halo thickness.
|
int |
getMouseDraggedSensitivity()
This property defines the mouse dragged sensitivity.
|
Color |
getXORModelColor()
Returns the XOR mode color of the dragged rectangle.
|
boolean |
isDragCentered() |
boolean |
isForceToSquare() |
boolean |
isHaloEnabled()
Returns if the dragged rectangle is painted with a halo.
|
boolean |
isRepaintOnReleased() |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isXORMode()
Returns if the dragged rectangle is drawn in XOR mode.
|
int |
lastXPressed() |
int |
lastXReleased() |
int |
lastYPressed() |
int |
lastYReleased() |
void |
mouseDragged(MouseEvent me) |
void |
mouseMoved(MouseEvent me)
No operation
|
void |
mousePressed(MouseEvent me) |
void |
mouseReleased(MouseEvent me) |
void |
paint(Graphics aGraphics)
Draws a rectangle on the given graphics if
ALcdGXYSmartController.isDragging() returns true and
if the rectangle is larger as getMouseDraggedSensitivity() . |
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 halo
|
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.
|
void |
setRepaintOnReleased(boolean aRepaintOnReleased) |
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
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() |
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
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription, viewRepaint
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
mouseClicked, mouseEntered, mouseExited
getLayered
@Deprecated protected int fXPressed
lastXPressed()
@Deprecated protected int fYPressed
lastYPressed()
@Deprecated protected int fXReleased
lastXReleased()
@Deprecated protected int fYReleased
lastYReleased()
public TLcdGXYDragRectangleController()
public TLcdGXYDragRectangleController(boolean aRegisterInstance)
public void setTraceOn(boolean aTraceOn)
true
or false
as argument automatically turns
off tracing for all other class instances for which
setTraceOn
has not been called.
If the argument is false
then only the informative, warning
and error log messages are recorded.setTraceOn
in class ALcdGXYSmartController
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.public boolean isTraceOn()
true
if tracing is enabled for this class.isTraceOn
in class ALcdGXYSmartController
public void setGhostLineWidth(int aGhostLineWidth)
aGhostLineWidth
- the line width of the dragged rectanglepublic int getGhostLineWidth()
setGhostLineWidth(int)
public void setGhostColor(Color aGhostColor)
aGhostColor
- the Color of the dragged rectanglepublic Color getGhostColor()
Color
of the dragged rectangle.public void setForceToSquare(boolean aForceToSquare)
aForceToSquare
- if true, force the rectangle to be a square.public boolean isForceToSquare()
TLcdGXYDragRectangleController
force the
rectangle to be a square. Default value if false.public void setDragCentered(boolean aDragCentered)
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.public boolean isDragCentered()
setDragCentered(boolean)
public void setRepaintOnReleased(boolean aRepaintOnReleased)
aRepaintOnReleased
- if true, this TLcdGXYDragRectangleController
will repaint the ILcdGXYView
on mouseReleased. Default if
true.public boolean isRepaintOnReleased()
setRepaintOnReleased(boolean)
public void setXORMode(boolean aXORMode)
aXORMode
- if true, the dragged rectangle is drawn in XORMode. If false, the rectangle is drawn using the
graphics' paint mode.public boolean isXORMode()
false
if the rectangle is drawn using the
graphics' paint mode.setXORMode(boolean)
public void setXORModeColor(Color aXORModeColor)
aXORModeColor
- the new color to usegetXORModelColor()
,
setXORMode(boolean)
public Color getXORModelColor()
setXORModeColor(java.awt.Color)
public boolean isHaloEnabled()
setHaloEnabled(boolean)
public void setHaloEnabled(boolean aHaloEnabled)
aHaloEnabled
- if true, the dragged rectangle is drawn with a haloisHaloEnabled()
,
setHaloColor(java.awt.Color)
,
setHaloThickness(int)
,
setXORMode(boolean)
public Color getHaloColor()
isHaloEnabled()
public void setHaloColor(Color aColor)
aColor
- the new halo color to use. If the halo is enabled, the dragged rectangle will be outlined on
both sides using this color.isHaloEnabled()
public int getHaloThickness()
setHaloThickness(int)
public void setHaloThickness(int aThickness)
aThickness
- the new halo thickness in pixelspublic Rectangle getCurrentRectangle()
public int getMouseDraggedSensitivity()
trigger(java.awt.event.MouseEvent, java.awt.Rectangle)
is invoked,
regardless the sensitivity.The current sensitivity, in pixels.
public void setMouseDraggedSensitivity(int aMouseDraggedSensitivity)
trigger(java.awt.event.MouseEvent, java.awt.Rectangle)
is invoked,
regardless the sensitivity.aMouseDraggedSensitivity
- The new sensitivity, in pixels.getMouseDraggedSensitivity()
protected void drawGhost(int aX, int aY, int aWidth, int aHeight, Graphics aGraphics)
public void mouseMoved(MouseEvent me)
mouseMoved
in interface MouseMotionListener
mouseMoved
in class ALcdGXYSmartController
protected void doPanGXYView(int aDeltaX, int aDeltaY)
ALcdGXYSmartController
ILcdGXYController
ILcdGXYView
doPanGXYView
in class ALcdGXYSmartController
aDeltaX
- delta along the X axis, in AWT pixelsaDeltaY
- delta along the Y axis, in AWT pixelsprotected void doZoomGXYView(double aDoubleFactor)
ALcdGXYSmartController
ILcdGXYController
ILcdGXYView
doZoomGXYView
in class ALcdGXYSmartController
aDoubleFactor
- zoom factor with which to multiply the view's scalepublic void mouseDragged(MouseEvent me)
mouseDragged
in interface MouseMotionListener
mouseDragged
in class ALcdGXYSmartController
protected void adaptRectangle(MouseEvent me, int aXPressed, int aYPressed)
me
- aXPressed
- aYPressed
- public void paint(Graphics aGraphics)
ALcdGXYSmartController.isDragging()
returns true and
if the rectangle is larger as getMouseDraggedSensitivity()
.paint
in interface ILcdGXYController
paint
in class ALcdGXYController
aGraphics
- The graphics to draw on.public void mousePressed(MouseEvent me)
mousePressed
in interface MouseListener
mousePressed
in class ALcdGXYSmartController
public int lastXPressed()
public int lastYPressed()
public int lastXReleased()
public int lastYReleased()
public void mouseReleased(MouseEvent me)
mouseReleased
in interface MouseListener
mouseReleased
in class ALcdGXYSmartController
public void trigger(MouseEvent aMouseEvent, Rectangle aRectangleDragged)
aRectangleDragged.width >= getMouseDraggedSensitivity() ||
aRectangleDragged.height >= getMouseDraggedSensitivity()
aMouseEvent
- the MouseEvent
received on mouseReleased.aRectangleDragged
- the dragged java.awt.Rectangle. Do not reuse
this instance directly, make a copy instead.public void undo()