Class WhiteboardRenderer<T extends android.view.View & ZoomableSharingView>
- java.lang.Object
-
- com.avaya.clientservices.collaboration.whiteboard.WhiteboardRenderer<T>
-
- All Implemented Interfaces:
android.view.View.OnTouchListener,ZoomableSharingView.ZoomableSharingViewActionListener
public class WhiteboardRenderer<T extends android.view.View & ZoomableSharingView> extends java.lang.Object implements ZoomableSharingView.ZoomableSharingViewActionListener, android.view.View.OnTouchListener
WhiteboardRenderer object provides whiteboard rendering methods. Using this object user can draw shapes and receive drawings.
All user drawings are done internally (by renderer) on
DrawingViewview, until they are accepted by server. After that they and other incoming drawings are displayed on aZoomableSharingViewview.In order to receive all drawings the user has to create a
ZoomableSharingViewandDrawingView, initialize them in the renderer object usingsetSharingView(View)andsetDrawingView(DrawingView)methods and also add them to the view hierarchy in which he wants to display the whole whiteboard component.This two tier system is constructed this way because redrawing all shapes is a time consuming operation which is done on a UI thread, therefore it's better to draw only received shapes instead of all of them.
- See Also:
DrawingView,ZoomableSharingView
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceWhiteboardRenderer.RendererPrivateListenerWhiteboard renderer private listener which notifies about whiteboard started and whiteboard ended events.
-
Constructor Summary
Constructors Constructor Description WhiteboardRenderer()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddListener(WhiteboardRenderer.RendererPrivateListener listener)Add a newWhiteboardRenderer.RendererPrivateListenerobject to the whiteboard renderer.voidclearWhiteboard()Clears whiteboard active surface.WhiteboardSurfacegetActiveWhiteboardSurface()Returns the active whiteboard surface.DrawingView.DrawingListenergetDrawingListener()ReturnsDrawingListenerobject required for constructingDrawingView.intgetWhiteboardHeight()Whiteboard renderer internally storesWhiteboardthis method returns height of the whiteboard object.WhiteboardListenergetWhiteboardListener()Whiteboard renderer internally creates implementation ofWhiteboardListenerand this method returns it.java.util.List<WhiteboardSurface>getWhiteboardSurfaces()Returns allWhiteboardSurfacewhiteboard surfaces associated with current whiteboard session.intgetWhiteboardWidth()Whiteboard renderer internally storesWhiteboardthis method returns width of the whiteboard object.booleanisInitialized()Deprecated.booleanisWhiteboardStarted()To get the correct value this method requires one to register a whiteboard renderer object as a listener onWhiteboardobject fromCollaborationobject returned onCollaborationListener.onCollaborationStartedmethod callback.voidonLongPress(float x, float y)Long press gesture was done on this view.voidonSingleTap(float x, float y)Single tap gesture was done on this view.booleanonTouch(android.view.View v, android.view.MotionEvent event)voidremoveListener(WhiteboardRenderer.RendererPrivateListener listener)RemovesWhiteboardRenderer.RendererPrivateListenerobject from the whiteboard renderer.voidremoveWhiteboardSurface(WhiteboardSurface surface)Request for removing whiteboard surface.voidrequestNewSurface()Request for creating new whiteboard surface.voidsetActiveWhiteboardSurface(WhiteboardSurface surface)Sets whiteboard surface as active and draws all its shape on canvas.voidsetDrawingColor(Color color)Sets actual color for the drawn shapes.voidsetDrawingTool(DrawingTool drawingTool)Sets new drawing tool.voidsetDrawingView(DrawingView drawingView)Sets view for user drawings.voidsetSharingView(T sharingView)Sets view with zoom and pinch for incoming drawings from server.voidsetZoomableImageView(ZoomableImageView zoomableImageView)Deprecated.voidshowActiveWhiteboardSurface()Displays active surface and its shapes on canvas in the case when whiteboard session was initialized before and is active.voidstopWhiteboardSharing()Stops current whiteboard session.
-
-
-
Method Detail
-
addListener
public void addListener(WhiteboardRenderer.RendererPrivateListener listener)
Add a newWhiteboardRenderer.RendererPrivateListenerobject to the whiteboard renderer.- Parameters:
listener- object to be added.
-
removeListener
public void removeListener(WhiteboardRenderer.RendererPrivateListener listener)
RemovesWhiteboardRenderer.RendererPrivateListenerobject from the whiteboard renderer.- Parameters:
listener- object to be removed.
-
setZoomableImageView
@Deprecated public void setZoomableImageView(ZoomableImageView zoomableImageView)
Deprecated.Sets view with zoom and pinch for incoming drawings from server.- Parameters:
zoomableImageView- zoomable image view object.
-
setSharingView
public void setSharingView(T sharingView)
Sets view with zoom and pinch for incoming drawings from server.- Parameters:
sharingView- sharing view object.
-
setDrawingView
public void setDrawingView(DrawingView drawingView)
Sets view for user drawings.- Parameters:
drawingView- drawing view object.
-
setActiveWhiteboardSurface
public void setActiveWhiteboardSurface(WhiteboardSurface surface)
Sets whiteboard surface as active and draws all its shape on canvas.- Parameters:
surface- object to be active.
-
getActiveWhiteboardSurface
public WhiteboardSurface getActiveWhiteboardSurface()
Returns the active whiteboard surface. A value of null is returned in case if the whiteboard session hasn't been started or is ended.- Returns:
- active whiteboard surface.
-
requestNewSurface
public void requestNewSurface()
Request for creating new whiteboard surface. In case of success whiteboard renderer will show on itsZoomableSharingViewview newly createdWhiteboardSurfacewhiteboard surface.
-
removeWhiteboardSurface
public void removeWhiteboardSurface(WhiteboardSurface surface)
Request for removing whiteboard surface. User could not remove last whiteboard surface.- Parameters:
surface- whiteboard surface to remove.
-
showActiveWhiteboardSurface
public void showActiveWhiteboardSurface()
Displays active surface and its shapes on canvas in the case when whiteboard session was initialized before and is active.
-
getWhiteboardSurfaces
public java.util.List<WhiteboardSurface> getWhiteboardSurfaces()
Returns allWhiteboardSurfacewhiteboard surfaces associated with current whiteboard session.- Returns:
- list of whiteboard surface objects.
-
setDrawingColor
public void setDrawingColor(Color color)
Sets actual color for the drawn shapes. Cannot be null.- Parameters:
color- new drawing color.- Throws:
java.lang.IllegalStateException- in case when whiteboard views are not properly initialized in renderer object.
-
setDrawingTool
public void setDrawingTool(DrawingTool drawingTool)
Sets new drawing tool. Cannot be null.- Parameters:
drawingTool- new drawing tool.- Throws:
java.lang.IllegalStateException- in the case when whiteboard views are not properly initialized in renderer object.
-
clearWhiteboard
public void clearWhiteboard()
Clears whiteboard active surface. Result of this operation will be displayed onZoomableSharingViewinternally by renderer. If the whiteboard session is not started, this method does nothing.
-
stopWhiteboardSharing
public void stopWhiteboardSharing()
Stops current whiteboard session. If the whiteboard session is not started, this method does nothing.
-
isWhiteboardStarted
public boolean isWhiteboardStarted()
To get the correct value this method requires one to register a whiteboard renderer object as a listener onWhiteboardobject fromCollaborationobject returned onCollaborationListener.onCollaborationStartedmethod callback.- Returns:
- true if whiteboard session was started, otherwise false.
-
isInitialized
@Deprecated public boolean isInitialized()
Deprecated.Indicates if renderer views are properly initialized and added to it.- Returns:
- true if renderer is properly initialized, otherwise false.
- See Also:
setZoomableImageView(ZoomableImageView),setSharingView(View),setDrawingView(DrawingView)
-
getDrawingListener
public DrawingView.DrawingListener getDrawingListener()
ReturnsDrawingListenerobject required for constructingDrawingView.- Returns:
- drawing listener object.
-
getWhiteboardListener
public WhiteboardListener getWhiteboardListener()
Whiteboard renderer internally creates implementation ofWhiteboardListenerand this method returns it. It should be registered on theWhiteboardobject in callbackCollaborationListener.onCollaborationStarted- Returns:
- whiteboard listener object.
-
getWhiteboardHeight
public int getWhiteboardHeight()
Whiteboard renderer internally storesWhiteboardthis method returns height of the whiteboard object.- Returns:
- whiteboard height if whiteboard object is valid and height is positive integer, othervise returns default value.
-
getWhiteboardWidth
public int getWhiteboardWidth()
Whiteboard renderer internally storesWhiteboardthis method returns width of the whiteboard object.- Returns:
- whiteboard width if whiteboard object is valid and width is positive integer, othervise returns default value.
-
onSingleTap
public void onSingleTap(float x, float y)Description copied from interface:ZoomableSharingView.ZoomableSharingViewActionListenerSingle tap gesture was done on this view.- Specified by:
onSingleTapin interfaceZoomableSharingView.ZoomableSharingViewActionListener- Parameters:
x- coordinate of tap gesture.y- coordinate of tap gesture.
-
onLongPress
public void onLongPress(float x, float y)Description copied from interface:ZoomableSharingView.ZoomableSharingViewActionListenerLong press gesture was done on this view.- Specified by:
onLongPressin interfaceZoomableSharingView.ZoomableSharingViewActionListener- Parameters:
x- coordinate of long press gesture.y- coordinate of long press gesture.
-
onTouch
public boolean onTouch(android.view.View v, android.view.MotionEvent event)- Specified by:
onTouchin interfaceandroid.view.View.OnTouchListener
-
-