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

      public class Canvas
      extends FocusWidget

  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

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Canvas` | `createIfSupported()` Return a new `Canvas` if supported, and null otherwise.
    `CanvasElement` | `getCanvasElement()` Returns the attached Canvas Element.
    `Context` | `getContext(java.lang.String contextId)` Gets the rendering context that may be used to draw on this canvas.
    `Context2d` | `getContext2d()` Returns a 2D rendering context.
    `int` | `getCoordinateSpaceHeight()` Gets the height of the internal canvas coordinate space.
    `int` | `getCoordinateSpaceWidth()` Gets the width of the internal canvas coordinate space.
    `static boolean` | `isSupported()` 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.
    `java.lang.String` | `toDataUrl()` Returns a data URL for the current content of the canvas element.
    `java.lang.String` | `toDataUrl(java.lang.String type)` Returns a data URL for the current content of the canvas element, with a specified type.

    - ### 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`

    - ### 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, unsinkEvents`

    - ### 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 Detail

    - #### createIfSupported

          public static Canvas createIfSupported()

      Return a new `Canvas` if supported, and null otherwise.
      Returns:
        a new `Canvas` if supported, and null otherwise

    - #### 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

          public CanvasElement getCanvasElement()

      Returns the attached Canvas Element.
      Returns:
        the Canvas Element

    - #### getContext

          public Context getContext(java.lang.String contextId)

      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

          public Context2d getContext2d()

      Returns a 2D rendering context. This is a convenience method, see `getContext(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:
        `setCoordinateSpaceHeight(int)`

    - #### getCoordinateSpaceWidth

          public int getCoordinateSpaceWidth()

      Gets the width of the internal canvas coordinate space.
      Returns:
        the width, in pixels
      See Also:
        `setCoordinateSpaceWidth(int)`

    - #### setCoordinateSpaceHeight

          public void setCoordinateSpaceHeight(int height)

      Sets the height of the internal canvas coordinate space.
      Parameters:
        `height` - the height, in pixels
      See Also:
        `getCoordinateSpaceHeight()`

    - #### setCoordinateSpaceWidth

          public void setCoordinateSpaceWidth(int width)

      Sets the width of the internal canvas coordinate space.
      Parameters:
        `width` - the width, in pixels
      See Also:
        `getCoordinateSpaceWidth()`

    - #### toDataUrl

          public java.lang.String 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

          public java.lang.String toDataUrl(java.lang.String type)

      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.