|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.smartgwt.client.core.BaseClass
com.smartgwt.client.widgets.drawing.DrawItem
public class DrawItem
Base class for graphical elements drawn in a DrawPane. All properties and methods documented here are available on all DrawItems unless otherwise specified.
Note that DrawItems as such should never be created, only concrete
subclasses such as DrawGroup and DrawLine.
See DrawPane for the
different approaches to create DrawItems.
| Field Summary |
|---|
| Fields inherited from class com.smartgwt.client.core.BaseClass |
|---|
config, id, scClassName |
| Constructor Summary | |
|---|---|
DrawItem()
|
|
DrawItem(JavaScriptObject jsObj)
|
|
| Method Summary | |
|---|---|
HandlerRegistration |
addClickHandler(ClickHandler handler)
Add a click handler. |
HandlerRegistration |
addDragMoveHandler(DragMoveHandler handler)
Add a dragMove handler. |
HandlerRegistration |
addDragStartHandler(DragStartHandler handler)
Add a dragStart handler. |
HandlerRegistration |
addDragStopHandler(DragStopHandler handler)
Add a dragStop handler. |
HandlerRegistration |
addMouseDownHandler(MouseDownHandler handler)
Add a mouseDown handler. |
HandlerRegistration |
addMouseMoveHandler(MouseMoveHandler handler)
Add a mouseMove handler. |
HandlerRegistration |
addMouseOutHandler(MouseOutHandler handler)
Add a mouseOut handler. |
HandlerRegistration |
addMouseOverHandler(MouseOverHandler handler)
Add a mouseOver handler. |
HandlerRegistration |
addMouseUpHandler(MouseUpHandler handler)
Add a mouseUp handler. |
HandlerRegistration |
addMovedHandler(MovedHandler handler)
Add a moved handler. |
HandlerRegistration |
addResizedHandler(ResizedHandler handler)
Add a resized handler. |
HandlerRegistration |
addShowContextMenuHandler(ShowContextMenuHandler handler)
Add a showContextMenu handler. |
float |
computeAngle(int px1,
int py1,
int px2,
int py2)
returns the angle in degrees between any two points |
static DrawItem[] |
convertToDrawItemArray(JavaScriptObject nativeArray)
|
JavaScriptObject |
create()
|
void |
destroy()
Permanently destroys this DrawItem, similar to Canvas.destroy. |
void |
draw()
Draw this item into it's current DrawPane. |
void |
erase()
Erase this drawItem's visual representation and remove it from it's DrawGroup (if any) and DrawPane. |
protected int[] |
getAttributeAsIntArray(String property)
|
int[] |
getBoundingBox()
Returns the startPoint endPoint |
Boolean |
getCanDrag()
Is this drawItem draggable? Note that dragging must be enabled for the dragPane in which this item is rendered via canDrag for this to have an effect. |
int[] |
getCenter()
Get the center coordinates of the rectangle |
Menu |
getContextMenu()
Context menu to show for this object, an instance of the Menu widget. |
Boolean |
getDestroyed()
Flag indicating a drawItem has been destroyed, similar to destroyed. |
Boolean |
getDestroying()
Flag indicating a drawItem is mid-destruction, similar to destroying. |
int |
getDragStartDistance()
Number of pixels the cursor needs to move before the EventHandler starts a drag operation. |
DrawGroup |
getDrawGroup()
DrawGroup this drawItem is a member of. |
DrawPane |
getDrawPane()
DrawPane this drawItem should draw in. |
ArrowStyle |
getEndArrow()
Style of arrowhead to draw at the end of the line or path. |
String |
getFillColor()
Fill color to use for shapes. |
Gradient |
getFillGradient()
Fill gradient to use for shapes. |
float |
getFillOpacity()
Opacity of the fillColor, as a number between 0 (transparent) and 1 (opaque). |
KnobType[] |
getKnobs()
Array of control knobs to display for this item. |
LineCap |
getLineCap()
Style of drawing the endpoints of a line. |
String |
getLineColor()
Line color |
float |
getLineOpacity()
Opacity for lines, as a number between 0 (transparent) and 1 (opaque). |
LinePattern |
getLinePattern()
Pattern for lines, eg "solid" or "dash" |
int |
getLineWidth()
Pixel width for lines. |
int[] |
getMoveKnobOffset()
Array holds 2 values representing the x and y offset from moveKnobPoint. |
String |
getMoveKnobPoint()
If this item is showing a "move" control
knob, this attribute
specifies where the knob should appear with respect to the drawItem. |
static DrawItem |
getOrCreateRef(JavaScriptObject jsObj)
|
int |
getPageLeft()
Returns the page-relative left coordinate of the widget on the page, in pixels. |
int |
getPageTop()
Returns the page-relative top coordinate of the widget on the page, in pixels |
static DrawItem |
getRef(JavaScriptObject jsObj)
|
String[] |
getResizeKnobPoints()
If this item is showing "resize" control
knobs, this attribute
specifies which sides / edges should show knobs. |
float |
getRotation()
Rotation in degrees. |
int[] |
getScale()
Array holds 2 values representing scaling along x and y dimensions. |
Shadow |
getShadow()
Shadow used for all DrawItem subtypes. |
ArrowStyle |
getStartArrow()
Style of arrowhead to draw at the beginning of the line or path. |
void |
getSvgString()
Generates a string containing the SVG source of this DrawItem. |
void |
hide()
Hide this drawItem. |
void |
hideKnobs(KnobType... knobType)
Hides a set of control knobs for this drawItem. |
Boolean |
isInBounds(int x,
int y)
returns true if point is in getBoundingBox() |
Boolean |
isPointInPath(int x,
int y)
returns true if point is in path |
void |
moveBy(int dX,
int dY)
Move the shape by the specified deltas for the left and top coordinate. |
void |
resizeBy(int dX,
int dY)
Resize the shape by the specified deltas for the left and top coordinate. |
void |
resizeTo(int width,
int height)
Resize to the specified size |
void |
rotateBy(float degrees)
Rotate the shape by the relative rotation in degrees |
void |
rotateTo(float degrees)
Rotate the shape by the absolute rotation in degrees |
void |
scaleBy(float x,
float y)
Scale the shape by the x, y multipliers |
void |
scaleTo(float x,
float y)
Scale the shape by the x, y multipliers |
void |
setCanDrag(Boolean canDrag)
Is this drawItem draggable? Note that dragging must be enabled for the dragPane in which this item is rendered via canDrag for this to have an effect. |
void |
setContextMenu(Menu contextMenu)
Context menu to show for this object, an instance of the Menu widget. |
void |
setDragStartDistance(int dragStartDistance)
Number of pixels the cursor needs to move before the EventHandler starts a drag operation. |
void |
setDrawGroup(DrawGroup drawGroup)
DrawGroup this drawItem is a member of. |
void |
setDrawPane(DrawPane drawPane)
DrawPane this drawItem should draw in. |
void |
setEndArrow(ArrowStyle endArrow)
Style of arrowhead to draw at the end of the line or path. |
void |
setFillColor(String fillColor)
Fill color to use for shapes. |
void |
setFillGradient(Gradient fillGradient)
Fill gradient to use for shapes. |
void |
setFillOpacity(float fillOpacity)
Opacity of the fillColor, as a number between 0 (transparent) and 1 (opaque). |
void |
setJavaScriptObject(JavaScriptObject jsObj)
|
void |
setKnobs(KnobType... knobs)
Array of control knobs to display for this item. |
void |
setLineCap(LineCap lineCap)
Style of drawing the endpoints of a line. |
void |
setLineColor(String lineColor)
Line color If this method is called after the component has been drawn/initialized: Update lineColor for this drawItem. |
void |
setLineOpacity(float lineOpacity)
Opacity for lines, as a number between 0 (transparent) and 1 (opaque). |
void |
setLinePattern(LinePattern linePattern)
Pattern for lines, eg "solid" or "dash" If this method is called after the component has been drawn/initialized: Update linePattern for this drawItem. |
void |
setLineWidth(int lineWidth)
Pixel width for lines. |
void |
setMoveKnobOffset(int[] offset)
Array holds 2 values representing the x and y offset from moveKnobPoint. |
void |
setMoveKnobPoint(String moveKnobPoint)
If this item is showing a "move" control
knob, this attribute
specifies where the knob should appear with respect to the drawItem. |
void |
setResizeKnobPoints(String[] resizeKnobPoints)
If this item is showing "resize" control
knobs, this attribute
specifies which sides / edges should show knobs. |
void |
setRotation(float rotation)
Rotation in degrees. |
void |
setScale(int[] scale)
Array holds 2 values representing scaling along x and y dimensions. |
void |
setShadow(Shadow shadow)
Shadow used for all DrawItem subtypes. |
void |
setStartArrow(ArrowStyle startArrow)
Style of arrowhead to draw at the beginning of the line or path. |
void |
show()
Make this drawItem visible. |
void |
showKnobs(KnobType... knobType)
Shows a set of control knobs for this drawItem. |
| 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 |
|---|
public DrawItem()
public DrawItem(JavaScriptObject jsObj)
| Method Detail |
|---|
public static DrawItem getOrCreateRef(JavaScriptObject jsObj)
public void setJavaScriptObject(JavaScriptObject jsObj)
public JavaScriptObject create()
create in class BaseClasspublic void setCanDrag(Boolean canDrag)
canDrag for this to have an effect.
Note : This is an advanced setting
canDrag - canDrag Default value is falsepublic Boolean getCanDrag()
canDrag for this to have an effect.
public void setContextMenu(Menu contextMenu)
Note: if Canvas.destroy is called on a canvas, any specified context menu is not
automatically destroyed as well. This is in contrast to MenuButtons which
automatically destroy their specified menu by default. The
behavior is intentional as context menus are commonly reused across components.
contextMenu - contextMenu Default value is nullShowContextMenuEvent,
Cues overview and related methods,
Context menus Examplepublic Menu getContextMenu()
Note: if Canvas.destroy is called on a canvas, any specified context menu is not
automatically destroyed as well. This is in contrast to MenuButtons which
automatically destroy their specified menu by default. The
behavior is intentional as context menus are commonly reused across components.
ShowContextMenuEvent,
Cues overview and related methods,
Context menus Example
public Boolean getDestroyed()
throws IllegalStateException
destroyed.
Note : This method should be called only after the underlying component has been created.
IllegalStateException - if underlying component has not yet been created.
public Boolean getDestroying()
throws IllegalStateException
destroying.
Note : This method should be called only after the underlying component has been created.
IllegalStateException - if underlying component has not yet been created.public void setDragStartDistance(int dragStartDistance)
Note : This is an advanced setting
dragStartDistance - dragStartDistance Default value is 5Dragdrop overview and related methodspublic int getDragStartDistance()
Dragdrop overview and related methods
public void setDrawGroup(DrawGroup drawGroup)
throws IllegalStateException
DrawGroup this drawItem is a member of.
drawGroup - drawGroup Default value is null
IllegalStateException - this property cannot be changed after the underlying component has been createdpublic DrawGroup getDrawGroup()
DrawGroup this drawItem is a member of.
public void setDrawPane(DrawPane drawPane)
throws IllegalStateException
DrawPane this drawItem should draw in. If this item has a DrawGroup, the drawGroup's drawPane is automatically used.
drawPane - drawPane Default value is null
IllegalStateException - this property cannot be changed after the underlying component has been createdpublic DrawPane getDrawPane()
DrawPane this drawItem should draw in. If this item has a DrawGroup, the drawGroup's drawPane is automatically used.
public void setEndArrow(ArrowStyle endArrow)
endArrow - style of arrow to use. Default value is nullpublic ArrowStyle getEndArrow()
public void setFillColor(String fillColor)
fillColor - new fillColor to use. Pass null for transparent.. See CSSColor. Default value is nullpublic String getFillColor()
CSSColorpublic void setFillOpacity(float fillOpacity)
fillOpacity - new opacity, as a number between 0 (transparent) and 1 (opaque).. Default value is 1.0public float getFillOpacity()
public void setKnobs(KnobType... knobs)
KnobType specified in this will
turn on UI allowing the user to manipulate this drawItem. To update the set of knobs at runtime use DrawItem.showKnobs and DrawItem.hideKnobs
knobs - knobs Default value is nullpublic KnobType[] getKnobs()
KnobType specified in this will
turn on UI allowing the user to manipulate this drawItem. To update the set of knobs at runtime use DrawItem.showKnobs and DrawItem.hideKnobs
public void setLineCap(LineCap lineCap)
Note that for dashed and dotted lines, the lineCap style affects each dash
or dot.
If this method is called after the component has been drawn/initialized:
Update lineCap for this drawItem.
lineCap - new lineCap to use. Default value is "round"public LineCap getLineCap()
Note that for dashed and dotted lines, the lineCap style affects each dash or dot.
public void setLineColor(String lineColor)
lineColor - new line color. Pass null for transparent.. See CSSColor. Default value is "#808080"public String getLineColor()
CSSColorpublic void setLineOpacity(float lineOpacity)
lineOpacity - new opacity, as a number between 0 (transparent) and 1 (opaque).. Default value is 1.0public float getLineOpacity()
public void setLinePattern(LinePattern linePattern)
linePattern - new linePattern to use. Default value is "solid"public LinePattern getLinePattern()
public void setLineWidth(int lineWidth)
lineWidth - new pixel lineWidth. Default value is 3public int getLineWidth()
public void setMoveKnobPoint(String moveKnobPoint)
"move" control
knob, this attribute
specifies where the knob should appear with respect to the drawItem. Valid options are:
"TL"Top Left corner"TR"Top Right corner"BL"Bottom Left corner"BR"Bottom Right corner"T"Centered on the top edge"B"Centered on the bottom edge"L"Centered on the left edge"R"Centered on thie right edge"C"positioned over the center of the drawItem
moveKnobPoint - . See String. Default value is "TL"public String getMoveKnobPoint()
"move" control
knob, this attribute
specifies where the knob should appear with respect to the drawItem. Valid options are:
"TL"Top Left corner"TR"Top Right corner"BL"Bottom Left corner"BR"Bottom Right corner"T"Centered on the top edge"B"Centered on the bottom edge"L"Centered on the left edge"R"Centered on thie right edge"C"positioned over the center of the drawItem
String
public void setRotation(float rotation)
throws IllegalStateException
rotation - rotation Default value is 0.0
IllegalStateException - this property cannot be changed after the underlying component has been createdpublic float getRotation()
public void setShadow(Shadow shadow)
shadow - new shadow. Default value is nullpublic Shadow getShadow()
public void setStartArrow(ArrowStyle startArrow)
startArrow - style of arrow to use. Default value is nullpublic ArrowStyle getStartArrow()
public HandlerRegistration addClickHandler(ClickHandler handler)
Executed when the left mouse is clicked (pressed and then released) on this widget. No default implementation.
addClickHandler in interface HasClickHandlershandler - the click handler
HandlerRegistration used to remove this handler
public float computeAngle(int px1,
int py1,
int px2,
int py2)
px1 - py1 - px2 - py2 -
public void destroy()
Canvas.destroy.
destroy in class BaseClasspublic void draw()
DrawPane.
public void erase()
To re-draw the
item within the DrawPane, call DrawItem.draw again, or use
DrawPane.addDrawItem to move to another DrawGroup.
public int getPageLeft()
Positioning overview and related methodspublic int getPageTop()
Positioning overview and related methodspublic void getSvgString()
NOTE: The generated SVG source assumes that the
default namespace is http://www.w3.org/2000/svg and that namespace prefix xlink refers to
namespace name http://www.w3.org/1999/xlink.
public void hide()
public Boolean isInBounds(int x,
int y)
x - y -
public Boolean isPointInPath(int x,
int y)
x - y -
public HandlerRegistration addMouseDownHandler(MouseDownHandler handler)
Executed when the left mouse down is pressed on this widget. No default implementation.
addMouseDownHandler in interface HasMouseDownHandlershandler - the mouseDown handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addMouseMoveHandler(MouseMoveHandler handler)
Executed when the mouse moves within this widget. No default implementation.
addMouseMoveHandler in interface HasMouseMoveHandlershandler - the mouseMove handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addMouseOutHandler(MouseOutHandler handler)
Executed when the mouse leaves this widget. No default implementation.
addMouseOutHandler in interface HasMouseOutHandlershandler - the mouseOut handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addMouseOverHandler(MouseOverHandler handler)
Executed when mouse enters this widget. No default implementation.
addMouseOverHandler in interface HasMouseOverHandlershandler - the mouseOver handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addMouseUpHandler(MouseUpHandler handler)
Executed when the left mouse is released on this widget. No default implementation.
addMouseUpHandler in interface HasMouseUpHandlershandler - the mouseUp handler
HandlerRegistration used to remove this handler
public void moveBy(int dX,
int dY)
dX - change to left coordinate in pixelsdY - change to top coordinate in pixelspublic HandlerRegistration addMovedHandler(MovedHandler handler)
Notification method fired when this component is explicitly moved. Note that a component's position on the screen may
also changed due to an ancestor being moved. The parentMoved method provides a notification entry point to catch that case as well.
addMovedHandler in interface HasMovedHandlershandler - the moved handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addDragMoveHandler(DragMoveHandler handler)
If canDrag is true and canDrag is true, this notification method will be fired when
the user drags the drawItem
addDragMoveHandler in interface HasDragMoveHandlershandler - the dragMove handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addDragStartHandler(DragStartHandler handler)
If canDrag is true and canDrag is true, this notification method will be fired when
the user starts to drag the drawItem
addDragStartHandler in interface HasDragStartHandlershandler - the dragStart handler
HandlerRegistration used to remove this handlerpublic HandlerRegistration addDragStopHandler(DragStopHandler handler)
If canDrag is true and canDrag is true, this notification method will be fired when
the user completes a drag on the drawItem
addDragStopHandler in interface HasDragStopHandlershandler - the dragStop handler
HandlerRegistration used to remove this handler
public void resizeBy(int dX,
int dY)
dX - change to left coordinate in pixelsdY - change to top coordinate in pixelspublic HandlerRegistration addResizedHandler(ResizedHandler handler)
Observable method called whenever a DrawItem changes size.
addResizedHandler in interface HasResizedHandlershandler - the resized handler
HandlerRegistration used to remove this handler
public void resizeTo(int width,
int height)
width - new widthheight - new heightpublic void rotateBy(float degrees)
degrees - number of degrees to rotate from current orientation.public void rotateTo(float degrees)
degrees - number of degrees to rotate
public void scaleBy(float x,
float y)
x - scale in the x directiony - scale in the y direction
public void scaleTo(float x,
float y)
x - scale in the x directiony - scale in the y directionpublic void show()
public HandlerRegistration addShowContextMenuHandler(ShowContextMenuHandler handler)
Executed when the right mouse button is clicked. The default implementation of this method auto-creates a Menu from the contextMenu
property on this component and then calls Menu.showContextMenu on it to show it.
If you want to show a standard context menu, you can simply define your Menu and set it as the contextMenu property on your component - you do not need to override this method.
If you want to do some other processing before showing a menu or do something else entirely, then you should override this method. Note that the return value from this method controls whether or not the native browser context menu is shown.
addShowContextMenuHandler in interface HasShowContextMenuHandlershandler - the showContextMenu handler
HandlerRegistration used to remove this handlerpublic static DrawItem[] convertToDrawItemArray(JavaScriptObject nativeArray)
public int[] getCenter()
public int[] getBoundingBox()
public static DrawItem getRef(JavaScriptObject jsObj)
protected int[] getAttributeAsIntArray(String property)
public void hideKnobs(KnobType... knobType)
knobs to remove the specified knobType, and clears any drawn knobs for this knobType.
knobType - knobs to hidepublic void showKnobs(KnobType... knobType)
knobs to include the specified knobType, and if necessary draws out the appropriate control knobs.
knobType - knobs to showpublic void setResizeKnobPoints(String[] resizeKnobPoints)
"resize" control
knobs, this attribute
specifies which sides / edges should show knobs. May include any of the following values:
"TL"Top Left corner"TR"Top Right corner"BL"Bottom Left corner"BR"Bottom Right corner
resizeKnobPoints - resizeKnobPoints Default value is ["TL","TR","BL","BR"]public String[] getResizeKnobPoints()
"resize" control
knobs, this attribute
specifies which sides / edges should show knobs. May include any of the following values:
"TL"Top Left corner"TR"Top Right corner"BL"Bottom Left corner"BR"Bottom Right corner
public void setScale(int[] scale)
throws IllegalStateException
scale - scale Default value is null
IllegalStateException - this property cannot be changed after the underlying component has been createdpublic int[] getScale()
public void setMoveKnobOffset(int[] offset)
throws IllegalStateException
scale - scale Default value is null
IllegalStateException - this property cannot be changed after the underlying component has been createdpublic int[] getMoveKnobOffset()
public void setFillGradient(Gradient fillGradient)
drawPane.createSimpleGradient, drawPane.createRadialGradient or drawPane.createLinearGradient. Otherwise it expects
one of SimpleGradient, LinearGradient or RadialGradient.
fillGradient - new gradient to use. Pass null for transparent.. Default value is nullGradientpublic Gradient getFillGradient()
drawPane.createSimpleGradient, drawPane.createRadialGradient or drawPane.createLinearGradient. Otherwise it expects
one of SimpleGradient, LinearGradient or RadialGradient.
Gradient
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||