com.smartgwt.client.widgets.drawing
Class DrawPane

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.smartgwt.client.widgets.BaseWidget
              extended by com.smartgwt.client.widgets.Canvas
                  extended by com.smartgwt.client.widgets.drawing.DrawPane
All Implemented Interfaces:
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.HasVisibility, com.google.gwt.user.client.ui.IsWidget, LogicalStructure, HasClickHandlers, HasDoubleClickHandlers, HasDragMoveHandlers, HasDragRepositionMoveHandlers, HasDragRepositionStartHandlers, HasDragRepositionStopHandlers, HasDragResizeMoveHandlers, HasDragResizeStartHandlers, HasDragResizeStopHandlers, HasDragStartHandlers, HasDragStopHandlers, HasDropHandlers, HasDropMoveHandlers, HasDropOutHandlers, HasDropOverHandlers, HasFocusChangedHandlers, HasHoverHandlers, HasHoverHiddenHandlers, HasKeyDownHandlers, HasKeyPressHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseStillDownHandlers, HasMouseUpHandlers, HasMouseWheelHandlers, HasMovedHandlers, HasParentMovedHandlers, HasResizedHandlers, HasRightMouseDownHandlers, HasScrolledHandlers, HasShowContextMenuHandlers, HasVisibilityChangedHandlers
Direct Known Subclasses:
FacetChart, Gauge

public class DrawPane
extends Canvas

Container for DrawLine, DrawOval, DrawPath, and other DrawItem-based components. These components provide consistent cross-browser APIs for rendering shapes using using the browsers' built in vector graphics capabilities. These include SVG (Scalable Vector Graphics) where available, VML (Vector Markup Language) for Microsoft browsers, and the HTML5 <canvas> tag.

You can use any of the following approaches to create DrawPanes and DrawItems:

DrawPane only
Create a DrawPane with drawItems set to an array of DrawItem instances or DrawItem declaration objects, and it will manage those DrawItems.
DrawItem only
Create and draw a DrawItem, and it will use a default DrawPane, which you can access via the drawPane property, eg myDrawItem.drawPane.bringToFront().
Both
Create DrawPanes with or without initial drawItems, then create DrawItems with their drawPane property set to an existing DrawPane instance.

To use DrawPane in SmartGWT, include the Drawing module in your application by including <inherits name="com.smartgwt.Drawing"/> in your GWT module XML.


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.smartgwt.client.widgets.BaseWidget
config, configOnly, id, isElementSet, nativeObject, scClassName
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
DrawPane()
           
DrawPane(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 
Method Summary
 void addDrawItem(DrawItem item, boolean autoDraw)
          Add a drawItem to this drawPane (if necessary removing it from any other drawPanes)
protected  com.google.gwt.core.client.JavaScriptObject create()
           
 java.lang.String createLinearGradient(java.lang.String id, LinearGradient linearGradient)
          Creates a linear gradient which can be used within any DrawItem Any DrawItems fillGradient can reference this gradient by the given name.
 java.lang.String createRadialGradient(java.lang.String id, RadialGradient radialGradient)
          Creates a radial gradient which can be used within any DrawItem Any DrawItems fillGradient can reference this gradient by the given name.
 java.lang.String createSimpleGradient(java.lang.String id, SimpleGradient simple)
          Creates a simple linear gradient which can be used within any DrawItem Any DrawItems fillGradient can reference this gradient by the given name.
 void destroyItems()
          Permanently destroy all DrawItems currently associated with this DrawPane, leaving the DrawPane itself intact
 void erase()
          Call DrawItem.erase on all DrawItems currently associated with the DrawPane.
 java.lang.Boolean getCanDrag()
          In order to enable dragging of drawItems, this property must be set to true, in addition to canDrag.
 DrawItem[] getDrawItems()
          Array of DrawItems to initially display in this DrawPane.
 com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()
           
static DrawPane getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 float getRotation()
          Rotation for the DrawPane as a whole, in degrees.
 java.lang.String getSvgString()
          Converts this DrawPane to the source of an <svg> element equivalent to the current drawing.
 float getZoomLevel()
          Zoom for the drawPane as a whole, where 1 is normal size.
 void setCanDrag(java.lang.Boolean canDrag)
          In order to enable dragging of drawItems, this property must be set to true, in addition to canDrag.
static void setDefaultProperties(DrawPane drawPaneProperties)
          Class level method to set the default properties of this class.
 void setDrawItems(DrawItem... drawItems)
          Array of DrawItems to initially display in this DrawPane.
 void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.widgets.drawing.DrawPaneLogicalStructure s)
           
 void setRotation(float rotation)
          Rotation for the DrawPane as a whole, in degrees.
 void setZoomLevel(float zoomLevel)
          Zoom for the drawPane as a whole, where 1 is normal size.
 void zoom(float zoom)
          Zoom this drawPane to the specified magnification, maintaining the current viewport position
 
Methods inherited from class com.smartgwt.client.widgets.Canvas
addChild, addChild, addChild, addChild, addClickHandler, addDoubleClickHandler, addDragMoveHandler, addDragRepositionMoveHandler, addDragRepositionStartHandler, addDragRepositionStopHandler, addDragResizeMoveHandler, addDragResizeStartHandler, addDragResizeStopHandler, addDragStartHandler, addDragStopHandler, addDropHandler, addDropMoveHandler, addDropOutHandler, addDropOverHandler, addFocusChangedHandler, addHoverHandler, addHoverHiddenHandler, addKeyDownHandler, addKeyPressHandler, addMouseDownHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseStillDownHandler, addMouseUpHandler, addMouseWheelHandler, addMovedHandler, addParentMovedHandler, addPeer, addPeer, addResizedHandler, addRightMouseDownHandler, addScrolledHandler, addShowContextMenuHandler, addStyleName, addVisibilityChangedHandler, adjustForContent, animateFade, animateFade, animateFade, animateHide, animateHide, animateHide, animateMove, animateMove, animateMove, animateMove, animateRect, animateRect, animateRect, animateResize, animateResize, animateResize, animateScroll, animateScroll, animateScroll, animateShow, animateShow, animateShow, blur, bringToFront, clear, clickMaskUp, clickMaskUp, contains, contains, containsEvent, containsFocus, containsPoint, containsPoint, convertToCanvasArray, deparent, depeer, disable, enable, focus, getAbsoluteLeft, getAbsoluteTop, getAccessKey, getAnimateAcceleration, getAnimateFadeTime, getAnimateHideAcceleration, getAnimateHideTime, getAnimateMoveAcceleration, getAnimateMoveTime, getAnimateRectAcceleration, getAnimateRectTime, getAnimateResizeAcceleration, getAnimateResizeTime, getAnimateScrollAcceleration, getAnimateScrollTime, getAnimateShowAcceleration, getAnimateShowEffect, getAnimateShowTime, getAnimateTime, getAppImgDir, getAriaRole, getAttribute, getAutoDraw, getAutoShowParent, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorder, getBottom, getById, getCanAcceptDrop, getCanDragReposition, getCanDragResize, getCanDragScroll, getCanDrop, getCanDropBefore, getCanFocus, getCanHover, getCanSelectText, getCanvasItem, getChildren, getChildrenSnapResizeToGrid, getChildrenSnapToGrid, getClassName, getContents, getContextMenu, getCursor, getDataPath, getDefaultHeight, getDefaultWidth, getDestroyed, getDestroying, getDisabled, getDisabledCursor, getDoubleClickDelay, getDragAppearance, getDragIntersectStyle, getDragOpacity, getDragRepositionAppearance, getDragRepositionCursor, getDragResizeAppearance, getDragScrollDelay, getDragStartDistance, getDragTarget, getDragType, getDropTypes, getDynamicContents, getEdgeBackgroundColor, getEdgeCenterBackgroundColor, getEdgeImage, getEdgeMarginSize, getEdgeOffset, getEdgeOpacity, getEdgeShowCenter, getEdgeSize, getEventEdge, getEventEdge, getExtraSpace, getFacetId, getFullDataPath, getGroupTitle, getHeight, getHeightAsString, getHoverAlign, getHoverAutoDestroy, getHoverComponent, getHoverDelay, getHoverHeight, getHoverHTML, getHoverMoveWithMouse, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getHoverWrap, getHSnapOrigin, getHSnapOrigin, getHSnapPosition, getHSnapPosition, getHtmlPosition, getImgURL, getImgURL, getInnerContentHeight, getInnerContentWidth, getInnerHeight, getInnerWidth, getIsGroup, getKeepInParentRect, getLayoutAlign, getLeft, getLeftAsString, getLocateChildrenBy, getLocateChildrenType, getLocatePeersBy, getLocatePeersType, getMargin, getMasterElement, getMatchElement, getMaxHeight, getMaxWidth, getMenuConstructor, getMinHeight, getMinWidth, getMouseStillDownDelay, getMouseStillDownInitialDelay, getNextZIndex, getNoDoubleClicks, getOffsetHeight, getOffsetWidth, getOffsetX, getOffsetY, getOpacity, getOverflow, getPadding, getPageBottom, getPageLeft, getPageRect, getPageRight, getPageTop, getParentElement, getParentElements, getPeers, getPercentBox, getPercentSource, getPosition, getPrefix, getPrintChildrenAbsolutelyPositioned, getPrintHTML, getPrintHTML, getPrompt, getRect, getRedrawOnResize, getResizeBarTarget, getResizeFrom, getRight, getScrollbarSize, getScrollBottom, getScrollHeight, getScrollLeft, getScrollRight, getScrollTop, getScrollWidth, getShadowDepth, getShadowImage, getShadowOffset, getShadowSoftness, getShouldPrint, getShowCustomScrollbars, getShowDragShadow, getShowEdges, getShowHover, getShowHoverComponents, getShowResizeBar, getShowShadow, getSkinImgDir, getSnapAxis, getSnapEdge, getSnapHDirection, getSnapHGap, getSnapOffsetLeft, getSnapOffsetTop, getSnapOnDrop, getSnapResizeToGrid, getSnapTo, getSnapToGrid, getSnapVDirection, getSnapVGap, getStyleName, getTabIndex, getTitle, getTooltip, getTop, getTopAsString, getTopElement, getUseBackMask, getUseOpacityFilter, getValuesManager, getViewportHeight, getViewportWidth, getVisibility, getVisibleHeight, getVisibleWidth, getVSnapOrigin, getVSnapOrigin, getVSnapPosition, getVSnapPosition, getWidth, getWidthAsString, getZIndex, handleHover, hide, hideClickMask, hideClickMask, hideContextMenu, imgHTML, imgHTML, imgHTML, intersects, isDirty, isDisabled, isDrawn, isVisible, keyUp, layoutChildren, linkHTML, linkHTML, markForDestroy, markForRedraw, markForRedraw, moveAbove, moveBelow, moveBy, moveTo, onAttach, onDetach, onInit, parentResized, printComponents, redraw, redraw, removeChild, removeChild, removePeer, removePeer, resizeBy, resizeTo, resizeTo, scrollBy, scrollByPercent, scrollTo, scrollTo, scrollToBottom, scrollToLeft, scrollToPercent, scrollToRight, scrollToTop, sendToBack, setAccessKey, setAlign, setAllowExternalFilters, setAnimateAcceleration, setAnimateFadeTime, setAnimateHideAcceleration, setAnimateHideTime, setAnimateMoveAcceleration, setAnimateMoveTime, setAnimateRectAcceleration, setAnimateRectTime, setAnimateResizeAcceleration, setAnimateResizeTime, setAnimateScrollAcceleration, setAnimateScrollTime, setAnimateShowAcceleration, setAnimateShowEffect, setAnimateShowTime, setAnimateTime, setAppImgDir, setAriaRole, setAutoDraw, setAutoHeight, setAutoShowParent, setAutoWidth, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBottom, setCanAcceptDrop, setCanDragReposition, setCanDragResize, setCanDragScroll, setCanDrop, setCanDropBefore, setCanFocus, setCanHover, setCanSelectText, setCanvasItem, setChildren, setChildrenSnapResizeToGrid, setChildrenSnapToGrid, setContents, setContextMenu, setCursor, setDataPath, setDefaultHeight, setDefaultProperties, setDefaultWidth, setDisabled, setDisabledCursor, setDoubleClickDelay, setDragAppearance, setDragIntersectStyle, setDragOpacity, setDragRepositionAppearance, setDragRepositionCursor, setDragResizeAppearance, setDragScrollDelay, setDragStartDistance, setDragTarget, setDragType, setDropTypes, setDynamicContents, setEdgeBackgroundColor, setEdgeCenterBackgroundColor, setEdgeImage, setEdgeMarginSize, setEdgeOffset, setEdgeOpacity, setEdgeShowCenter, setEdgeSize, setExtraSpace, setFacetId, setGroupTitle, setHeight, setHeight, setHeight100, setHoverAlign, setHoverAutoDestroy, setHoverDelay, setHoverHeight, setHoverMoveWithMouse, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setHoverWrap, setHtmlPosition, setImage, setImage, setIsGroup, setKeepInParentRect, setKeepInParentRect, setKeepInParentRect, setLayoutAlign, setLayoutAlign, setLeft, setLeft, setLocateChildrenBy, setLocateChildrenType, setLocatePeersBy, setLocatePeersType, setLogicalStructure, setMargin, setMatchElement, setMaxHeight, setMaxWidth, setMenuConstructor, setMinHeight, setMinWidth, setMouseStillDownDelay, setMouseStillDownInitialDelay, setNeverUseFilters, setNoDoubleClicks, setOpacity, setOverflow, setPadding, setPageLeft, setPageTop, setParentElement, setPeers, setPercentBox, setPercentSource, setPosition, setPrefix, setPrintChildrenAbsolutelyPositioned, setPrompt, setRect, setRect, setRedrawOnResize, setResizeBarTarget, setResizeFrom, setResizeFrom, setRight, setScrollbarSize, setShadowDepth, setShadowImage, setShadowOffset, setShadowSoftness, setShouldPrint, setShowCustomScrollbars, setShowDragShadow, setShowEdges, setShowHover, setShowHoverComponents, setShowResizeBar, setShowShadow, setSkinImgDir, setSmoothFade, setSnapAxis, setSnapEdge, setSnapHDirection, setSnapHGap, setSnapOffsetLeft, setSnapOffsetTop, setSnapOnDrop, setSnapResizeToGrid, setSnapTo, setSnapToGrid, setSnapVDirection, setSnapVGap, setStyleName, setTabIndex, setTitle, setTooltip, setTop, setTop, setUseBackMask, setUseOpacityFilter, setValuesManager, setVisibility, setVisible, setWidth, setWidth, setWidth100, setZIndex, shouldDragScroll, show, showClickMask, showNextTo, showNextTo, showPrintPreview, showPrintPreview, showPrintPreview, showPrintPreview, showRecursively, updateHover, updateHover, updateShadow, visibleAtPoint, willAcceptDrop
 
Methods inherited from class com.smartgwt.client.widgets.BaseWidget
addDrawHandler, destroy, doAddHandler, doInit, doOnRender, draw, equals, error, errorIfNotCreated, fireEvent, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDateArray, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsFloatArray, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getConfig, getDOM, getElement, getElement, getHandlerCount, getID, getInnerHTML, getJsObj, getOrCreateJsObj, getRef, getScClassName, hashCode, initNativeObject, isConfigOnly, isCreated, onDestroy, onDraw, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setDragTracker, setElement, setHtmlElement, setID, setLogicalStructure, setNullProperty, setPosition, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setScClassName, toString
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getStyleElement, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

DrawPane

public DrawPane()

DrawPane

public DrawPane(com.google.gwt.core.client.JavaScriptObject jsObj)
Method Detail

getOrCreateRef

public static DrawPane getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)

setJavaScriptObject

public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
Overrides:
setJavaScriptObject in class Canvas

create

protected com.google.gwt.core.client.JavaScriptObject create()
Overrides:
create in class Canvas

setCanDrag

public void setCanDrag(java.lang.Boolean canDrag)
In order to enable dragging of drawItems, this property must be set to true, in addition to canDrag.

Overrides:
setCanDrag in class Canvas
Parameters:
canDrag - canDrag Default value is false
See Also:
Dragdrop overview and related methods, Drag create Example

getCanDrag

public java.lang.Boolean getCanDrag()
In order to enable dragging of drawItems, this property must be set to true, in addition to canDrag.

Overrides:
getCanDrag in class Canvas
Returns:
Boolean
See Also:
Dragdrop overview and related methods, Drag create Example

setDrawItems

public void setDrawItems(DrawItem... drawItems)
                  throws java.lang.IllegalStateException
Array of DrawItems to initially display in this DrawPane.

Parameters:
drawItems - drawItems Default value is null
Throws:
java.lang.IllegalStateException - this property cannot be changed after the component has been created

getDrawItems

public DrawItem[] getDrawItems()
Array of DrawItems to initially display in this DrawPane.

Returns:
DrawItem

setRotation

public void setRotation(float rotation)
Rotation for the DrawPane as a whole, in degrees. Applied to all DrawItems.

Parameters:
rotation - rotation Default value is 0

getRotation

public float getRotation()
Rotation for the DrawPane as a whole, in degrees. Applied to all DrawItems.

Returns:
float

setZoomLevel

public void setZoomLevel(float zoomLevel)
Zoom for the drawPane as a whole, where 1 is normal size. Applied to all DrawItems.

Parameters:
zoomLevel - zoomLevel Default value is 1

getZoomLevel

public float getZoomLevel()
Zoom for the drawPane as a whole, where 1 is normal size. Applied to all DrawItems.

Returns:
float

addDrawItem

public void addDrawItem(DrawItem item,
                        boolean autoDraw)
Add a drawItem to this drawPane (if necessary removing it from any other drawPanes)

Parameters:
item - drawItem to add
autoDraw - If explicitly set to false, and this drawPane is drawn, don't draw the newly added item

createLinearGradient

public java.lang.String createLinearGradient(java.lang.String id,
                                             LinearGradient linearGradient)
Creates a linear gradient which can be used within any DrawItem Any DrawItems fillGradient can reference this gradient by the given name.

Parameters:
id - the name of the linear gradient
linearGradient - the linear gradient
Returns:
id

createRadialGradient

public java.lang.String createRadialGradient(java.lang.String id,
                                             RadialGradient radialGradient)
Creates a radial gradient which can be used within any DrawItem Any DrawItems fillGradient can reference this gradient by the given name.

Parameters:
id - the name of the radial gradient
radialGradient - the radial gradient
Returns:
id

createSimpleGradient

public java.lang.String createSimpleGradient(java.lang.String id,
                                             SimpleGradient simple)
Creates a simple linear gradient which can be used within any DrawItem Any DrawItems fillGradient can reference this gradient by the given name.

Parameters:
id - the name of the linear gradient
simple -
Returns:
id

destroyItems

public void destroyItems()
Permanently destroy all DrawItems currently associated with this DrawPane, leaving the DrawPane itself intact


erase

public void erase()
Call DrawItem.erase on all DrawItems currently associated with the DrawPane.

The DrawItems will continue to exist, and you can call draw() on them to make them appear again, or destroy to get rid of them permanetly. Use DrawPane.destroyItems to permanently get rid of all DrawItems.


getSvgString

public java.lang.String getSvgString()
Converts this DrawPane to the source of an <svg> element equivalent to the current drawing.

Returns:
the source of an <svg> element.

zoom

public void zoom(float zoom)
Zoom this drawPane to the specified magnification, maintaining the current viewport position

Parameters:
zoom - Desired zoom level as a float where 1.0 is equivalent to 100% magnification.

setDefaultProperties

public static void setDefaultProperties(DrawPane drawPaneProperties)
Class level method to set the default properties of this class. If set, then all subsequent instances of this class will automatically have the default properties that were set when this method was called. This is a powerful feature that eliminates the need for users to create a separate hierarchy of subclasses that only alter the default properties of this class. Can also be used for skinning / styling purposes.

Note: This method is intended for setting default attributes only and will effect all instances of the underlying class (including those automatically generated in JavaScript). This method should not be used to apply standard EventHandlers or override methods for a class - use a custom subclass instead.

Parameters:
drawPaneProperties - properties that should be used as new defaults when instances of this class are created

setLogicalStructure

public com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.widgets.drawing.DrawPaneLogicalStructure s)

getLogicalStructure

public com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()
Specified by:
getLogicalStructure in interface LogicalStructure
Overrides:
getLogicalStructure in class Canvas