Package com.storedobject.chart
Class Shape
java.lang.Object
com.storedobject.chart.AbstractPart
com.storedobject.chart.Shape
- All Implemented Interfaces:
Component,ComponentPart,ComponentProperty,HasPosition,VisibleProperty
- 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 classRepresentation of a (x, y) point used in shapes.static classClass to specify the style of aShapeinstance. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidencode(StringBuilder sb, String name, Object value) Helper method: Encode a (name, value) pair.voidEncode the JSON string with the properties of this.protected static voidencodePoint(StringBuilder sb, Shape.Point point) Helper method: Encode aShape.Point.protected static voidencodePoint(StringBuilder sb, String nameX, String nameY, Shape.Point point) Helper method: Encode aShape.Point.protected voidEncode shape details.final PositiongetPosition(boolean create) Get the position.final Shape.StylegetStyle(boolean create) Get the style.protected abstract StringgetType()Get the type of this shape.final booleanWhether this shape is draggable or not.booleanChecks if this property is currently visible.voidsetDraggable(boolean draggable) Mark this shape as draggable.voidsetPosition(Position position) Set position.voidsetPosition(Shape.Point positionXY) Set the X and Y positions of this shape in the coordinate system.voidsetPosition(Number positionX, Number positionY) Set the X and Y positions of this shape in the coordinate system.voidsetStyle(Shape.Style style) Set style.voidsetVisible(boolean visible) Sets the visibility of this property.voidvalidate()This method is invoked bySOChartto 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, setZMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.storedobject.chart.ComponentPart
className, getId, getName, getRenderingIndex, getSerial, setName, setRenderingIndex, setSerialMethods inherited from interface com.storedobject.chart.VisibleProperty
hide, show
-
Constructor Details
-
Shape
public Shape()Constructor.
-
-
Method Details
-
getType
-
encodeJSON
Description copied from interface:ComponentPropertyEncode the JSON string with the properties of this.- Specified by:
encodeJSONin interfaceComponentProperty- Overrides:
encodeJSONin 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:ComponentPartThis method is invoked bySOChartto check if the component or part is valid or not.- Specified by:
validatein interfaceComponentPart- Throws:
ChartException- Raises exception if the component or part is not valid.
-
setVisible
public void setVisible(boolean visible) Description copied from interface:VisiblePropertySets the visibility of this property.- Specified by:
setVisiblein interfaceVisibleProperty- Parameters:
visible- A boolean indicating whether this property should be visible (true) or hidden (false).
-
isVisible
public boolean isVisible()Description copied from interface:VisiblePropertyChecks if this property is currently visible.- Specified by:
isVisiblein interfaceVisibleProperty- Returns:
- true if the property is visible, false otherwise.
-
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:
getPositionin interfaceHasPosition- Parameters:
create- Whether to create it or not.- Returns:
- Position.
-
setPosition
Set position.- Specified by:
setPositionin 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
-