Package com.google.gwt.canvas.client
Class Canvas
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.FocusWidget
com.google.gwt.canvas.client.Canvas
- All Implemented Interfaces:
HasAllDragAndDropHandlers
,HasAllFocusHandlers
,HasAllGestureHandlers
,HasAllKeyHandlers
,HasAllMouseHandlers
,HasAllTouchHandlers
,HasBlurHandlers
,HasClickHandlers
,HasDoubleClickHandlers
,HasDragEndHandlers
,HasDragEnterHandlers
,HasDragHandlers
,HasDragLeaveHandlers
,HasDragOverHandlers
,HasDragStartHandlers
,HasDropHandlers
,HasFocusHandlers
,HasGestureChangeHandlers
,HasGestureEndHandlers
,HasGestureStartHandlers
,HasKeyDownHandlers
,HasKeyPressHandlers
,HasKeyUpHandlers
,HasMouseDownHandlers
,HasMouseMoveHandlers
,HasMouseOutHandlers
,HasMouseOverHandlers
,HasMouseUpHandlers
,HasMouseWheelHandlers
,HasTouchCancelHandlers
,HasTouchEndHandlers
,HasTouchMoveHandlers
,HasTouchStartHandlers
,HasAttachHandlers
,HasHandlers
,EventListener
,Focusable
,HasEnabled
,HasFocus
,HasVisibility
,IsWidget
,SourcesClickEvents
,SourcesFocusEvents
,SourcesKeyboardEvents
,SourcesMouseEvents
A widget representing a <canvas> element.
This widget may not be supported on all browsers.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
-
Field Summary
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
-
Method Summary
Modifier and TypeMethodDescriptionstatic Canvas
Return a newCanvas
if supported, and null otherwise.Returns the attached Canvas Element.getContext
(String contextId) Gets the rendering context that may be used to draw on this canvas.Returns a 2D rendering context.int
Gets the height of the internal canvas coordinate space.int
Gets the width of the internal canvas coordinate space.static boolean
Runtime check for whether the canvas element is supported in this browser.void
setCoordinateSpaceHeight
(int height) Sets the height of the internal canvas coordinate space.void
setCoordinateSpaceWidth
(int width) Sets the width of the internal canvas coordinate space.Returns a data URL for the current content of the canvas element.Returns a data URL for the current content of the canvas element, with a specified type.static Canvas
wrap
(CanvasElement element) Wrap an existing canvas element.Methods inherited from class com.google.gwt.user.client.ui.FocusWidget
addBlurHandler, addClickHandler, addClickListener, addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addFocusHandler, addFocusListener, addGestureChangeHandler, addGestureEndHandler, addGestureStartHandler, addKeyboardListener, addKeyDownHandler, addKeyPressHandler, addKeyUpHandler, addMouseDownHandler, addMouseListener, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addMouseWheelListener, addTouchCancelHandler, addTouchEndHandler, addTouchMoveHandler, addTouchStartHandler, getFocusImpl, getTabIndex, isEnabled, onAttach, removeClickListener, removeFocusListener, removeKeyboardListener, removeMouseListener, removeMouseWheelListener, setAccessKey, setEnabled, setFocus, setTabIndex
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Method Details
-
createIfSupported
Return a newCanvas
if supported, and null otherwise.- Returns:
- a new
Canvas
if supported, and null otherwise
-
wrap
Wrap an existing canvas element. The element must already be attached to the document. If the element is removed from the document, you must callRootPanel.detachNow(Widget)
. Note: This method can return null if there is no support for canvas by the current browser.- Parameters:
element
- the element to wrap- Returns:
- the
Canvas
widget or null if canvas is not supported by the current browser.
-
isSupported
public static boolean isSupported()Runtime check for whether the canvas element is supported in this browser.- Returns:
- whether the canvas element is supported
-
getCanvasElement
Returns the attached Canvas Element.- Returns:
- the Canvas Element
-
getContext
Gets the rendering context that may be used to draw on this canvas.- Parameters:
contextId
- the context id as a String- Returns:
- the canvas rendering context
-
getContext2d
Returns a 2D rendering context. This is a convenience method, seegetContext(String)
.- Returns:
- a 2D canvas rendering context
-
getCoordinateSpaceHeight
public int getCoordinateSpaceHeight()Gets the height of the internal canvas coordinate space.- Returns:
- the height, in pixels
- See Also:
-
getCoordinateSpaceWidth
public int getCoordinateSpaceWidth()Gets the width of the internal canvas coordinate space.- Returns:
- the width, in pixels
- See Also:
-
setCoordinateSpaceHeight
public void setCoordinateSpaceHeight(int height) Sets the height of the internal canvas coordinate space.- Parameters:
height
- the height, in pixels- See Also:
-
setCoordinateSpaceWidth
public void setCoordinateSpaceWidth(int width) Sets the width of the internal canvas coordinate space.- Parameters:
width
- the width, in pixels- See Also:
-
toDataUrl
Returns a data URL for the current content of the canvas element.- Returns:
- a data URL for the current content of this element.
-
toDataUrl
Returns a data URL for the current content of the canvas element, with a specified type.- Parameters:
type
- the type of the data url, e.g., image/jpeg or image/png.- Returns:
- a data URL for the current content of this element with the specified type.
-