public class TLcdGXYMagnifierController extends ALcdGXYSmartController
MagnifierController
is an ILcdGXYController
to magnify an area of a given ILcdGXYView
around the location where a mouse button is
pressed. The magnified area is shown in a magnifier window.
If the left mouse button is pressed, the magnifier window disappears when the mouse button is released. If the mouse is dragged with the left mouse button pressed, the magnifier window is moved along, such that it always shows the area around the location where the mouse button is pressed.
If the right mouse button is pressed, the magnifier window remains visible, even after releasing the mouse button. The magnifier window can be closed by clicking on it.
If the shift key is pressed at the same time as pressing the mouse, the magnification is accelerated, i.e., made stronger.
The TLcdGXYMagnifierController
has several modes of update
(i.e., refresh of what is displayed inside):
IMMEDIATE_UPDATE_MODE
: the magnifier window
is updated whenever it is dragged around.
INTERVAL_UPDATE_MODE
: the magnifier window
is updated at fixed intervals. The length of the interval is
UpdateInterval
milliseconds.
LAZY_UPDATE_MODE
: the magnifier window
is updated whenever the mouse is not moved for UpdateInterval
milliseconds.
ADAPTIVE_UPDATE_MODE
: the magnifier window
behaves like IMMEDIATE_UPDATE_MODE
if its first update
takes less than UpdateDurationThreshold
milliseconds, and like
LAZY_UPDATE_MODE
otherwise. This is the default value.
Width
and Height
to indicate its size
(default value: 80x80).
ScaleFactor
, to indicate the magnification (default value: 5).
ScaleAccelerator
, to indicate the acceleration of
the magnification (default value: 2).
UpdateInterval
, to indicate at which interval
the magnifier window must be updated (in milliseconds).
The UpdateInterval
must be strictly positive.
The default value is 200.
UpdateDurationTreshold
, to indicate a threshold (in milliseconds) for
deciding upon the behavior in ADAPTIVE_UPDATE_MODE
.
The default value is 100.
Scale
of the magnifier window always equals
the Scale
of the ILcdGXYView
multiplied by
the ScaleFactor
multiplied by
the ScaleAccelerator
.
The Width
of the magnifier window is constrained by
half the Width
of the ILcdGXYView
.
The Height
of the magnifier window is constrained by
half the Height
of the ILcdGXYView
.
The magnifier window can be made UserAdjustable
.
When this is the case, the user can adapt some of the above properties with
the keyboard as long as the magnifier window is visible:
Width
and Height
of the magnifier window.
Width
and Height
of the magnifier window.
ScaleFactor
of the magnifier window.
ScaleFactor
of the magnifier window.
UserAdjustable
.Modifier and Type | Field and Description |
---|---|
static int |
ADAPTIVE_UPDATE_MODE |
static int |
IMMEDIATE_UPDATE_MODE |
static int |
INTERVAL_UPDATE_MODE |
static int |
LAST_MODE
The possible modes are consecutive int values,
starting from
0 to LAST_MODE . |
static int |
LAZY_UPDATE_MODE |
Constructor and Description |
---|
TLcdGXYMagnifierController()
Make a new
MagnifierController . |
Modifier and Type | Method and Description |
---|---|
protected ILcdGXYView |
createGlassGXYView()
Returns the
ILcdGXYView that will be used as a magnifier on top of this controllers
ILcdGXYView . |
ILcdFilter |
getGXYLayerFilter()
Returns the filter to determine if a layer of the original view is visible in the
magnifier window.
|
int |
getHeight() |
double |
getScaleAccelerator() |
double |
getScaleFactor() |
int |
getUpdateDurationTreshold() |
int |
getUpdateInterval() |
int |
getWidth() |
boolean |
isAdaptiveUpdateMode() |
boolean |
isImmediateUpdateMode() |
boolean |
isIntervalUpdateMode() |
boolean |
isLazyUpdateMode() |
boolean |
isTraceOn()
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
boolean |
isUserAdjustable()
Deprecated.
This property is never taken into account and may be removed in the future.
|
void |
mouseClicked(MouseEvent e) |
void |
mouseDragged(MouseEvent e)
When the mouse is dragged with the left-button pressed,
a magnifier window is shown whose center is the location below
the mouse.
|
void |
mouseEntered(MouseEvent e) |
void |
mouseExited(MouseEvent e)
Will perform a pan depending on the values of isDragging,
isPanOnMouseDragExit and isPanOnMouseMoveExit properties
|
void |
mouseMoved(MouseEvent e) |
void |
mousePressed(MouseEvent e)
When the left-button or right-button of the mouse is pressed,
a magnifier window is shown whose center is the location below
the mouse.
|
void |
mouseReleased(MouseEvent e)
When the left-button of the mouse is released,
the magnifier window disappears.
|
void |
setGXYLayerFilter(ILcdFilter aFilter)
Sets a filter that determines if a layer of the original view is visible in the
magnifier window.
|
void |
setHeight(int aHeight)
Sets
aHeight as the height of the magnifier window. |
void |
setMode(int aMode)
Set the mode of the magnifier window.
|
void |
setScaleAccelerator(double aScaleAccelerator)
Sets
aScaleAccelerator as the scale accelerator of the magnifier window. |
void |
setScaleFactor(double aScaleFactor)
Sets
aScaleFactor as the scale factor of the magnifier window. |
void |
setTraceOn(boolean aTraceOn)
Deprecated.
This method has been deprecated. It is recommended to use the
standard Java logging framework directly.
|
void |
setUpdateDurationTreshold(int aUpdateDurationThreshold)
Set the update duration threshold of the magnifier window to
aUpdateDurationThreshold |
void |
setUpdateInterval(int aUpdateInterval)
Set the update interval of the magnifier window to
aUpdateInterval |
void |
setUserAdjustable(boolean aUserAdjustable)
Deprecated.
This property is never taken into account and may be removed in the future.
|
void |
setWidth(int aWidth)
Sets
aWidth as the width of the magnifier window. |
void |
startInteraction(ILcdGXYView aGXYView)
Sets up the controller to receive input through the view passed.
|
void |
terminateInteraction(ILcdGXYView aGXYView)
Releases a few items.
|
void |
viewRepaint(ILcdGXYView aGXYView)
Empty implementation.
|
addUndoableListener, doPanGXYView, doZoomGXYView, 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, removeUndoableListener, setDownPanChars, setDownPanCodes, setIsDragging, setLeftPanChars, setLeftPanCodes, setPanAbsDelta, setPanOnMouseDragExit, setPanOnMouseMoveExit, setPanUndoable, setRequestFocusOnMouseEntered, setRequestFocusOnMousePressed, setRightPanChars, setRightPanCodes, setUpPanChars, setUpPanCodes, setZoomInChars, setZoomInCodes, setZoomOutChars, setZoomOutCodes, setZoomUndoable, updateViewLocationAfterZoomSFCT
addStatusListener, asGXYController, fireStatusEvent, getCursor, getGXYView, getIcon, getName, getShortDescription, paint, registerInstance, removeStatusListener, retrieveGXYViewXYWorldTransformation, setClassTraceOn, setCursor, setGXYView, setIcon, setName, setShortDescription
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLayered
public static final int IMMEDIATE_UPDATE_MODE
public static final int INTERVAL_UPDATE_MODE
public static final int ADAPTIVE_UPDATE_MODE
public static final int LAZY_UPDATE_MODE
public static final int LAST_MODE
0
to LAST_MODE
.public TLcdGXYMagnifierController()
MagnifierController
.
This MagnifierController
won't work until
it interacts with an ILcdGXYView
.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 startInteraction(ILcdGXYView aGXYView)
ALcdGXYController
All ILcdGXYView
implementations that support interaction call this method when the controller
has been made active with setGXYController
on the view,
so this method shouldn't normally be called directly.
Note that most view implementations add the controller as listener if appropriate before calling
this method.
Sets the cursor on the view and sets the view for which this controller is now active.
Sends out a status event based on the short description
.
startInteraction
in interface ILcdGXYController
startInteraction
in class ALcdGXYSmartController
aGXYView
- the ILcdGXYView
this ILcdGXYController
will interact with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.terminateInteraction(com.luciad.view.gxy.ILcdGXYView)
public void terminateInteraction(ILcdGXYView aGXYView)
ALcdGXYController
terminateInteraction
in interface ILcdGXYController
terminateInteraction
in class ALcdGXYSmartController
aGXYView
- the ILcdGXYView
this ILcdGXYController
interacted with.ILcdGXYView.setGXYController(com.luciad.view.gxy.ILcdGXYController)
,
ILcdGXYController.startInteraction(com.luciad.view.gxy.ILcdGXYView)
protected ILcdGXYView createGlassGXYView()
ILcdGXYView
that will be used as a magnifier on top of this controllers
ILcdGXYView
. This method shall return an instance of Component
or an
IllegalArgumentException
will be thrown in the startInteraction method.public ILcdFilter getGXYLayerFilter()
public void setGXYLayerFilter(ILcdFilter aFilter)
aFilter
- the used filter. If the filter returns true for an ILcdGXYLayer
,
that layer will be included in the magnifier window.public void viewRepaint(ILcdGXYView aGXYView)
ALcdGXYController
viewRepaint
in interface ILcdGXYController
viewRepaint
in class ALcdGXYController
aGXYView
- the ILcdGXYView
to draw on.public void mouseDragged(MouseEvent e)
The same constraints apply at the borders as in mousePressed
.
If the scale accelerator was activated when the mouse was pressed at the beginning of the drag, it remains activated.
mouseDragged
in interface MouseMotionListener
mouseDragged
in class ALcdGXYSmartController
mousePressed(java.awt.event.MouseEvent)
public void mouseMoved(MouseEvent e)
mouseMoved
in interface MouseMotionListener
mouseMoved
in class ALcdGXYSmartController
public void mouseClicked(MouseEvent e)
mouseClicked
in interface MouseListener
mouseClicked
in class ALcdGXYSmartController
public void mousePressed(MouseEvent e)
At the left and right borders of the ILcdGXYView
on which this MagnifierController
operates,
the center of the magnifier window is the location with minimum x
(resp. maximum x) such that the magnifier window is still within
the borders of the ILcdGXYView
.
Similarly, at the bottom and top borders of the ILcdGXYView
,
the center of the magnifier window is the location with minimum y
(resp. maximum y) such that the magnifier window is still within
the borders of the ILcdGXYView
.
If the SHIFT
key is held when pressing the mouse,
the scale accelerator of the magnifier is activated.
mousePressed
in interface MouseListener
mousePressed
in class ALcdGXYSmartController
public void mouseReleased(MouseEvent e)
mouseReleased
in interface MouseListener
mouseReleased
in class ALcdGXYSmartController
public void mouseEntered(MouseEvent e)
mouseEntered
in interface MouseListener
mouseEntered
in class ALcdGXYSmartController
public void mouseExited(MouseEvent e)
ALcdGXYSmartController
mouseExited
in interface MouseListener
mouseExited
in class ALcdGXYSmartController
public void setUserAdjustable(boolean aUserAdjustable)
public boolean isUserAdjustable()
public void setUpdateInterval(int aUpdateInterval)
aUpdateInterval
The new value for the update interval is taken into account at the latest after a delay of the old value of update interval.
public int getUpdateInterval()
public void setUpdateDurationTreshold(int aUpdateDurationThreshold)
aUpdateDurationThreshold
The new value for the duration threshold is taken into account at the next mouse drag.
public int getUpdateDurationTreshold()
public void setWidth(int aWidth)
aWidth
as the width of the magnifier window.public int getWidth()
public void setHeight(int aHeight)
aHeight
as the height of the magnifier window.public int getHeight()
public void setScaleFactor(double aScaleFactor)
aScaleFactor
as the scale factor of the magnifier window.public double getScaleFactor()
public void setScaleAccelerator(double aScaleAccelerator)
aScaleAccelerator
as the scale accelerator of the magnifier window.public double getScaleAccelerator()
public void setMode(int aMode)
public boolean isIntervalUpdateMode()
true
if and only if the mode of the
magnifier window is INTERVAL_UPDATE_MODE
public boolean isImmediateUpdateMode()
true
if and only if the mode of the
magnifier window is IMMEDIATE_UPDATE_MODE
public boolean isAdaptiveUpdateMode()
true
if and only if the mode of the
magnifier window is ADAPTIVE_UPDATE_MODE
public boolean isLazyUpdateMode()
true
if and only if the mode of the
magnifier window is LAZY_UPDATE_MODE