|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mt4j.components.MTComponent
org.mt4j.components.MTCanvas
public class MTCanvas
The canvas to add all objects to.
Constructor Summary | |
---|---|
MTCanvas(processing.core.PApplet pApplet, Icamera attachedCamera) The Constructor. |
|
MTCanvas(processing.core.PApplet pApplet, java.lang.String name, Icamera attachedCamera) The Constructor. |
Method Summary | |
---|---|
protected void |
destroyComponent() Override this to clean up resources when destroying a component. |
void |
drawAndUpdateCanvas(processing.core.PGraphics graphics, long updateTime) Updates and then draws every visible object in the canvas. |
int |
getCacheClearTime() Gets the cache clear time. |
long |
getCacheTimeDelta() Gets the cache time delta. |
ClusterManager |
getClusterManager() Gets the cluster manager. |
IMTComponent3D |
getComponentAt(float x, float y) Method for asking the canvas whether and which object is at the specified screen position. |
boolean |
isBackGroundAt(float x, float y) Checks if is back ground at. |
boolean |
isFrustumCulling() |
boolean |
isUseHitTestCache() Checks if is use hit test cache. |
boolean |
processInputEvent(MTInputEvent inEvt) Processes the input event. |
void |
setCacheClearTime(int cacheClearTime) Sets the time intervals in ms in which the canvas clears its hit test cache Default value is: 20000 ms This is important to prevent the hit test cache from growing indefinitely. |
void |
setCacheTimeDelta(long cacheTimeDelta) If repeated calls to getObjectAt(float x, float y) in MTCanvas class are called during the provided cacheTimeDelta, the Canvas looks into his cache instead of querying all objects again Default value is: 80. |
void |
setClusterManager(ClusterManager selectionManager) Sets the cluster manager. |
void |
setFrustumCulling(boolean frustumCulling) |
void |
setUseHitTestCache(boolean useHitTestCache) The canvas can be set to look into a hit test cache if repeated calls to getComponentAt() with the same coordinates during a short period of time are made. |
void |
updateComponent(long timeDelta) Tells the component to update its state if neccessary. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MTCanvas(processing.core.PApplet pApplet, Icamera attachedCamera)
pApplet
- the appletglobalCamera
- the global camerapublic MTCanvas(processing.core.PApplet pApplet, java.lang.String name, Icamera attachedCamera)
pApplet
- the appletname
- the nameattachedCamera
- the attached cameraMethod Detail |
---|
protected void destroyComponent()
MTComponent
destroy
method. So you shouldnt invoke this method directly.
destroyComponent
in class MTComponent
public IMTComponent3D getComponentAt(float x, float y)
IMPORTANT: this method returns the MTCanvas instance if no other object is hit. This means that the MTCanvas instance acts like the background => Gestures that are supposed to be performed on the background have to check if they hit the canvas. And the gestureevents should then have the canvas as their targetComponent! Also, you have to be careful in other gestures, as even when you dont hit an object, you will get the mtcanvas returned as the hit component - not null!
Note: if the hit component is part of a cluster, the cluster is returned!
getComponentAt
in interface IHitTestInfoProvider
x
- the screen x coordinatey
- the screen y coordinatepublic boolean isBackGroundAt(float x, float y)
IHitTestInfoProvider
isBackGroundAt
in interface IHitTestInfoProvider
x
- the xy
- the ypublic void updateComponent(long timeDelta)
MTComponent
drawComponent()
method is invoked. The timeDelta
parameter indicates the time passed since the last frame was drawn and can be used for animation for example.IMTController
object if existing. If overriden, the superclass implementation should always be called!
updateComponent
in interface IMTComponent
updateComponent
in class MTComponent
timeDelta
- the time deltapublic void drawAndUpdateCanvas(processing.core.PGraphics graphics, long updateTime)
updateComponent(long timeDelta)
method. Then the drawComponent()
method of each object in the scene graph. Also handles the setting of cameras attached to the objects.
graphics
-updateTime
- the time passed since the last update (in ms)public boolean processInputEvent(MTInputEvent inEvt)
IMTComponent
processInputEvent
in interface IMTComponent
processInputEvent
in interface IMTInputEventListener
processInputEvent
in class MTComponent
inEvt
- the in evtpublic ClusterManager getClusterManager()
public void setClusterManager(ClusterManager selectionManager)
selectionManager
- the new cluster managerpublic long getCacheTimeDelta()
public void setCacheTimeDelta(long cacheTimeDelta)
cacheTimeDelta
- the cache time deltapublic boolean isUseHitTestCache()
public void setUseHitTestCache(boolean useHitTestCache)
setCacheTimeDelta(long cacheTimeDelta)
This is useful for example when a click is made many gestureanalyzers call getObjectAt() almost concurrently.
useHitTestCache
- the use hit test cachepublic int getCacheClearTime()
public void setCacheClearTime(int cacheClearTime)
This is important to prevent the hit test cache from growing indefinitely.
cacheClearTime
- the cache clear timepublic boolean isFrustumCulling()
public void setFrustumCulling(boolean frustumCulling)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |