Package com.storedobject.chart
Class Shape
java.lang.Object
com.storedobject.chart.AbstractPart
com.storedobject.chart.Shape
- All Implemented Interfaces:
Component
,ComponentPart
,ComponentProperty
,HasPosition
- Direct Known Subclasses:
BezierCurve
,CirclePart
,Image
,Line
,Polyline
,Rectangle
,ShapeGroup
,Text
Shape class that can be added to
SOChart
. Positioning of the Shape
on the screen is relative
to its parent. The parent could be an instance of the SOChart
if this was added to that instance directly, or
it could be a ShapeGroup
class if this was added to a ShapeGroup
instance. Positioning can be done by
setting appropriate values on the Position
instance of this shape or by setting shape-specific parameters
like center coordinate for the CirclePart
shape. When both are specified, values set on the Position
will be used.
Note: Unless otherwise specified, all measurements used in this class are in pixels. Sub-pixels are supported.
- Author:
- Syam
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Representation of a (x, y) point used in shapes.static class
Class to specify the style of aShape
instance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static void
encode
(StringBuilder sb, String name, Object value) Helper method: Encode a (name, value) pair.void
Encode the JSON string with the properties of this.protected static void
encodePoint
(StringBuilder sb, Shape.Point point) Helper method: Encode aShape.Point
.protected static void
encodePoint
(StringBuilder sb, String nameX, String nameY, Shape.Point point) Helper method: Encode aShape.Point
.protected void
Encode shape details.final Position
getPosition
(boolean create) Get the position.final Shape.Style
getStyle
(boolean create) Get the style.protected abstract String
getType()
Get the type of this shape.void
hide()
Hide this shape.final boolean
Whether this shape is draggable or not.void
setDraggable
(boolean draggable) Mark this shape as draggable.void
setPosition
(Position position) Set position.void
setPosition
(Shape.Point positionXY) Set the X and Y positions of this shape in the coordinate system.void
setPosition
(Number positionX, Number positionY) Set the X and Y positions of this shape in the coordinate system.void
setStyle
(Shape.Style style) Set style.void
show()
Show this shape.void
validate()
This method is invoked bySOChart
to check if the component or part is valid or not.Methods inherited from class com.storedobject.chart.AbstractPart
equals, getId, getLabelTag, getName, getSerial, getZ, hashCode, hasId, setSerial, setZ
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.storedobject.chart.ComponentPart
className, getId, getName, getRenderingIndex, getSerial, setName, setRenderingIndex, setSerial
-
Constructor Details
-
Method Details
-
getType
-
encodeJSON
Description copied from interface:ComponentProperty
Encode the JSON string with the properties of this.- Specified by:
encodeJSON
in interfaceComponentProperty
- Overrides:
encodeJSON
in classAbstractPart
- Parameters:
sb
- Encoded JSON string to be appended to this.
-
encode
Helper method: Encode a (name, value) pair.- Parameters:
sb
- Encoded JSON string to be appended to this.name
- Name to be encoded.value
- Value to be encoded.
-
encodePoint
Helper method: Encode aShape.Point
.- Parameters:
sb
- Encoded JSON string to be appended to this.nameX
- Name to be encoded for X value.nameY
- Name to be encoded for Y value.point
- Point to be encoded.
-
encodePoint
Helper method: Encode aShape.Point
. Names of the X value and Y value will be "x" and "y" respectively.- Parameters:
sb
- Encoded JSON string to be appended to this.point
- Point to be encoded.
-
encodeShape
Encode shape details.- Parameters:
sb
- Encoded JSON string to be appended to this.
-
validate
Description copied from interface:ComponentPart
This method is invoked bySOChart
to check if the component or part is valid or not.- Specified by:
validate
in interfaceComponentPart
- Throws:
ChartException
- Raises exception if the component or part is not valid.
-
show
public void show()Show this shape. -
hide
public void hide()Hide this shape. -
isDraggable
public final boolean isDraggable()Whether this shape is draggable or not.- Returns:
- True/false.
-
setDraggable
public void setDraggable(boolean draggable) Mark this shape as draggable.- Parameters:
draggable
- True/false.
-
getPosition
Get the position.- Specified by:
getPosition
in interfaceHasPosition
- Parameters:
create
- Whether to create it or not.- Returns:
- Position.
-
setPosition
Set position.- Specified by:
setPosition
in interfaceHasPosition
- Parameters:
position
- Position to set.
-
setPosition
Set the X and Y positions of this shape in the coordinate system.Note: If X and Y positions are set this way, other position details set through
getPosition(boolean)
and/orsetPosition(Position)
are ignored.- Parameters:
positionXY
- XY position in pixels.
-
setPosition
Set the X and Y positions of this shape in the coordinate system.Note: If X and Y positions are set this way, other position details set through
getPosition(boolean)
and/orsetPosition(Position)
are ignored.- Parameters:
positionX
- X position in pixels.positionY
- Y position in pixels.
-
getStyle
Get the style.- Parameters:
create
- Whether to create it now or not.- Returns:
- Style.
-
setStyle
-