com.smartgwt.client.widgets.drawing
Class DrawGroup

java.lang.Object
  extended by com.smartgwt.client.core.BaseClass
      extended by com.smartgwt.client.widgets.drawing.DrawItem
          extended by com.smartgwt.client.widgets.drawing.DrawGroup
All Implemented Interfaces:
com.google.gwt.event.shared.HasHandlers, HasClickHandlers, HasDragMoveHandlers, HasDragResizeMoveHandlers, HasDragStartHandlers, HasDragStopHandlers, HasMouseDownHandlers, HasMouseMoveHandlers, HasMouseOutHandlers, HasMouseOverHandlers, HasMouseUpHandlers, HasMovedHandlers, HasResizedHandlers, HasShowContextMenuHandlers

public class DrawGroup
extends DrawItem

DrawItem subclass to manage a group of other DrawItem instances.

A DrawGroup has no local visual representation other than that of its drawItems. Adding items to a drawGroup allows for central event handling, and allows them to be manipulated (drawn, scaled, etc) together.

DrawItems are added to a DrawGroup by creating the DrawItems with drawGroup set to a drawGroup, or by creating a DrawGroup with drawItems.

DrawGroups handle events by having an explicitly specified group rectangle (see DrawGroup.getGroupRect). This rectangle has no visual representation within the draw pane (is not visible) but any user-interactions within the specified coordinates will trigger group level events.

DrawGroups may contain other DrawGroups.


Field Summary
 
Fields inherited from class com.smartgwt.client.core.BaseClass
config, id, scClassName
 
Constructor Summary
DrawGroup()
           
DrawGroup(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 
Method Summary
 java.lang.Boolean click()
          Notification fired when the user clicks on this DrawGroup.
 com.google.gwt.core.client.JavaScriptObject create()
           
 boolean dragMove()
          Notification fired for every mouseMove event triggered while the user is dragging this DrawGroup.
 boolean dragStart()
          Notification fired when the user starts to drag this DrawGroup.
 boolean dragStop()
          Notification fired when the user stops dragging this DrawGroup.
 void erase()
          Erases all DrawItems in the DrawGroup.
 int[] getBoundingBox()
          Returns the left, top, (left + width), and (top + height) values
 Point getCenter()
          Get the center point of the group rectangle.
 DrawItem[] getDrawItems()
          Initial list of DrawItems for this DrawGroup.
 Rectangle getGroupRect()
          This method will return an array of integers mapping out the coordinates (left, top, width, height) of the "group rectangle" for the group.
 int getHeight()
          Height of the group rectangle in pixels relative to the DrawPane.
 KnobType[] getKnobs()
          NOTE: DrawGroups do not support knobs.
 int getLeft()
          Left coordinate of the group rectangle in pixels relative to the DrawPane.
static DrawGroup getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 int getTop()
          Top coordinate of the group rectangle in pixels relative to the DrawPane.
 boolean getUseGroupRect()
          When should this drawGroup receive event notifications? If set to true, the developer can specify an explicit set of coordinates.
 int getWidth()
          Width of the group rectangle in pixels relative to the DrawPane.
 java.lang.Boolean mouseDown()
          Notification fired when the user presses the left mouse button on this DrawGroup.
 java.lang.Boolean mouseMove()
          Notification fired when the user moves the mouse over this DrawGroup.
 java.lang.Boolean mouseOut()
          Notification fired when the mouse leaves this DrawGroup.
 java.lang.Boolean mouseOver()
          Notification fired when the mouse enters this DrawGroup.
 java.lang.Boolean mouseUp()
          Notification fired when the user releases the left mouse button on this DrawGroup.
 void moveBy(int dX, int dY)
          Updates the DrawGroup's left coordinate by dX and the top coordinate by dY.
 void moveTo(int left, int top)
          Sets both the left and top coordinates of this DrawGroup's group rectangle.
 void rotateBy(java.lang.String degrees)
          Rotate the group by degrees.
 void rotateTo(java.lang.String degrees)
          Rotate the group to degrees.
 void scaleBy(double x, double y)
          Scale all drawItem[] shapes by the x, y multipliers
 void scaleBy(float x, float y)
          Deprecated. GwtFloatVsDouble
 void scaleTo(double x, double y)
          Scale the each item in the drawGroup by the x, y multipliers
 void scaleTo(float x, float y)
          Deprecated. GwtFloatVsDouble
static void setDefaultProperties(DrawGroup drawGroupProperties)
          Class level method to set the default properties of this class.
 void setDrawItems(DrawItem... drawItems)
          Initial list of DrawItems for this DrawGroup.
 void setHeight(int height)
          Height of the group rectangle in pixels relative to the DrawPane.
 void setKnobs(KnobType... knobs)
          NOTE: DrawGroups do not support knobs.
 void setLeft(int left)
          Left coordinate of the group rectangle in pixels relative to the DrawPane.
 void setTop(int top)
          Top coordinate of the group rectangle in pixels relative to the DrawPane.
 void setUseGroupRect(boolean useGroupRect)
          When should this drawGroup receive event notifications? If set to true, the developer can specify an explicit set of coordinates.
 void setWidth(int width)
          Width of the group rectangle in pixels relative to the DrawPane.
 
Methods inherited from class com.smartgwt.client.widgets.drawing.DrawItem
addClickHandler, addDragMoveHandler, addDragResizeMoveHandler, addDragStartHandler, addDragStopHandler, addMouseDownHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMovedHandler, addResizedHandler, addShowContextMenuHandler, computeAngle, computeAngleAsDouble, dragResizeMove, draw, getAttributeAsIntArray, getBoundingBoxAsDouble, getCanDrag, getCanHover, getContextMenu, getCursor, getDestroyed, getDestroying, getDragStartDistance, getDrawGroup, getDrawPane, getEndArrow, getFillColor, getFillGradient, getFillGradientAsString, getFillOpacity, getHoverHTML, getKeepInParentRect, getLineCap, getLineColor, getLineOpacity, getLinePattern, getLineWidth, getMoveKnobOffset, getMoveKnobPoint, getPageLeft, getPageTop, getPrompt, getRef, getResizeKnobPoints, getRotation, getRotationAsDouble, getScale, getShadow, getShowHover, getStartArrow, getSvgString, hide, hideKnobs, hideKnobs, hover, isInBounds, isPointInPath, resizeBy, resizeTo, rotateBy, rotateTo, setAttribute, setAttribute, setCanDrag, setCanHover, setContextMenu, setCursor, setDefaultProperties, setDragStartDistance, setDrawGroup, setDrawPane, setEndArrow, setFillColor, setFillGradient, setFillGradient, setFillOpacity, setKeepInParentRect, setKeepInParentRect, setLineCap, setLineColor, setLineOpacity, setLinePattern, setLineWidth, setMoveKnobOffset, setMoveKnobPoint, setPrompt, setResizeKnobPoints, setRotation, setRotation, setScale, setShadow, setShowHover, setStartArrow, show, showKnobs, showKnobs, supportsEndArrow, supportsStartArrow
 
Methods inherited from class com.smartgwt.client.core.BaseClass
asSGWTComponent, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getJsObj, getOrCreateJsObj, getScClassName, hasAutoAssignedID, internalSetID, internalSetID, isCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setID, setJavaScriptObject, setProperty, setProperty, setProperty, setProperty, setScClassName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 

Constructor Detail

DrawGroup

public DrawGroup()

DrawGroup

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

getOrCreateRef

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

create

public com.google.gwt.core.client.JavaScriptObject create()
Overrides:
create in class DrawItem

setHeight

public void setHeight(int height)
Height of the group rectangle in pixels relative to the DrawPane.

If this method is called after the component has been drawn/initialized: Sets the height of this DrawGroup's group rectangle. Note that setting the height will not move or resize the items in this DrawGroup.

Parameters:
height - new height for the group rectangle. Default value is 1

getHeight

public int getHeight()
Height of the group rectangle in pixels relative to the DrawPane.

Returns:
int

setKnobs

public void setKnobs(KnobType... knobs)
              throws java.lang.IllegalStateException
NOTE: DrawGroups do not support knobs.

Overrides:
setKnobs in class DrawItem
Parameters:
knobs - Default value is null
Throws:
java.lang.IllegalStateException - this property cannot be changed after the underlying component has been created

getKnobs

public KnobType[] getKnobs()
NOTE: DrawGroups do not support knobs.

Overrides:
getKnobs in class DrawItem
Returns:
KnobType...

setLeft

public void setLeft(int left)
Left coordinate of the group rectangle in pixels relative to the DrawPane.

If this method is called after the component has been drawn/initialized: Sets the left coordinate of this DrawGroup's group rectangle. Note that setting the left coordinate will not move the items in this DrawGroup.

Parameters:
left - new left coordinate. Default value is 0

getLeft

public int getLeft()
Left coordinate of the group rectangle in pixels relative to the DrawPane.

Returns:
int

setTop

public void setTop(int top)
Top coordinate of the group rectangle in pixels relative to the DrawPane.

If this method is called after the component has been drawn/initialized: Sets the top coordinate of this DrawGroup's group rectangle. Note that setting the top coordinate will not move the items in this DrawGroup.

Parameters:
top - new top coordinate in pixels. Default value is 0

getTop

public int getTop()
Top coordinate of the group rectangle in pixels relative to the DrawPane.

Returns:
int

setUseGroupRect

public void setUseGroupRect(boolean useGroupRect)
                     throws java.lang.IllegalStateException
When should this drawGroup receive event notifications? If set to true, the developer can specify an explicit set of coordinates. Whenever the user interacts with this rectangle, the drawGroup will be notified and the appropriate event handlers will be fired. Note that rectangle need not contain all DrawItems within the group, and is manually managed by the developer.
If set to false, the event rectangle coordinates are unused - instead as a user interacts with specific drawItems within this group, the appropriate event handler would be fired on the item, then the event would "bubble" to the drawGroup, firing the appropriate event handler at the group level as well.

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

getUseGroupRect

public boolean getUseGroupRect()
When should this drawGroup receive event notifications? If set to true, the developer can specify an explicit set of coordinates. Whenever the user interacts with this rectangle, the drawGroup will be notified and the appropriate event handlers will be fired. Note that rectangle need not contain all DrawItems within the group, and is manually managed by the developer.
If set to false, the event rectangle coordinates are unused - instead as a user interacts with specific drawItems within this group, the appropriate event handler would be fired on the item, then the event would "bubble" to the drawGroup, firing the appropriate event handler at the group level as well.

Returns:
boolean

setWidth

public void setWidth(int width)
Width of the group rectangle in pixels relative to the DrawPane.

If this method is called after the component has been drawn/initialized: Sets the width of this DrawGroup's group rectangle. Note that setting the width will not move or resize the items in this DrawGroup.

Parameters:
width - new width for the group rectangle. Default value is 1

getWidth

public int getWidth()
Width of the group rectangle in pixels relative to the DrawPane.

Returns:
int

click

public java.lang.Boolean click()
Notification fired when the user clicks on this DrawGroup.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to prevent this event from bubbling to this widget's parent, true or undefined to bubble.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY()

dragMove

public boolean dragMove()
Notification fired for every mouseMove event triggered while the user is dragging this DrawGroup. Will only fire if canDrag is true for this group.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Default drag behavior will be to reposition all items in the group (and update the group rectangle).

Returns:
false to cancel drag interaction.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY(), Drag pan Example

dragStart

public boolean dragStart()
Notification fired when the user starts to drag this DrawGroup. Will only fire if canDrag is true for this group.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Default drag behavior will be to reposition all items in the group (and update the group rectangle).

Returns:
false to cancel drag action.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY(), Drag pan Example

dragStop

public boolean dragStop()
Notification fired when the user stops dragging this DrawGroup. Will only fire if canDrag is true for this group.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to cancel drag interaction.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY()

erase

public void erase()
Erases all DrawItems in the DrawGroup.

Overrides:
erase in class DrawItem

getBoundingBox

public int[] getBoundingBox()
Returns the left, top, (left + width), and (top + height) values

Overrides:
getBoundingBox in class DrawItem
Returns:
x1, y1, x2, y2 coordinates

getCenter

public Point getCenter()
Get the center point of the group rectangle.

Returns:
the center point

mouseDown

public java.lang.Boolean mouseDown()
Notification fired when the user presses the left mouse button on this DrawGroup.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to prevent this event from bubbling to this widget's parent, true or undefined to bubble.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY()

mouseMove

public java.lang.Boolean mouseMove()
Notification fired when the user moves the mouse over this DrawGroup.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to prevent this event from bubbling to this widget's parent, true or undefined to bubble.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY(), Mouse events Example

mouseOut

public java.lang.Boolean mouseOut()
Notification fired when the mouse leaves this DrawGroup.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to prevent this event from bubbling to this widget's parent, true or undefined to bubble.
See Also:
Mouse events Example

mouseOver

public java.lang.Boolean mouseOver()
Notification fired when the mouse enters this DrawGroup.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to prevent this event from bubbling to this widget's parent, true or undefined to bubble.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY()

mouseUp

public java.lang.Boolean mouseUp()
Notification fired when the user releases the left mouse button on this DrawGroup.

Note that if useGroupRect is true, this notification will be triggered by the user interacting with the specified group rectangle for the group. If useGroupRect is false, the notification will bubble up from interactions with individual items within the group.

Returns:
false to prevent this event from bubbling to this widget's parent, true or undefined to bubble.
See Also:
Canvas.getOffsetX(), Canvas.getOffsetY(), Mouse events Example

moveBy

public void moveBy(int dX,
                   int dY)
Updates the DrawGroup's left coordinate by dX and the top coordinate by dY. Note that this does not move or resize the items in this DrawGroup.

Overrides:
moveBy in class DrawItem
Parameters:
dX - change to left coordinate in pixels
dY - change to top coordinate in pixels

moveTo

public void moveTo(int left,
                   int top)
Sets both the left and top coordinates of this DrawGroup's group rectangle. Note that this does not move or resize the items in this DrawGroup.

Parameters:
left - new left coordinate in pixels
top - new top coordinate in pixels

scaleBy

public void scaleBy(float x,
                    float y)
Deprecated. GwtFloatVsDouble

Scale all drawItem[] shapes by the x, y multipliers

Parameters:
x - scale in the x direction
y - scale in the y direction

scaleBy

public void scaleBy(double x,
                    double y)
Scale all drawItem[] shapes by the x, y multipliers

Overrides:
scaleBy in class DrawItem
Parameters:
x - scale in the x direction
y - scale in the y direction

scaleTo

public void scaleTo(float x,
                    float y)
Deprecated. GwtFloatVsDouble

Scale the each item in the drawGroup by the x, y multipliers

Parameters:
x - scale in the x direction
y - scale in the y direction

scaleTo

public void scaleTo(double x,
                    double y)
Scale the each item in the drawGroup by the x, y multipliers

Overrides:
scaleTo in class DrawItem
Parameters:
x - scale in the x direction
y - scale in the y direction

setDefaultProperties

public static void setDefaultProperties(DrawGroup drawGroupProperties)
Class level method to set the default properties of this class. If set, then all existing and subsequently created instances of this class will automatically have default properties corresponding to the properties set on the SmartGWT class instance passed to this function before its underlying SmartClient JS object was created. 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 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.

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

rotateBy

public void rotateBy(java.lang.String degrees)
Rotate the group by degrees. This is a relative rotation based on any current rotation

Parameters:
degrees -

rotateTo

public void rotateTo(java.lang.String degrees)
Rotate the group to degrees. This is an absolute rotation and does not consider any existing rotation

Parameters:
degrees -

setDrawItems

public void setDrawItems(DrawItem... drawItems)
                  throws java.lang.IllegalStateException
Initial list of DrawItems for this DrawGroup.

DrawItems can be added to a DrawGroup after initialization by setting drawGroup.

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

getDrawItems

public DrawItem[] getDrawItems()
Initial list of DrawItems for this DrawGroup.

DrawItems can be added to a DrawGroup after initialization by setting drawGroup.

Returns:
DrawItem

getGroupRect

public Rectangle getGroupRect()
This method will return an array of integers mapping out the coordinates (left, top, width, height) of the "group rectangle" for the group. This is the area of the drawPane where user interactions will fire event notifications on this drawGroup.

Developers may also use left, top, width and height to manage each coordinate directly.

Returns:
4 element array containing left, top, width, height of the group rectangle.