public class DrawPane extends Canvas implements HasDrawEndHandlers, HasDrawStartHandlers
<canvas>
tag and SVG (Scalable Vector Graphics)
where available,
and the VML (Vector Markup Language)
for legacy browsers (Internet Explorer 8 and earlier). To draw in
a DrawPane
you create DrawLine
s, DrawOval
s, DrawPath
s and other DrawItem
-based components, and place them in the DrawPane
via drawItems
or add them incrementally via addDrawItem()
.
DrawItems
support a variety of
common features, such as gradient fills
, arrowheads
, events such as click()
and built-in control knobs
for end user resizing and manipulation of shapes.
Common shapes such as rectangles
, ovals
and triangles
have dedicated DrawItem subclasses. For other shapes, consider:
DrawPath
- a multi-segment line with straight segments, defined by a series of
points
DrawPolygon
- a closed shape with straight sides, defined by a series of
points
DrawShape
- a multi-segment line or closed shape whose sides can be defined by a
series of commands, including curved arcs NOTE:To use the Drawing subsystem, include the Drawing module
in your application by including <inherits name="com.smartgwt.Drawing"/>
in your GWT module XML.
DrawRect
is configured with left:20, top:30, width:200, and height:100, the
DrawRect represents a rectangle from (20, 30) to (220, 130) in its local coordinate system. For this same DrawRect,
top
is going to be 30 even if the shape is scaled by 3x,
such that the (transformed) top coordinate in the drawing coordinate system actually lies outside the visible region
of the DrawPane. Similarly, no matter what rotation is applied, top
will continue to be 30. Use DrawItem.getBoundingBox()
to obtain the bounding box of the
item in local coordinates. Subclass properties also typically provide data in the local coordinate system, such
as DrawRect.left
, DrawRect.top
, DrawRect.width
, DrawRect.height
, DrawPath.points
, and DrawTriangle.points
.
There is a local coordinate system for each DrawItem.
DrawItem.scale
or DrawItem.rotation
, have been
applied. Since DrawGroup
s pass through applied transforms to the
underlying items, DrawGroup
properties such as DrawGroup.left
, DrawGroup.top
, DrawGroup.width
, and DrawGroup.height
, represent coordinates in the drawing
coordinate system, as does therefore DrawGroup.getBoundingBox()
. The APIs getDrawingPoint()
, getDrawingX()
, and getDrawingY()
, also return drawing coordinates.
For DrawItems with no local transforms, the drawing coordinate system is identical to the local coordinate system.
translate
, zoomLevel
and rotation
applied. Use DrawItem.getResizeBoundingBox()
to obtain the
bounding box of a DrawItem
in global coordinates. The APIs DrawItem.getPageLeft()
and DrawItem.getPageTop()
reflect global coordinates rounded to the
nearest pixel and offset by the page-relative coordinates of the DrawPane
's top left corner. (See for example Canvas.getPageLeft()
and Canvas.getPageTop()
.)
With the default global transforms, the global coordinate system is identical to the drawing coordinate system.
The view port of the DrawPane
is the rectangle in the global coordinate system from (0, 0) that is as wide as the DrawPane's inner content width
and as high as the DrawPane's inner content height
. Note: In the case of a FacetChart
showing a zoom chart
, the view port height is decreased by the height of the zoom chart.
One other coordinate system in use
by a DrawPane when drag-scrolling
is enabled is
the "viewbox coordinate system". The viewbox coordinate system is the drawing coordinate system with the translate
and zoomLevel
transforms applied.
config, configOnly, factoryCreated, factoryProperties, id, nativeObject, scClassName
Constructor and Description |
---|
DrawPane() |
DrawPane(com.google.gwt.core.client.JavaScriptObject jsObj) |
Modifier and Type | Method and Description |
---|---|
com.google.gwt.event.shared.HandlerRegistration |
addDrawEndHandler(DrawEndHandler handler)
Add a drawEnd handler.
|
void |
addDrawItem(DrawItem item,
boolean autoDraw)
Adds a draw item to this
DrawPane . |
com.google.gwt.event.shared.HandlerRegistration |
addDrawStartHandler(DrawStartHandler handler)
Add a drawStart handler.
|
java.lang.String |
addGradient(Gradient gradient)
Add a new gradient to the drawPane shared gradient list (
gradients ). |
static double |
bezier(double p1,
double cp1,
double cp2,
double p2,
double t)
Computes a cubic Bézier curve polynomial:
B(t) = (1 - t)3P1 + 3(1 -
t)2tCP1 + 3(1 - t)t2CP2 + t3P2 |
static double[] |
bezierExtrema(double p1,
double cp1,
double cp2,
double p2)
Computes the minimum and maximum value of the cubic Bézier curve polynomial defined in
bezier() , for 0 ≤ t ≤ 1 . |
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)
Deprecated.
in favor of
addGradient() |
java.lang.String |
createRadialGradient(java.lang.String id,
RadialGradient radialGradient)
Deprecated.
in favor of
addGradient() |
java.lang.String |
createSimpleGradient(java.lang.String id,
SimpleGradient simple)
Deprecated.
in favor of
addGradient() |
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. |
static double[] |
getBezierBoundingBox(Point p1,
Point cp1,
Point cp2,
Point p2)
Calculate the bounding box of the cubic Bézier curve with endpoints
p1 and p2 and
control points cp1 and cp2 . |
boolean |
getCanDragScroll()
Can the user drag-scroll the DrawPane?
|
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.
|
int |
getDrawingHeight()
When
canDragScroll is enabled, this is the height
of the area in viewbox coordinates that can be accessed through drag-scrolling. |
Point |
getDrawingPoint()
Returns the point of the last event in the
drawing coordinate
system . |
int |
getDrawingWidth()
When
canDragScroll is enabled, this is the width
of the area in viewbox coordinates that can be accessed through drag-scrolling. |
int |
getDrawingX()
Returns the X coordinate in the
drawing coordinate system of the
last event. |
int |
getDrawingY()
Returns the Y coordinate in the
drawing coordinate system of the
last event. |
DrawItem[] |
getDrawItems()
Array of DrawItems to initially display in this DrawPane.
|
java.lang.String |
getEditProxyConstructor()
Default class used to construct the
EditProxy for this component when the component is
first placed into edit mode . |
Gradient |
getGradient(java.lang.String gradientID)
Returns gradient for gradientID.
|
Gradient[] |
getGradients()
Array of gradients that can be referenced by DrawItems placed on this DrawPane.
|
com.smartgwt.logicalstructure.core.LogicalStructureObject |
getLogicalStructure()
Getter implementing the
LogicalStructure interface,
which supports Eclipse's logical structure debugging facility. |
static DrawPane |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
static Point[] |
getPolygonPoints(int width,
int height,
int xc,
int yc,
double[] angles)
Computes an array of Points for a polygon that has an equal distance from its center to any of its vertices and that
fits in the given width and height.
|
java.lang.String |
getPrintHTML(PrintProperties printProperties,
PrintHTMLCallback callback)
Retrieves printable HTML for this component and all printable subcomponents.
|
static Point[] |
getRegularPolygonPoints(int n,
int width,
int height,
int xc,
int yc,
double startAngle)
Calls
getPolygonPoints() with angles spread evenly
over the full 360 degrees. |
float |
getRotation()
Deprecated.
|
double |
getRotationAsDouble()
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()
Deprecated.
|
double |
getZoomLevelAsDouble()
Zoom for the
DrawPane as a whole, where 1 is normal size. |
void |
refreshNow()
Immediately draws or redraws any items of this
DrawPane that are scheduled to be drawn or redrawn after a
delay. |
void |
removeGradient(java.lang.String gradientID)
Removes gradient for gradientID.
|
void |
rotate(double degrees)
Synonym of
setRotation() . |
static void |
scaleAndCenter(int width,
int height,
int xc,
int yc,
Point... points)
Computes the top-, left-, bottom-, and right-most coordinates in a list of points, then translates and scales all points
to fit the entire shape into the given width and height.
|
static void |
scaleAndCenterBezier(int width,
int height,
int xc,
int yc,
Point startPoint,
Point endPoint,
Point controlPoint1,
Point controlPoint2)
Computes the top-, left-, bottom-, and right-most coordinates containing the Bézier curve defined by
startPoint , controlPoint1 , controlPoint2 , and endPoint , then
translates and scales these four points to fit the entire curve into the given width and height. |
void |
setCanDragScroll(boolean canDragScroll)
Can the user drag-scroll the DrawPane?
|
static void |
setDefaultProperties(DrawPane drawPaneProperties)
Class level method to set the default properties of this class.
|
void |
setDrawingHeight(int drawingHeight)
When
canDragScroll is enabled, this is the height
of the area in viewbox coordinates that can be accessed through drag-scrolling. |
void |
setDrawingWidth(int drawingWidth)
When
canDragScroll is enabled, this is the width
of the area in viewbox coordinates that can be accessed through drag-scrolling. |
void |
setDrawItems(DrawItem... drawItems)
Array of DrawItems to initially display in this DrawPane.
|
void |
setEditProxyConstructor(java.lang.String editProxyConstructor)
Default class used to construct the
EditProxy for this component when the component is
first placed into edit mode . |
void |
setGradients(Gradient... gradients)
Array of gradients that can be referenced by DrawItems placed on this DrawPane.
|
com.smartgwt.logicalstructure.core.LogicalStructureObject |
setLogicalStructure(com.smartgwt.logicalstructure.widgets.drawing.DrawPaneLogicalStructure s)
Setter implementing the
LogicalStructure interface,
which supports Eclipse's logical structure debugging facility. |
void |
setRotation(double rotation)
Rotation in degrees for the
DrawPane as a whole about the center of the DrawPane . |
void |
setRotation(float rotation)
Deprecated.
|
void |
setTranslate(int[] translate)
Global translation.
|
void |
setZoomLevel(double zoomLevel)
Zoom for the
DrawPane as a whole, where 1 is normal size. |
void |
setZoomLevel(float zoomLevel)
Deprecated.
|
void |
zoom(double zoomLevel)
Synonym of
setZoomLevel() . |
void |
zoom(float zoomLevel)
Deprecated.
|
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, addSnapAlignCandidate, addStyleName, addVisibilityChangedHandler, adjustForContent, animateFade, 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, animateShow, animateShow, animateShow, asSGWTComponent, blur, bringToFront, clear, clickMaskUp, clickMaskUp, contains, contains, containsEvent, containsFocus, containsPoint, containsPoint, deparent, depeer, disable, enable, encloses, focus, focusInNextTabElement, focusInPreviousTabElement, getAbsoluteLeft, getAbsoluteTop, getAccessKey, getAlwaysShowScrollbars, getAnimateAcceleration, getAnimateFadeTime, getAnimateHideAcceleration, getAnimateHideTime, getAnimateMoveAcceleration, getAnimateMoveTime, getAnimateRectAcceleration, getAnimateRectTime, getAnimateResizeAcceleration, getAnimateResizeTime, getAnimateScrollAcceleration, getAnimateScrollTime, getAnimateShowAcceleration, getAnimateShowEffect, getAnimateShowTime, getAnimateTime, getAppImgDir, getAriaRole, getAutoDraw, getAutoMaskComponents, getAutoShowParent, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorder, getBottom, getById, getByJSObject, getByLocalId, getCanAcceptDrop, getCanDrag, getCanDragReposition, getCanDragResize, getCanDrop, getCanDropBefore, getCanFocus, getCanHover, getCanSelectText, getCanvasAutoChild, getCanvasItem, getChildren, getChildrenResizeSnapAlign, getChildrenSnapAlign, getChildrenSnapCenterAlign, getChildrenSnapEdgeAlign, getChildrenSnapResizeToGrid, getChildrenSnapToGrid, getClassName, getComponentMask, getComponentMaskDefaults, getContentElement, getContents, getContextMenu, getCursor, getDataPath, getDefaultHeight, getDefaultWidth, getDestroyed, getDestroying, getDisabled, getDisabledCursor, getDisableTouchScrollingForDrag, getDoubleClickDelay, getDragAppearance, getDragIntersectStyle, getDragMaskType, getDragOpacity, getDragRepositionAppearance, getDragRepositionCursor, getDragResizeAppearance, getDragScrollDelay, getDragStartDistance, getDragTarget, getDragType, getDropTypes, getDropTypesAsString, getDynamicContents, getEdgeBackgroundColor, getEdgeCenterBackgroundColor, getEdgeImage, getEdgeMarginSize, getEdgeOffset, getEdgeOpacity, getEdgeShowCenter, getEdgeSize, getEditNode, getEditProxy, getElement, getElement, 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, getHtmlElement, getHtmlPosition, getImage, getImgURL, getImgURL, getInnerContentHeight, getInnerContentWidth, getInnerHeight, getInnerWidth, getIsGroup, getIsPrinting, getIsSnapAlignCandidate, getKeepInParentRect, getLayoutAlign, getLeavePageSpace, getLeft, getLeftAsString, getLocateChildrenBy, getLocateChildrenType, getLocatePeersBy, getLocatePeersType, getMargin, getMasterCanvas, getMasterElement, getMatchElement, getMaxHeight, getMaxWidth, getMenuConstructor, getMinHeight, getMinNonEdgeSize, getMinWidth, getMomentumScrollMinSpeed, getMouseStillDownDelay, getMouseStillDownInitialDelay, getNextZIndex, getNoDoubleClicks, getNoDropCursor, getOffsetHeight, getOffsetWidth, getOffsetX, getOffsetY, getOpacity, getOuterElement, getOverflow, getPadding, getPageBottom, getPageLeft, getPageRect, getPageRight, getPageTop, getPanelContainer, getParentCanvas, getParentElement, getPeers, getPercentBox, getPercentSource, getPosition, getPrefix, getPrintChildrenAbsolutelyPositioned, getPrintHTML, getPrompt, getProportionalResizeModifiers, getProportionalResizing, getRect, getRedrawOnResize, getResizeBarTarget, getResizeFrom, getRight, getScrollbarSize, getScrollBottom, getScrollHeight, getScrollLeft, getScrollRight, getScrollTop, getScrollWidth, getShadowDepth, getShadowImage, getShadowOffset, getShadowSoftness, getShouldPrint, getShowCustomScrollbars, getShowDragShadow, getShowEdges, getShowHover, getShowHoverComponents, getShowResizeBar, getShowShadow, getShowSnapGrid, getShrinkElementOnHide, getSkinImgDir, getSnapAlignCandidates, getSnapAlignCenterLineStyle, getSnapAlignEdgeLineStyle, getSnapAxis, getSnapEdge, getSnapHDirection, getSnapHGap, getSnapOffsetLeft, getSnapOffsetTop, getSnapOnDrop, getSnapPosition, getSnapPosition, getSnapResizeToAlign, getSnapResizeToGrid, getSnapTo, getSnapToAlign, getSnapToCenterAlign, getSnapToEdgeAlign, getSnapToGrid, getSnapVDirection, getSnapVGap, getStyleName, getTabIndex, getTestInstance, getTitle, getTooltip, getTop, getTopAsString, getTopElement, getUseBackMask, getUseDragMask, getUseNativeDrag, getUseOpacityFilter, getUseTouchScrolling, getValuesManager, getViewportHeight, getViewportWidth, getVisibility, getVisibleHeight, getVisibleWidth, getVSnapOrigin, getVSnapOrigin, getVSnapPosition, getVSnapPosition, getWidth, getWidthAsString, getZIndex, getZIndex, handleHover, hide, hideClickMask, hideClickMask, hideComponentMask, hideComponentMask, hideContextMenu, imgHTML, imgHTML, imgHTML, intersects, isDirty, isDisabled, isDrawn, isFocused, isVisible, keyUp, layoutChildren, linkHTML, linkHTML, linkHTML, linkHTML, linkHTML, linkHTML, markForDestroy, markForRedraw, markForRedraw, moveAbove, moveBelow, moveBy, moveTo, onAttach, onDetach, onInit, pageScrollDown, pageScrollUp, parentResized, placeNear, placeNear, placeNear, printComponents, provideRuleContext, redraw, redraw, removeChild, removeChild, removePeer, removePeer, removeSnapAlignCandidate, resizeBy, resizeTo, resizeTo, revealChild, revealChild, scrollBy, scrollByPercent, scrollTo, scrollTo, scrollTo, scrollToBottom, scrollToLeft, scrollToPercent, scrollToRight, scrollToTop, sendToBack, setAccessKey, setAlign, setAllowExternalFilters, setAlwaysShowScrollbars, setAnimateAcceleration, setAnimateFadeTime, setAnimateHideAcceleration, setAnimateHideTime, setAnimateMoveAcceleration, setAnimateMoveTime, setAnimateRectAcceleration, setAnimateRectTime, setAnimateResizeAcceleration, setAnimateResizeTime, setAnimateScrollAcceleration, setAnimateScrollTime, setAnimateShowAcceleration, setAnimateShowEffect, setAnimateShowTime, setAnimateTime, setAppImgDir, setAriaRole, setAriaState, setAutoChildConstructor, setAutoChildProperties, setAutoChildProperties, setAutoChildProperties, setAutoChildProperties, setAutoChildVisibility, setAutoDraw, setAutoHeight, setAutoMaskComponents, setAutoShowParent, setAutoWidth, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBottom, setCanAcceptDrop, setCanDrag, setCanDragReposition, setCanDragResize, setCanDrop, setCanDropBefore, setCanFocus, setCanHover, setCanSelectText, setChildren, setChildrenResizeSnapAlign, setChildrenSnapAlign, setChildrenSnapCenterAlign, setChildrenSnapEdgeAlign, setChildrenSnapResizeToGrid, setChildrenSnapToGrid, setComponentMaskDefaults, setContents, setContextMenu, setCursor, setDataPath, setDefaultHeight, setDefaultPageSpace, setDefaultProperties, setDefaultWidth, setDisabled, setDisabledCursor, setDisableTouchScrollingForDrag, setDoubleClickDelay, setDragAppearance, setDragIntersectStyle, setDragMaskType, setDragOpacity, setDragRepositionAppearance, setDragRepositionCursor, setDragResizeAppearance, setDragScrollDelay, setDragStartDistance, setDragTarget, setDragType, setDropTypes, setDropTypes, setDynamicContents, setEdgeBackgroundColor, setEdgeCenterBackgroundColor, setEdgeImage, setEdgeMarginSize, setEdgeOffset, setEdgeOpacity, setEdgeShowCenter, setEdgeSize, setEditMode, setEditMode, setEditMode, setElement, setExtraSpace, setFacetId, setGroupBorderCSS, setGroupLabelBackgroundColor, setGroupLabelStyleName, setGroupTitle, setHeight, setHeight, setHeight, setHeight100, setHideUsingDisplayNone, setHoverAlign, setHoverAutoDestroy, setHoverDelay, setHoverHeight, setHoverMoveWithMouse, setHoverOpacity, setHoverStyle, setHoverVAlign, setHoverWidth, setHoverWrap, setHtmlElement, setHtmlPosition, setImage, setImage, setInitHandler, setIsGroup, setIsSnapAlignCandidate, setKeepInParentRect, setKeepInParentRect, setKeepInParentRect, setLayoutAlign, setLayoutAlign, setLeavePageSpace, setLeft, setLeft, setLocateChildrenBy, setLocateChildrenType, setLocatePeersBy, setLocatePeersType, setLogicalStructure, setMargin, setMatchElement, setMaxHeight, setMaxWidth, setMenuConstructor, setMinHeight, setMinNonEdgeSize, setMinWidth, setMomentumScrollMinSpeed, setMouseStillDownDelay, setMouseStillDownInitialDelay, setNeverUseFilters, setNoDoubleClicks, setNoDropCursor, setOpacity, setOverflow, setPadding, setPageLeft, setPageTop, setParentCanvas, setParentElement, setPeers, setPercentBox, setPercentSource, setPosition, setPrefix, setPrintChildrenAbsolutelyPositioned, setPrompt, setProportionalResizeModifiers, setProportionalResizing, setRect, setRect, setRedrawOnResize, setResizeBarTarget, setResizeFrom, setResizeFrom, setRight, setScrollbarConstructor, setScrollbarSize, setShadowDepth, setShadowImage, setShadowOffset, setShadowSoftness, setShouldPrint, setShowCustomScrollbars, setShowDragShadow, setShowEdges, setShowHover, setShowHoverComponents, setShowResizeBar, setShowShadow, setShowSnapGrid, setShrinkElementOnHide, setSkinImgDir, setSmoothFade, setSnapAlignCandidates, setSnapAlignCenterLineStyle, setSnapAlignEdgeLineStyle, setSnapAxis, setSnapEdge, setSnapHDirection, setSnapHGap, setSnapOffsetLeft, setSnapOffsetTop, setSnapOnDrop, setSnapResizeToAlign, setSnapResizeToGrid, setSnapTo, setSnapToAlign, setSnapToCenterAlign, setSnapToEdgeAlign, setSnapToGrid, setSnapVDirection, setSnapVGap, setStyleName, setTabIndex, setTitle, setTooltip, setTop, setTop, setUseBackMask, setUseDragMask, setUseNativeDrag, setUseOpacityFilter, setUseTouchScrolling, setValuesManager, setVisibility, setVisible, setWidth, setWidth, setWidth, setWidth100, setZIndex, shouldDragScroll, show, showClickMask, showComponentMask, showComponentMask, showNextTo, showNextTo, showNextTo, showNextTo, showPrintPreview, showPrintPreview, showPrintPreview, showPrintPreview, showRecursively, updateEditNode, updateHover, updateHover, updateShadow, visibleAtPoint, willAcceptDrop
addDrawHandler, applyFactoryProperties, 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, getHandlerCount, getID, getInnerHTML, getJsObj, getOrCreateJsObj, getRef, getScClassName, hasAutoAssignedID, hashCode, initNativeObject, internalSetID, internalSetID, isConfigOnly, isCreated, isFactoryCreated, onBind, onDestroy, onDraw, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setDragTracker, setFactoryCreated, setID, setJavaScriptObject, setLogicalStructure, setNullProperty, setPosition, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setProperty, setScClassName, toString
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getLayoutData, getParent, isAttached, isOrWasAttached, onBrowserEvent, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents, unsinkEvents
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getStyleElement, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent
public DrawPane()
public DrawPane(com.google.gwt.core.client.JavaScriptObject jsObj)
public static DrawPane getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public 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. For usage tips on this
param, see SGWTProperties
.AutoChildUsage
public 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. For usage tips on this
param, see SGWTProperties
.AutoChildUsage
protected com.google.gwt.core.client.JavaScriptObject create()
public void setCanDragScroll(boolean canDragScroll) throws java.lang.IllegalStateException
setCanDragScroll
in class Canvas
canDragScroll
- Default value is falsejava.lang.IllegalStateException
- this property cannot be changed after the component has been createdsetDrawingWidth(int)
,
setDrawingHeight(int)
public boolean getCanDragScroll()
getCanDragScroll
in class Canvas
getDrawingWidth()
,
getDrawingHeight()
public void setDrawingHeight(int drawingHeight) throws java.lang.IllegalStateException
canDragScroll
is enabled, this is the height
of the area in viewbox coordinates that can be accessed through drag-scrolling.drawingHeight
- Default value is 1000java.lang.IllegalStateException
- this property cannot be changed after the component has been createdpublic int getDrawingHeight()
canDragScroll
is enabled, this is the height
of the area in viewbox coordinates that can be accessed through drag-scrolling.public void setDrawingWidth(int drawingWidth) throws java.lang.IllegalStateException
canDragScroll
is enabled, this is the width
of the area in viewbox coordinates that can be accessed through drag-scrolling.drawingWidth
- Default value is 1000java.lang.IllegalStateException
- this property cannot be changed after the component has been createdpublic int getDrawingWidth()
canDragScroll
is enabled, this is the width
of the area in viewbox coordinates that can be accessed through drag-scrolling.public void setDrawItems(DrawItem... drawItems) throws java.lang.IllegalStateException
drawItems
- Default value is nulljava.lang.IllegalStateException
- this property cannot be changed after the component has been createdpublic DrawItem[] getDrawItems()
public void setEditProxyConstructor(java.lang.String editProxyConstructor) throws java.lang.IllegalStateException
EditProxy
for this component when the component is
first placed into edit mode
.setEditProxyConstructor
in class Canvas
editProxyConstructor
- See SCClassName
. Default value is "DrawPaneEditProxy"java.lang.IllegalStateException
- this property cannot be changed after the component has been createdpublic java.lang.String getEditProxyConstructor()
EditProxy
for this component when the component is
first placed into edit mode
.getEditProxyConstructor
in class Canvas
SCClassName
public void setGradients(Gradient... gradients) throws java.lang.IllegalStateException
gradients
- Default value is nulljava.lang.IllegalStateException
- this property cannot be changed after the component has been createdpublic Gradient[] getGradients()
public void setRotation(float rotation)
GwtFloatVsDouble
DrawPane
as a whole about the center of the DrawPane
. The positive
direction corresponds to clockwise rotation (for example, 45 is rotation clockwise by 45 degrees and -10 is rotation
counterclockwise by 10 degrees).
rotation
of the DrawPane
.rotation
- the new rotation in degrees. The positive direction corresponds to clockwise rotation.. Default value is 0public float getRotation()
GwtFloatVsDouble
DrawPane
as a whole about the center of the DrawPane
. The positive
direction corresponds to clockwise rotation (for example, 45 is rotation clockwise by 45 degrees and -10 is rotation
counterclockwise by 10 degrees).public void setRotation(double rotation)
DrawPane
as a whole about the center of the DrawPane
. The positive
direction corresponds to clockwise rotation (for example, 45 is rotation clockwise by 45 degrees and -10 is rotation
counterclockwise by 10 degrees).
rotation
of the DrawPane
.rotation
- the new rotation in degrees. The positive direction corresponds to clockwise rotation.. Default value is 0public double getRotationAsDouble()
DrawPane
as a whole about the center of the DrawPane
. The positive
direction corresponds to clockwise rotation (for example, 45 is rotation clockwise by 45 degrees and -10 is rotation
counterclockwise by 10 degrees).public void setTranslate(int[] translate) throws java.lang.IllegalStateException
translate
- Default value is nulljava.lang.IllegalStateException
- this property cannot be changed after the component has been createdpublic int[] getTranslate()
public void setZoomLevel(float zoomLevel)
GwtFloatVsDouble
DrawPane
as a whole, where 1 is normal size.
DrawPane
to the specified magnification, maintaining the current viewport position.zoomLevel
- Desired zoom level as a float where 1.0
is equivalent to 100% magnification. Must be greater than 0.. Default value is 1public float getZoomLevel()
GwtFloatVsDouble
DrawPane
as a whole, where 1 is normal size.public void setZoomLevel(double zoomLevel)
DrawPane
as a whole, where 1 is normal size.
DrawPane
to the specified magnification, maintaining the current viewport position.zoomLevel
- Desired zoom level as a float where 1.0
is equivalent to 100% magnification. Must be greater than 0.. Default value is 1public double getZoomLevelAsDouble()
DrawPane
as a whole, where 1 is normal size.public void addDrawItem(DrawItem item, boolean autoDraw)
DrawPane
. If already added to a DrawPane
, the draw item is removed
from its current DrawPane
and added to this DrawPane
. NOTE: For performance reasons, this
DrawPane
may draw the new item on a delay to allow multiple items to be added and drawn at one time. The
refreshNow()
API will force the item to be drawn
immediately.
item
- item to add.autoDraw
- If explicitly set to false, and this drawPane is drawn, don't draw the newly added itempublic java.lang.String addGradient(Gradient gradient)
gradients
). If the gradient does not have an ID a new one
will be assigned.gradient
- gradient to addpublic java.lang.String createLinearGradient(java.lang.String id, LinearGradient linearGradient)
addGradient()
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)
addGradient()
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)
addGradient()
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 com.google.gwt.event.shared.HandlerRegistration addDrawEndHandler(DrawEndHandler handler)
Called after we finish drawing to the underlying HTML5 <canvas> element of a DrawPane, after the last DrawItem
has been drawn. Only called if the
Com.smartgwt.client.widgets.drawing.events.DrawEndEvent.drawingType is com.smartgwt.client.types.DrawingType#BITMAP
.
addDrawEndHandler
in interface HasDrawEndHandlers
handler
- the drawEnd handlerHandlerRegistration
used to remove this handlerpublic com.google.gwt.event.shared.HandlerRegistration addDrawStartHandler(DrawStartHandler handler)
Called when we start drawing to the underlying HTML5 <canvas> element of a DrawPane, right after the element is
cleared. Only called if the Com.smartgwt.client.widgets.drawing.events.DrawStartEvent.drawingType is com.smartgwt.client.types.DrawingType#BITMAP
.
addDrawStartHandler
in interface HasDrawStartHandlers
handler
- the drawStart handlerHandlerRegistration
used to remove this handlerpublic 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
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, Img.src
.
This
method will directly return the data URL on modern browsers when using <canvas>-style rendering (the default), and
if there are no DrawImage
s in this DrawPane
that load
cross-domain images.
On legacy browers (any version of IE in "quirks" mode, all versions of IE prior to 9.0), or if
there is a DrawImage
that loads a cross-domain image, 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.
Note: It is recommended to
pass a callback instead of relying on the method returning the data URL directly. This is because the callback will
always be called with the generated data URL, whereas work-arounds for browser bugs may require asynchronous generation
of the data URL, meaning that a data URL might not be returned immediately in certain browsers for certain
DrawPane
contents.
public java.lang.String getDataURL(DataURLCallback callback)
The returned "data:" URLs can be used
anywhere a URL to an image is valid, for example, Img.src
.
This
method will directly return the data URL on modern browsers when using <canvas>-style rendering (the default), and
if there are no DrawImage
s in this DrawPane
that load
cross-domain images.
On legacy browers (any version of IE in "quirks" mode, all versions of IE prior to 9.0), or if
there is a DrawImage
that loads a cross-domain image, 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.
Note: It is recommended to
pass a callback instead of relying on the method returning the data URL directly. This is because the callback will
always be called with the generated data URL, whereas work-arounds for browser bugs may require asynchronous generation
of the data URL, meaning that a data URL might not be returned immediately in certain browsers for certain
DrawPane
contents.
callback
- callback to fire when the data URL is available. The callback is called regardless of whether the data URL is also
returned.public Point getDrawingPoint()
drawing coordinate
system
. To give a concrete example, suppose that this DrawPane
has zoomLevel
2 and drag-panning is not enabled (just to simplify
this example). If getOffsetX()
and getOffsetY()
is (0, 0) (i.e. the mouse pointer is located at the top left
point of this DrawPane
), then getDrawingPoint() would return (0, 0). If getOffsetX/Y() is (20, 40), then
getDrawingPoint() would return (10, 20) because when the 2× zoom level is applied, (10, 20) is translated to (20,
40) on the screen. You could, for example, create a new DrawLine
with startPoint
(10, 20) and when this line is drawn on screen,
the position of the line's start point would be at offset (20, 40) on screen.
public int getDrawingX()
drawing coordinate system
of the
last event. Note: If you need both the X and Y coordinates in the drawing coordinate system of the last event, it is
more efficient to call getDrawingPoint()
instead.
See the documentation of getDrawingPoint()
for
a clarifying example.
public int getDrawingY()
drawing coordinate system
of the
last event. Note: If you need both the X and Y coordinates in the drawing coordinate system of the last event, it is
more efficient to call getDrawingPoint()
instead.
See the documentation of getDrawingPoint()
for
a clarifying example.
public Gradient getGradient(java.lang.String gradientID)
gradientID
- ID of gradient to retrievepublic 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 refreshNow()
DrawPane
that are scheduled to be drawn or redrawn after a
delay. For performance reasons, this DrawPane
may delay refreshing its display to allow for multiple
draw item updates to be drawn at the same time. If this is occurring, refreshNow() will immediately refresh the display
instead of refreshing the display in a timer.
public void removeGradient(java.lang.String gradientID)
gradientID
- ID of gradient to removepublic void rotate(double degrees)
setRotation()
.degrees
- the new rotation in degrees. The positive direction corresponds to clockwise rotation.public void zoom(float zoomLevel)
GwtFloatVsDouble
setZoomLevel()
.zoomLevel
- Desired zoom level as a float where 1.0
is equivalent to 100% magnification. Must be greater than 0.public void zoom(double zoomLevel)
setZoomLevel()
.zoomLevel
- Desired zoom level as a float where 1.0
is equivalent to 100% magnification. Must be greater than 0.public static double bezier(double p1, double cp1, double cp2, double p2, double t)
B(t) = (1 - t)3P1 + 3(1 -
t)2tCP1 + 3(1 - t)t2CP2 + t3P2
p1
- starting point coordinatecp1
- first control point coordinatecp2
- second control point coordinatep2
- end point coordinatet
- the value of the parameter of the curve, between 0 and 1B(t)
at t
public static double[] bezierExtrema(double p1, double cp1, double cp2, double p2)
bezier()
, for 0 ≤ t ≤ 1
.p1
- starting point coordinatecp1
- first control point coordinatecp2
- second control point coordinatep2
- end point coordinatepublic static double[] getBezierBoundingBox(Point p1, Point cp1, Point cp2, Point p2)
p1
and p2
and
control points cp1
and cp2
.p1
- start point of the curvecp1
- first cubic Bézier control pointcp2
- second cubic Bézier control pointp2
- end point of the curve(x1, y1)
is the top-left point of the bounding box and the point
(x2, y2)
is the bottom-right point of the bounding box.public static Point[] getPolygonPoints(int width, int height, int xc, int yc, double[] angles)
width
- width of target spaceheight
- height of target spacexc
- center point xyc
- center point yangles
- the complete list of angles (in radians) with respect to the center point at which the polygon must have verticespublic static Point[] getRegularPolygonPoints(int n, int width, int height, int xc, int yc, double startAngle)
getPolygonPoints()
with angles spread evenly
over the full 360 degrees.n
- the number of vertices the polygonwidth
- width of target spaceheight
- height of target spacexc
- center point xyc
- center point ystartAngle
- the angle (in radians) with respect to the center point of the first vertex of the polygonpublic static void scaleAndCenter(int width, int height, int xc, int yc, Point... points)
width
- width of target spaceheight
- height of target spacexc
- center point xyc
- center point ypoints
- list of points to scale and translatepublic static void scaleAndCenterBezier(int width, int height, int xc, int yc, Point startPoint, Point endPoint, Point controlPoint1, Point controlPoint2)
startPoint
, controlPoint1
, controlPoint2
, and endPoint
, then
translates and scales these four points to fit the entire curve into the given width and height.width
- width of target spaceheight
- height of target spacexc
- center point xyc
- center point ystartPoint
- start point of the curveendPoint
- end point of the curvecontrolPoint1
- first cubic Bézier control pointcontrolPoint2
- second cubic Bézier control pointpublic static void setDefaultProperties(DrawPane drawPaneProperties)
Note: This method is intended for setting default attributes only and will affect 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. Calling this method after instances have been created can result in undefined behavior, since it bypasses any setters and a class instance may have already examined a particular property and not be expecting any changes through this route.
drawPaneProperties
- properties that should be used as new defaults when instances of this class are createdSGWTProperties
public 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 Canvas
printProperties
- 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 methods
public com.smartgwt.logicalstructure.core.LogicalStructureObject setLogicalStructure(com.smartgwt.logicalstructure.widgets.drawing.DrawPaneLogicalStructure s)
LogicalStructure
interface,
which supports Eclipse's logical structure debugging facility.public com.smartgwt.logicalstructure.core.LogicalStructureObject getLogicalStructure()
LogicalStructure
interface,
which supports Eclipse's logical structure debugging facility.getLogicalStructure
in interface LogicalStructure
getLogicalStructure
in class Canvas