Class CanvasWidget
java.lang.Object
com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.Widget
com.google.gwt.user.client.ui.FocusWidget
cn.mapway.ui.client.widget.canvas.CanvasWidget
- All Implemented Interfaces:
com.google.gwt.animation.client.AnimationScheduler.AnimationCallback,com.google.gwt.event.dom.client.HasAllDragAndDropHandlers,com.google.gwt.event.dom.client.HasAllFocusHandlers,com.google.gwt.event.dom.client.HasAllGestureHandlers,com.google.gwt.event.dom.client.HasAllKeyHandlers,com.google.gwt.event.dom.client.HasAllMouseHandlers,com.google.gwt.event.dom.client.HasAllTouchHandlers,com.google.gwt.event.dom.client.HasBlurHandlers,com.google.gwt.event.dom.client.HasClickHandlers,com.google.gwt.event.dom.client.HasDoubleClickHandlers,com.google.gwt.event.dom.client.HasDragEndHandlers,com.google.gwt.event.dom.client.HasDragEnterHandlers,com.google.gwt.event.dom.client.HasDragHandlers,com.google.gwt.event.dom.client.HasDragLeaveHandlers,com.google.gwt.event.dom.client.HasDragOverHandlers,com.google.gwt.event.dom.client.HasDragStartHandlers,com.google.gwt.event.dom.client.HasDropHandlers,com.google.gwt.event.dom.client.HasFocusHandlers,com.google.gwt.event.dom.client.HasGestureChangeHandlers,com.google.gwt.event.dom.client.HasGestureEndHandlers,com.google.gwt.event.dom.client.HasGestureStartHandlers,com.google.gwt.event.dom.client.HasKeyDownHandlers,com.google.gwt.event.dom.client.HasKeyPressHandlers,com.google.gwt.event.dom.client.HasKeyUpHandlers,com.google.gwt.event.dom.client.HasMouseDownHandlers,com.google.gwt.event.dom.client.HasMouseMoveHandlers,com.google.gwt.event.dom.client.HasMouseOutHandlers,com.google.gwt.event.dom.client.HasMouseOverHandlers,com.google.gwt.event.dom.client.HasMouseUpHandlers,com.google.gwt.event.dom.client.HasMouseWheelHandlers,com.google.gwt.event.dom.client.HasTouchCancelHandlers,com.google.gwt.event.dom.client.HasTouchEndHandlers,com.google.gwt.event.dom.client.HasTouchMoveHandlers,com.google.gwt.event.dom.client.HasTouchStartHandlers,com.google.gwt.event.logical.shared.HasAttachHandlers,com.google.gwt.event.shared.HasHandlers,com.google.gwt.user.client.EventListener,com.google.gwt.user.client.ui.Focusable,com.google.gwt.user.client.ui.HasEnabled,com.google.gwt.user.client.ui.HasFocus,com.google.gwt.user.client.ui.HasVisibility,com.google.gwt.user.client.ui.IsWidget,com.google.gwt.user.client.ui.SourcesClickEvents,com.google.gwt.user.client.ui.SourcesFocusEvents,com.google.gwt.user.client.ui.SourcesKeyboardEvents,com.google.gwt.user.client.ui.SourcesMouseEvents
- Direct Known Subclasses:
ColorCanvas,HueChooser
public class CanvasWidget
extends com.google.gwt.user.client.ui.FocusWidget
implements com.google.gwt.animation.client.AnimationScheduler.AnimationCallback
CanvasWidget
颜色面板
- Author:
- zhang
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled -
Field Summary
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(double timestamp) com.google.gwt.dom.client.CanvasElementReturns the attached Canvas Element.com.google.gwt.canvas.dom.client.ContextgetContext(String contextId) Gets the rendering context that may be used to draw on this canvas.com.google.gwt.canvas.dom.client.Context2dReturns a 2D rendering context.intGets the height of the internal canvas coordinate space.intGets the width of the internal canvas coordinate space.doublegetDpr()protected voidonDraw(double timestamp) 需要绘制画布protected voidonLoad()protected voidonUnload()voidredraw()voidsetContinueDraw(boolean continueDraw) voidsetCoordinateSpaceHeight(int height) Sets the height of the internal canvas coordinate space.voidsetCoordinateSpaceWidth(int width) Sets the width of the internal canvas coordinate space.voidsetPixelSize(int width, int height) 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 CanvasWidgetwrap(com.google.gwt.dom.client.CanvasElement 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, setTabIndexMethods 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, removeFromParent, setLayoutData, sinkEvents, unsinkEventsMethods 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, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
-
Constructor Details
-
CanvasWidget
public CanvasWidget()
-
-
Method Details
-
wrap
-
onLoad
protected void onLoad()- Overrides:
onLoadin classcom.google.gwt.user.client.ui.Widget
-
getDpr
public double getDpr() -
resizeWindow
-
getSpaceSize
-
getCanvasElement
public com.google.gwt.dom.client.CanvasElement 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
public com.google.gwt.canvas.dom.client.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
public void setCoordinateSpaceHeight(int height) Sets the height of the internal canvas coordinate space.- Parameters:
height- 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:
-
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.
-
setPixelSize
public void setPixelSize(int width, int height) - Overrides:
setPixelSizein classcom.google.gwt.user.client.ui.UIObject
-
onUnload
protected void onUnload()- Overrides:
onUnloadin classcom.google.gwt.user.client.ui.Widget
-
execute
public void execute(double timestamp) - Specified by:
executein interfacecom.google.gwt.animation.client.AnimationScheduler.AnimationCallback
-
setContinueDraw
public void setContinueDraw(boolean continueDraw) -
redraw
public void redraw() -
onDraw
protected void onDraw(double timestamp) 需要绘制画布- Parameters:
timestamp-
-