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, 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 calling addItem.

DrawGroups handle events by having an explicitly specified group rectangle (see 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()
          Executed when the left mouse is clicked (pressed and then released) on this widget.
 com.google.gwt.core.client.JavaScriptObject create()
           
 void erase()
          Erases all DrawItems in the DrawGroup.
 int[] getBoundingBox()
          Returns the top, left, top+height, left+width
 int[] getCenter()
          Get the center coordinates of the 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.
 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.
 int getWidth()
          Width of the group rectangle in pixels relative to the DrawPane.
 java.lang.Boolean mouseDown()
          Executed when the left mouse down is pressed on this widget.
 java.lang.Boolean mouseMove()
          Executed when the mouse moves within this widget.
 java.lang.Boolean mouseOut()
          Executed when the mouse leaves this widget.
 java.lang.Boolean mouseOver()
          Executed when mouse enters this widget.
 java.lang.Boolean mouseUp()
          Executed when the left mouse is released on this widget.
 void moveBy(int left, int top)
          Move all member drawItems by the specified number of pixels.
 void moveTo(int left, int top)
          Set both the left and top coordinate of this drawGroup 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(float x, float y)
          Scale all drawItem[] shapes by the x, y multipliers
 void scaleTo(float x, float y)
          Scale the each item in the drawGroup by the x, y multipliers
 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 setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
           
 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 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, addDragStartHandler, addDragStopHandler, addMouseDownHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMovedHandler, addResizedHandler, addShowContextMenuHandler, computeAngle, convertToDrawItemArray, destroy, draw, getAttributeAsIntArray, getCanDrag, getContextMenu, getDestroyed, getDestroying, getDragStartDistance, getDrawGroup, getDrawPane, getEndArrow, getFillColor, getFillGradient, getFillOpacity, getKnobs, getLineCap, getLineColor, getLineOpacity, getLinePattern, getLineWidth, getMoveKnobOffset, getMoveKnobPoint, getPageLeft, getPageTop, getRef, getResizeKnobPoints, getRotation, getScale, getShadow, getStartArrow, getSvgString, hide, hideKnobs, isInBounds, isPointInPath, resizeBy, resizeTo, rotateBy, rotateTo, setCanDrag, setContextMenu, setDragStartDistance, setDrawGroup, setDrawPane, setEndArrow, setFillColor, setFillGradient, setFillOpacity, setKnobs, setLineCap, setLineColor, setLineOpacity, setLinePattern, setLineWidth, setMoveKnobOffset, setMoveKnobPoint, setResizeKnobPoints, setRotation, setScale, setShadow, setStartArrow, show, showKnobs
 
Methods inherited from class com.smartgwt.client.core.BaseClass
doAddHandler, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getConfig, getHandlerCount, getID, getJsObj, getOrCreateJsObj, getScClassName, isCreated, onInit, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setID, 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)

setJavaScriptObject

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

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: Set the height of his drawGrop group rectangle. Note that setting this attribute will not move or resize the drawItems in this group.

Parameters:
height - new height for the event rect. Default value is 1

getHeight

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

Returns:
int

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: Set the left coordinate of this drawGroup group rectangle. Note that setting this attribute will not move the drawItems in this group.

Parameters:
left - new left coordinate in pixels. 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: Set the top coordinate of this drawGroup group rectangle. Note that setting this attribute will not move the drawItems in this group.

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

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: Set the width of his drawGrop group rectangle. Note that setting this attribute will not move or resize the drawItems in this group.

Parameters:
width - new width for the event rect. 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()
Executed when the left mouse is clicked (pressed and then released) on this widget. No default implementation.

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

erase

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

Overrides:
erase in class DrawItem

mouseDown

public java.lang.Boolean mouseDown()
Executed when the left mouse down is pressed on this widget. No default implementation.

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()
Executed when the mouse moves within this widget. No default implementation.

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()
Executed when the mouse leaves this widget. No default implementation.

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()
Executed when mouse enters this widget. No default implementation.

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()
Executed when the left mouse is released on this widget. No default implementation.

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 left,
                   int top)
Move all member drawItems by the specified number of pixels. Also updates the group rectangle, moving it by the same offset.

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

moveTo

public void moveTo(int left,
                   int top)
Set both the left and top coordinate of this drawGroup group rectangle. Unlike DrawGroup.moveBy, this will not move the drawItems in this group.

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

scaleBy

public void scaleBy(float x,
                    float 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)
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

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 -

getBoundingBox

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

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

getCenter

public int[] getCenter()
Get the center coordinates of the rectangle

Overrides:
getCenter in class DrawItem
Returns:
x, y coordinates

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.