public class DrawPane extends Canvas
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:
To
use DrawPane in SmartGWT, include the Drawing module in your application by including <inherits
name="com.smartgwt.Drawing"/> in your GWT module XML.
config, configOnly, id, isElementSet, nativeObject, scClassName| Constructor and Description |
|---|
DrawPane() |
DrawPane(com.google.gwt.core.client.JavaScriptObject jsObj) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDrawItem(DrawItem item,
boolean autoDraw)
Add a drawItem to this drawPane (if necessary removing it from any other drawPanes)
|
static void |
changeAutoChildDefaults(java.lang.String autoChildName,
Canvas defaults)
Changes the defaults for Canvas AutoChildren named
autoChildName. |
static void |
changeAutoChildDefaults(java.lang.String autoChildName,
FormItem defaults)
Changes the defaults for FormItem AutoChildren named
autoChildName. |
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 by any DrawItem of this DrawPane.
|
java.lang.String |
createRadialGradient(java.lang.String id,
RadialGradient radialGradient)
Creates a radial gradient which can be used by any DrawItem of this DrawPane.
|
java.lang.String |
createSimpleGradient(java.lang.String id,
SimpleGradient simple)
Creates a simple linear gradient which can be used by any DrawItem of this DrawPane.
|
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. |
java.lang.String |
getDataURL()
Get a "data:" URL encoding the current contents of the DrawPane as a PNG file.
|
java.lang.String |
getDataURL(DataURLCallback callback)
Get a "data:" URL encoding the current contents of the DrawPane as a PNG file.
|
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) |
java.lang.String |
getPrintHTML(PrintProperties printProperties,
PrintHTMLCallback callback)
Retrieves printable HTML for this component and all printable subcomponents.
|
float |
getRotation()
Rotation in degrees for the DrawPane as a whole about the center of the DrawPane.
|
java.lang.String |
getSvgString()
Converts this DrawPane to the source of an
<svg> element equivalent to the current drawing. |
int[] |
getTranslate()
Global translation.
|
float |
getZoomLevel()
Zoom for the DrawPane as a whole, where 1 is normal size.
|
void |
rotate(double degrees)
Sets the
rotation of the DrawPane. |
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 in degrees for the DrawPane as a whole about the center of the DrawPane.
|
void |
setTranslate(int[] translate)
Global translation.
|
void |
setZoomLevel(float zoomLevel)
Zoom for the DrawPane as a whole, where 1 is normal size.
|
void |
zoom(double zoom)
Zoom this drawPane to the specified magnification, maintaining the current viewport position
|
void |
zoom(float zoom)
Zoom this drawPane to the specified magnification, maintaining the current viewport position
|
addChild, 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, addPeer, addPeer, addResizedHandler, addRightMouseDownHandler, addScrolledHandler, addShowContextMenuHandler, addStyleName, addVisibilityChangedHandler, adjustForContent, animateFade, animateFade, animateFade, animateFade, animateFade, animateFade, animateFade, animateHide, animateHide, animateHide, animateMove, animateMove, animateMove, animateMove, animateRect, animateRect, animateRect, animateRect, animateResize, animateResize, animateResize, animateResize, animateScroll, animateScroll, animateScroll, animateScroll, animateScroll, animateScroll, animateShow, animateShow, animateShow, asSGWTComponent, blur, bringToFront, clear, clickMaskUp, clickMaskUp, contains, contains, containsEvent, containsFocus, containsPoint, containsPoint, deparent, depeer, disable, enable, focus, focusInNextTabElement, focusInPreviousTabElement, getAbsoluteLeft, getAbsoluteTop, getAccessKey, getAnimateAcceleration, getAnimateFadeTime, getAnimateHideAcceleration, getAnimateHideTime, getAnimateMoveAcceleration, getAnimateMoveTime, getAnimateRectAcceleration, getAnimateRectTime, getAnimateResizeAcceleration, getAnimateResizeTime, getAnimateScrollAcceleration, getAnimateScrollTime, getAnimateShowAcceleration, getAnimateShowEffect, getAnimateShowTime, getAnimateTime, getAppImgDir, getAriaRole, getAutoDraw, getAutoShowParent, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorder, getBottom, getById, getByJSObject, getByLocalId, getCanAcceptDrop, getCanDragReposition, getCanDragResize, getCanDragScroll, getCanDrop, getCanDropBefore, getCanFocus, getCanHover, getCanSelectText, getCanvasAutoChild, getCanvasItem, getChildren, getChildrenSnapResizeToGrid, getChildrenSnapToGrid, getClassName, getContentElement, 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, getFormItemAutoChild, getFullDataPath, getGroupBorderCSS, getGroupLabelBackgroundColor, getGroupLabelStyleName, getGroupTitle, getHeight, getHeightAsString, getHideUsingDisplayNone, getHoverAlign, getHoverAutoDestroy, getHoverComponent, getHoverDelay, getHoverHeight, getHoverHTML, getHoverMoveWithMouse, getHoverOpacity, getHoverStyle, getHoverVAlign, getHoverWidth, getHoverWrap, getHSnapOrigin, getHSnapOrigin, getHSnapPosition, getHSnapPosition, getHtmlPosition, getImage, 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, getOuterElement, getOverflow, getPadding, getPageBottom, getPageLeft, getPageRect, getPageRight, getPageTop, getParentElement, getPeers, getPercentBox, getPercentSource, getPosition, getPrefix, getPrintChildrenAbsolutelyPositioned, 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, getTestInstance, 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, linkHTML, linkHTML, 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, 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, setAriaState, setAutoChildConstructor, setAutoChildProperties, setAutoChildProperties, setAutoChildVisibility, 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, setGroupBorderCSS, setGroupLabelBackgroundColor, setGroupLabelStyleName, setGroupTitle, setHeight, setHeight, setHeight100, setHideUsingDisplayNone, 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, setScrollbarConstructor, 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, showNextTo, showNextTo, showPrintPreview, showPrintPreview, showPrintPreview, showPrintPreview, showRecursively, updateHover, updateHover, updateShadow, visibleAtPoint, willAcceptDropaddDrawHandler, destroy, doAddHandler, doInit, doOnRender, draw, equals, error, errorIfNotCreated, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDateArray, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsFloatArray, getAttributeAsInt, getAttributeAsIntArray, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsRecord, getAttributeAsString, getAttributeAsStringArray, getConfig, getDOM, getElement, getElement, getHandlerCount, getID, getInnerHTML, getJsObj, getOrCreateJsObj, getRef, getScClassName, hashCode, initNativeObject, internalSetID, internalSetID, isConfigOnly, isCreated, onBind, onDestroy, onDraw, setAttribute, 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, toStringaddAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onLoad, onUnload, removeFromParent, setLayoutData, sinkEventsaddStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getStyleElement, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEventspublic DrawPane()
public DrawPane(com.google.gwt.core.client.JavaScriptObject jsObj)
public static DrawPane getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
setJavaScriptObject in class Canvaspublic static void changeAutoChildDefaults(java.lang.String autoChildName,
Canvas defaults)
autoChildName.autoChildName - name of an AutoChild to customize the defaults for.defaults - Canvas defaults to apply. These defaults override any existing properties
without destroying or wiping out non-overridden properties.AutoChildUsagepublic static void changeAutoChildDefaults(java.lang.String autoChildName,
FormItem defaults)
autoChildName.autoChildName - name of an AutoChild to customize the defaults for.defaults - FormItem defaults to apply. These defaults override any existing properties
without destroying or wiping out non-overridden properties.AutoChildUsageprotected com.google.gwt.core.client.JavaScriptObject create()
public void setCanDrag(java.lang.Boolean canDrag)
canDrag.setCanDrag in class CanvascanDrag - canDrag Default value is falseDragdrop overview and related methods,
Drag create Examplepublic java.lang.Boolean getCanDrag()
canDrag.getCanDrag in class CanvasDragdrop overview and related methods,
Drag create Examplepublic void setDrawItems(DrawItem... drawItems) throws java.lang.IllegalStateException
drawItems - drawItems Default value is nulljava.lang.IllegalStateException - this property cannot be changed after the component has been createdpublic DrawItem[] getDrawItems()
public void setRotation(float rotation)
rotation - rotation Default value is 0public float getRotation()
public void setZoomLevel(float zoomLevel)
zoomLevel - zoomLevel Default value is 1public float getZoomLevel()
public void addDrawItem(DrawItem item, boolean autoDraw)
item - drawItem to addautoDraw - If explicitly set to false, and this drawPane is drawn, don't draw the newly added itempublic java.lang.String createLinearGradient(java.lang.String id,
LinearGradient linearGradient)
fillGradient can reference the gradient by the given ID.id - the ID of the linear gradientlinearGradient - the linear gradientpublic java.lang.String createRadialGradient(java.lang.String id,
RadialGradient radialGradient)
fillGradient can reference the gradient by the given ID.id - the ID of the radial gradientradialGradient - the radial gradientpublic java.lang.String createSimpleGradient(java.lang.String id,
SimpleGradient simple)
fillGradient can reference the gradient by the given ID.id - the ID of the simple linear gradientsimple - the simple linear gradientpublic void destroyItems()
destroy all DrawItems currently associated with
this DrawPane, leaving the DrawPane itself intactpublic void erase()
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.
public java.lang.String getDataURL()
The returned "data:" URLs can be used
anywhere a URL to an image is valid, for example, src.
This method will directly return the data URL on modern browsers when using <canvas>-style rendering (the default).
On
legacy browers (any version of IE in "quirks" mode, all versions of IE prior to 9.0), data URL generation requires a
server trip and requires the Smart GWT Server to be installed with the same set of required .jars as are required for PDF export of charts in legacy IE.
The method will return null and a callback must be passed, which fires when the data URL has been retrieved from the
server.
If the callback is passed but no server trip is required, the callback is fired immediately.
For obtaining PNG or other image data for use in server-side processing (such as attaching to automated emails or saving to a database), see also the server-side APIs in com.isomorphic.contentexport.ImageExport.
public java.lang.String getDataURL(DataURLCallback callback)
The returned "data:" URLs can be used
anywhere a URL to an image is valid, for example, src.
This method will directly return the data URL on modern browsers when using <canvas>-style rendering (the default).
On
legacy browers (any version of IE in "quirks" mode, all versions of IE prior to 9.0), data URL generation requires a
server trip and requires the Smart GWT Server to be installed with the same set of required .jars as are required for PDF export of charts in legacy IE.
The method will return null and a callback must be passed, which fires when the data URL has been retrieved from the
server.
If the callback is passed but no server trip is required, the callback is fired immediately.
For obtaining PNG or other image data for use in server-side processing (such as attaching to automated emails or saving to a database), see also the server-side APIs in com.isomorphic.contentexport.ImageExport.
callback - callback to fire when data url is availablepublic java.lang.String getSvgString()
<svg> element equivalent to the current drawing. In
Pro edition and above, the returned string can be used with RPCManager.exportImage to download an image, or with server-side APIs in com.isomorphic.contentexport.ImageExport to
obtain various kinds of images for further server-side processing.
<svg> element.public void rotate(double degrees)
rotation of the DrawPane.degrees - the new rotation in degrees. The positive direction corresponds to clockwise rotation.public void zoom(float zoom)
zoom - Desired zoom level as a float where 1.0 is equivalent to 100% magnification.public void zoom(double zoom)
zoom - Desired zoom level as a float where 1.0 is equivalent to 100% magnification.public static void setDefaultProperties(DrawPane drawPaneProperties)
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.
drawPaneProperties - properties that should be used as new defaults when instances of this class are createdpublic java.lang.String getPrintHTML(PrintProperties printProperties, PrintHTMLCallback callback)
By default any Canvas with children will simply collect the printable HTML of its
children by calling getPrintHTML() on each child that is considered
printable.
If overriding this method for a custom component, you should either return a String of printable HTML string directly or return null, and fire the callback (if provided).
To return an empty print representation, return an empty string ("") rather than null.
The printProperties argument, if passed, must be passed to any subcomponents on
which getPrintHTML() is called.
Notes on printing
To print a DrawPane for export on IE8 and earlier, it is
PrintProperties with printForExport:true:
final PrintProperties pp = new PrintProperties(); pp.setPrintForExport(true); final String exportHTML = drawPane.getPrintHTML(pp, null);
Note: this is an override point.
getPrintHTML in class CanvasprintProperties - properties to configure printing behavior - may be null.callback - optional callback to fire. Generated HTML should be passed to the
PrintHTMLCallback.setHTML(String) method of the callback.Printing overview and related methodspublic void setTranslate(int[] translate)
throws java.lang.IllegalStateException
translate - translate Default value is nulljava.lang.IllegalStateException - this property cannot be changed after the component has been createdpublic int[] getTranslate()
public com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.widgets.drawing.DrawPaneLogicalStructure s)
public com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()
getLogicalStructure in interface LogicalStructuregetLogicalStructure in class Canvas