Class ALspTouchController
- All Implemented Interfaces:
ILcdAWTEventListener,ILspController
- Direct Known Subclasses:
ALspConfinedTouchController
Extension of ALspController for TLcdTouchEvent instances.
It provides support for tracking multiple TLcdTouchPoints and allows to react when
a
point is created, moves (beyond a certain threshold) or is
removed.
All incoming events are passed down the chain to the next controller. In case of
TLcdTouchEvents, the consumed state of the different TLcdTouchPoints contained in the event will be
updated according to the points this controller is handling.
The handleFXEvent(Event aEvent) converts the native JavaFX TouchEvent
to a TLcdTouchEvent and passes it to the handleAWTEvent(AWTEvent aEvent).
Implementations of this class can track touch points by implementing
touchPointAvailable, touchPointMoved, and
touchPointWithdrawn as follows:
- Every time a new touch point becomes available, the touchPointAvailable method is called. This method determines which points will be tracked by this controller. A touch point becomes available when:
-
If one of the tracked points moves or is withdrawn, the touchPointMoved and touchPointWithdrawn methods are respectively called. At both occasions, it is possible to indicate certain points should no longer be tracked by this controller. A
TLcdTouchPointis withdrawn when:
ALcdGXYTouchChainableController for an example of this controller's behavior.- Since:
- 2012.0
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault constructor, nothing is initialized. -
Method Summary
Modifier and TypeMethodDescriptionReturns the current locations of the touch points this controller is tracking.intReturns the current threshold for move events.Returns the original locations of the touch points this controller is tracking (= the location of the point when it was passed to thetouchPointAvailablemethod).Returns the locations of the touch points this controller is tracking during the previous event.Returns a list containing the touch point IDs of the touch points used by this controller.voidhandleAWTEvent(AWTEvent aEvent) handleAWTEventImpl(AWTEvent aAWTEvent) Called byhandleAWTEvent.protected voidhandleEventImpl(TLcdTouchEvent aTouchEvent) This method is called right before aTLcdTouchEventis forwarded to the next controller in the chain.voidhandleFXEvent(Event aEvent) Delegates tohandleFXEventImpl.booleanReturns true if this controller is configured to visualize touch points in the view.protected TLspPaintProgresspaintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) The specific implementation ofpaintfor this controller.voidsetDrawTouchPoints(boolean aDrawTouchPoints) Determines whether this controller should visualize touch points in the view.voidsetMoveThreshold(int aMoveThreshold) Sets the threshold for move events.protected abstract List<TLcdTouchPoint> touchPointAvailable(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchDown) This method is called every time a new touch point is created or becomes available and allows to react accordingly.protected abstract List<TLcdTouchPoint> touchPointMoved(List<TLcdTouchPoint> aTrackedTouchPoints, TLcdTouchPoint aTouchMoved) This method is called when one of the touch points, used by this controller, is moved beyond the threshold and allows to react accordingly.protected abstract List<TLcdTouchPoint> touchPointWithdrawn(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchUp) This methods is called every time a tracked touch point is removed or consumed and allows to react accordingly.Methods inherited from class com.luciad.view.lightspeed.controller.ALspController
addPropertyChangeListener, addStatusListener, appendController, firePropertyChange, fireStatusEvent, getAWTFilter, getCursor, getFXCursor, getFXFilter, getIcon, getLayered, getName, getNextController, getShortDescription, getView, handleFXEventImpl, paint, registerViewPropertyNameForReset, removePropertyChangeListener, removeStatusListener, setAWTFilter, setCursor, setFXCursor, setFXFilter, setIcon, setName, setShortDescription, startInteraction, startInteractionImpl, terminateInteraction, terminateInteractionImpl
-
Constructor Details
-
ALspTouchController
protected ALspTouchController()Default constructor, nothing is initialized.
-
-
Method Details
-
isDrawTouchPoints
public boolean isDrawTouchPoints()Returns true if this controller is configured to visualize touch points in the view. By default, this feature is off.- Returns:
- true if this controller is configured to visualize touch points in the view
- See Also:
-
setDrawTouchPoints
public void setDrawTouchPoints(boolean aDrawTouchPoints) Determines whether this controller should visualize touch points in the view. If true, the controller'spaint()method will draw a circle at the location of each current touch point. By default, this property is set to false.- Parameters:
aDrawTouchPoints- whether or not to visualize touch points in the view
-
handleAWTEvent
When the event describes the creation of a touch point, the
touchPointAvailablemethod will be called, allowing to indicate which touch points to track. ThetouchPointAvailablemethod will also be called if aTLcdTouchPointwas previously marked as consumed and is no longer consumed inaEvent.When the event describes the move of a touch point tracked by this controller, the
touchPointMovedwill be called if thethresholdis exceeded.When the event describes the removal of a touch point, the
touchPointWithdrawnmethod will be called. ThetouchPointWithdrawnmethod will also be called whenaEventindicates one of the tracked points is consumed.All incoming events will be forwarded to the next controller. In case of
TLcdTouchEvents, the consumed state of the differentTLcdTouchPoints contained in the event will be adjusted according to the points this controller is handling. Right before anyTLcdTouchEventis forwarded to the next controller, the handleEventImpl method is called.Typically this method should not be overridden. Override
touchPointAvailable,touchPointMovedortouchPointWithdrawninstead.If
aEventis not an instance ofTLcdTouchEvent, it will simply be forwarded to the next controller without affecting this controller.- Specified by:
handleAWTEventin interfaceILcdAWTEventListener- Overrides:
handleAWTEventin classALspController- Parameters:
aEvent- The event to be handled.- See Also:
-
handleFXEvent
Description copied from class:ALspControllerDelegates tohandleFXEventImpl. If that method does not returnnull, the result is passed on to the next controller in the chain (if one exists). If the controller has a filter that does not accept the event, the event is not delegated and is immediately passed on to the next controller.- Specified by:
handleFXEventin interfaceILspController- Overrides:
handleFXEventin classALspController- Parameters:
aEvent- the event to be handled
-
touchPointMoved
protected abstract List<TLcdTouchPoint> touchPointMoved(List<TLcdTouchPoint> aTrackedTouchPoints, TLcdTouchPoint aTouchMoved) This method is called when one of the touch points, used by this controller, is moved beyond the threshold and allows to react accordingly.
aTouchMovedis theTLcdTouchPointwhich has moved, whileaTrackedTouchPointscontains allTLcdTouchPoints this controller is currently tracking (includingaTouchMoved). All of these points will be non-consumed.This method allows to indicate that certain touch points should no longer be tracked by this controller. It does so by returning a
Listcontaining allTLcdTouchPointinstances which should be tracked by this controller. If aTLcdTouchPointwhich is currently tracked is omitted from theList, that touch point will be made available to the rest of the chain as explained in the class javadoc.A possible use case is a select controller, which does not expect move events. The select controller can claim the touch point when it is created, but when the point starts moving it can decide it cannot handle it.
- Parameters:
aTrackedTouchPoints-Listcontaining allTLcdTouchPoints currently tracked by this controller. It is possible to modify thisListand return it instead of creating a newList.aTouchMoved- theTLcdTouchPointthat has moved- Returns:
- a
Listcontaining allTLcdTouchPoints this controller should keep tracking. AllTLcdTouchPointinstances contained in thisListmust be contained inaTrackedTouchPoints. May be an emptyList, but notnull. - See Also:
-
getOriginalLocations
Returns the original locations of the touch points this controller is tracking (= the location of the point when it was passed to the
touchPointAvailablemethod). The locations are expressed in view AWT coordinates. In case the view is moved after the touch down of the touch point (for example, due to a pan operation), these coordinates will not be altered. Hence the corresponding world coordinates will no longer match the world coordinates of the point during thetouchPointAvailablemethod call.The order of the points in the returned list matches the order of the lists returned in
getPreviousLocationsandgetCurrentLocations. The same order is applied ongetTouchPointIDs.- Returns:
- the original locations of the touch points this controller is tracking. The
Listis empty when no points are currently tracked.
-
getPreviousLocations
Returns the locations of the touch points this controller is tracking during the previous event. The locations are expressed in view AWT coordinates. In case the view is moved after the touch down or last move of the touch point (for example, due to a pan operation), these coordinates will not be altered. Hence the corresponding world coordinates will no longer match the world coordinates of the point during the touch down or the move.
The order of the points in the returned list matches the order of the lists returned in
getOriginalLocationsandgetCurrentLocations. The same order is applied ongetTouchPointIDs.- Returns:
- the previous locations of the touch points this controller is tracking. The
Listis empty when no points are currently tracked.
-
getCurrentLocations
Returns the current locations of the touch points this controller is tracking. Locations are expressed in view AWT coordinates.
The order of the points in the returned list matches the order of the lists returned in
getOriginalLocationsandgetPreviousLocations. The same order is applied ongetTouchPointIDs.- Returns:
- the current locations of the touch points this controller is tracking. The
Listis empty when no points are currently tracked.
-
getTouchPointIDs
Returns a list containing the touch point IDs of the touch points used by this controller.
The order of the IDs is the order in which the points were passed to the touchPointAvailable method.
- Returns:
- a list containing the touch
point IDs of the touch points this controller is using. The
Listis empty when no points are currently tracked.
-
touchPointAvailable
protected abstract List<TLcdTouchPoint> touchPointAvailable(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchDown) This method is called every time a new touch point is created or becomes available and allows to react accordingly.
aTouchDownis theTLcdTouchPointwhich has been created, whileaTouchPointscontains all availableTLcdTouchPoints (includingaTouchDown). All of these points are non-consumed.This method allows to indicate which points should be tracked by this controller by returning them in a
List. If aTLcdTouchPointwhich is currently tracked is omitted from theList, that touch point will be made available to the rest of the chain as explained in the class javadoc.- Parameters:
aTouchPoints- AListcontaining all availableTLcdTouchPointinstances. This list will includeaTouchDown. Note that some of theseTLcdTouchPoints can already be tracked by this controller (seegetTouchPointIDs). It is possible to modify thisListand return it instead of creating a newList.aTouchDown- The descriptor of the touch point which has been created or removed. The state of the descriptor will always be DOWN. Note that this descriptor is included inaTouchPoints.- Returns:
- a
Listcontaining allTLcdTouchPointinstances which should be tracked by this controller. AllTLcdTouchPointinstances contained in thisListmust be contained inaTouchPoints. May be an emptyList, but notnull.
-
touchPointWithdrawn
protected abstract List<TLcdTouchPoint> touchPointWithdrawn(List<TLcdTouchPoint> aTouchPoints, TLcdTouchPoint aTouchUp) This methods is called every time a tracked touch point is removed or consumed and allows to react accordingly.
aTouchUpis theTLcdTouchPointwhich has been removed, whileaTouchPointscontains all availableTLcdTouchPoints (includingaTouchUp). All of these points are non-consumed.This method allows to indicate that certain touch points should no longer be tracked by this controller. It does so by returning a
Listcontaining allTLcdTouchPointinstances which should be tracked by this controller. If aTLcdTouchPointwhich is currently tracked is omitted from theList, that touch point will be made available to the rest of the chain as explained in the class javadoc.- Parameters:
aTouchPoints- AListcontaining all availableTLcdTouchPointinstances, includingaTouchUp. It is possible to modify thisListand return it instead of creating a newList.aTouchUp- The touch point which has been removed. The state of the descriptor will always be UP. Note that this descriptor is included inaTouchPoints.- Returns:
- a
Listcontaining allTLcdTouchPoints this controller should keep tracking. AllTLcdTouchPointinstances contained in thisListmust be contained inaTrackedTouchPoints. May be an emptyList, but notnull. - See Also:
-
getMoveThreshold
public int getMoveThreshold()Returns the current threshold for move events.
The
touchPointMovedmethod will only be called if the point moves further then the threshold in either the X or Y direction, and the same applies for the update of the previous and current locations.The default value for this property is 0, which means every move of a tracked touch point will be handled.
- Returns:
- the current threshold for move events
- See Also:
-
setMoveThreshold
public void setMoveThreshold(int aMoveThreshold) Sets the threshold for move events.
The
touchPointMovedmethod will only be called if the point moves further then the threshold in either the X or Y direction, and the same applies for the update of the previous and current locations.The new value of the threshold will not affect any events which arrived at the controller prior to the change in threshold.
The default value for this property is 0, which means every move of a tracked touch point will be handled.
- Parameters:
aMoveThreshold- the threshold for move events. Must be positive.- See Also:
-
paintImpl
protected TLspPaintProgress paintImpl(ILcdGLDrawable aGLDrawable, ILspView aView, TLspPaintPhase aPaintPhase) Description copied from class:ALspControllerThe specific implementation ofpaintfor this controller.- Overrides:
paintImplin classALspController- Parameters:
aGLDrawable- the drawable that should be painted onaView- the view that is painted onaPaintPhase- the current paint phase- Returns:
- whether or not the painting was finished
-
handleEventImpl
This method is called right before a
TLcdTouchEventis forwarded to the next controller in the chain. The default implementation of this method is empty.- Parameters:
aTouchEvent- theTLcdTouchEventwhich will be forwarded to the next controller. The consumed state of theTLcdTouchPoints is already updated.
-
handleAWTEventImpl
Description copied from class:ALspControllerCalled byhandleAWTEvent. Returnsnullwhen the controller consumed the event or a partially consumed event when the controller partially consumed the event (which could happen withTLcdTouchEvents). When the controller did not use the given event, it is returned unaltered.- Specified by:
handleAWTEventImplin classALspController- Parameters:
aAWTEvent- the event to be handled.- Returns:
nullwhen the input event was consumed, the (possibly modified) input event when it was (partially) consumed.
-