public class Canvas extends FocusWidget
UIObject.DebugIdImpl, UIObject.DebugIdImplEnabled
DEBUG_ID_PREFIX
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.
|
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
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
fireEvent
public static Canvas createIfSupported()
Canvas
if supported, and null otherwise.Canvas
if supported, and null otherwisepublic static boolean isSupported()
public CanvasElement getCanvasElement()
public Context getContext(java.lang.String contextId)
contextId
- the context id as a Stringpublic Context2d getContext2d()
getContext(String)
.public int getCoordinateSpaceHeight()
setCoordinateSpaceHeight(int)
public int getCoordinateSpaceWidth()
setCoordinateSpaceWidth(int)
public void setCoordinateSpaceHeight(int height)
height
- the height, in pixelsgetCoordinateSpaceHeight()
public void setCoordinateSpaceWidth(int width)
width
- the width, in pixelsgetCoordinateSpaceWidth()
public java.lang.String toDataUrl()
public java.lang.String toDataUrl(java.lang.String type)
type
- the type of the data url, e.g., image/jpeg or image/png.