Class 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 
      Constructor Description
      CanvasWidget()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute​(double timestamp)  
      com.google.gwt.dom.client.CanvasElement getCanvasElement()
      Returns the attached Canvas Element.
      com.google.gwt.canvas.dom.client.Context getContext​(String contextId)
      Gets the rendering context that may be used to draw on this canvas.
      com.google.gwt.canvas.dom.client.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.
      double getDpr()  
      Size getSpaceSize()  
      protected void onDraw​(double timestamp)
      需要绘制画布
      protected void onLoad()  
      protected void onUnload()  
      void redraw()  
      Size resizeWindow()  
      void setContinueDraw​(boolean continueDraw)  
      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.
      void setPixelSize​(int width, int height)  
      String toDataUrl()
      Returns a data URL for the current content of the canvas element.
      String toDataUrl​(String type)
      Returns a data URL for the current content of the canvas element, with a specified type.
      static CanvasWidget wrap​(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, 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, 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, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString
      • Methods inherited from interface com.google.gwt.event.shared.HasHandlers

        fireEvent
    • Constructor Detail

      • CanvasWidget

        public CanvasWidget()
    • Method Detail

      • wrap

        public static CanvasWidget wrap​(com.google.gwt.dom.client.CanvasElement element)
      • onLoad

        protected void onLoad()
        Overrides:
        onLoad in class com.google.gwt.user.client.ui.Widget
      • getDpr

        public double getDpr()
      • resizeWindow

        public Size resizeWindow()
      • getSpaceSize

        public Size getSpaceSize()
      • getCanvasElement

        public com.google.gwt.dom.client.CanvasElement getCanvasElement()
        Returns the attached Canvas Element.
        Returns:
        the Canvas Element
      • getContext

        public com.google.gwt.canvas.dom.client.Context getContext​(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 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(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()
      • getCoordinateSpaceWidth

        public int getCoordinateSpaceWidth()
        Gets the width of the internal canvas coordinate space.
        Returns:
        the width, in pixels
        See Also:
        setCoordinateSpaceWidth(int)
      • 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 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 String toDataUrl​(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.
      • setPixelSize

        public void setPixelSize​(int width,
                                 int height)
        Overrides:
        setPixelSize in class com.google.gwt.user.client.ui.UIObject
      • onUnload

        protected void onUnload()
        Overrides:
        onUnload in class com.google.gwt.user.client.ui.Widget
      • execute

        public void execute​(double timestamp)
        Specified by:
        execute in interface com.google.gwt.animation.client.AnimationScheduler.AnimationCallback
      • setContinueDraw

        public void setContinueDraw​(boolean continueDraw)
      • redraw

        public void redraw()
      • onDraw

        protected void onDraw​(double timestamp)
        需要绘制画布
        Parameters:
        timestamp -