Class K2DComplexElement
java.lang.Object
com.kheops.jmap.client.graphics2D.K2DElement
com.kheops.jmap.client.graphics2D.K2DComplexElement
- All Implemented Interfaces:
Shareable
,Serializable
,Cloneable
A class containing many K2DElement (K2DPolygon, K2DPolyline, K2DPoint, etc).
- See Also:
-
Field Summary
Fields inherited from class com.kheops.jmap.client.graphics2D.K2DElement
attributes, DEFAULT_DC_BUFFER, id, selected
-
Constructor Summary
ConstructorDescriptionConstructs an empty instance of K2DComplexElement.K2DComplexElement
(K2DElement element, long id) Constructs a K2DComplexElement with a Vector that contains a group of K2DElement. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addElement
(K2DElement element) Adds a K2DElement to the complex element.void
addElements
(K2DElement[] elements) clone()
Clones this complex element.void
draw
(GraphicsRef gr, K2DTransform t, Style s) Draws all the elements of this complex element to the specified Graphics, using the specified transform matrix and the specified style.void
drawHandles
(GraphicsRef gr, K2DTransform t, Style s) This method draws handles around the element.Determines the bounding box of the displayed element in DC.getDisplayBoundsWc
(ViewState vs, Style s) Determines the bounding box including the style of element in WC (World Coordinates).Returns the geometry object associated with the element.int
getType()
Return the current element type.void
removeElement
(K2DElement element) Removes an element from this complex element.void
setElements
(K2DElement[] elements) void
setGeometry
(Geometry geometry) Sets the geometry object associated with the element.void
setSelected
(boolean selected) Sets the selection state of the element.share()
Creates a clone of the current element excluding the geometry which remains the same instance in both elements.
Useclone()
to create a real copy of the current element.int
sizeOf()
Returns the estimated memory used by this object in bytes.boolean
touches
(Point dcCoord, K2DTransform t, Style s) Determines if the specified device coordinate touches the displayed element.Methods inherited from class com.kheops.jmap.client.graphics2D.K2DElement
copyAttributes, draw, drawHandles, equals, fromByteArray, generateUniqueId, getAttributes, getDisplayBounds, getId, hashCode, isSelected, setAttributes, setId, sizeOfAttributes, toByteArray, toByteArray, touches
-
Constructor Details
-
K2DComplexElement
public K2DComplexElement()Constructs an empty instance of K2DComplexElement. -
K2DComplexElement
Constructs a K2DComplexElement with a Vector that contains a group of K2DElement.- Parameters:
element
- an element to add to the complex elementid
- the id of the element
-
-
Method Details
-
addElement
Adds a K2DElement to the complex element.- Parameters:
element
- the element to be added
-
addElements
-
removeElement
Removes an element from this complex element.- Parameters:
element
- the element to be removed
-
draw
Draws all the elements of this complex element to the specified Graphics, using the specified transform matrix and the specified style.- Specified by:
draw
in classK2DElement
- Parameters:
gr
- the GraphicsRef object to draw ont
- the transformation to apply to the elements
- the style that defines the appearance of the element- See Also:
-
clone
Clones this complex element.- Specified by:
clone
in classK2DElement
- Returns:
- a new instance of the drawing vector
-
sizeOf
public int sizeOf()Returns the estimated memory used by this object in bytes.- Overrides:
sizeOf
in classK2DElement
- Returns:
- the estimated memory used by this object in bytes.
-
drawHandles
Description copied from class:K2DElement
This method draws handles around the element. The position of the handles is implementation dependent. These handles are typically used to modify the geometry of the element.- Specified by:
drawHandles
in classK2DElement
- Parameters:
gr
- the Graphics object to draw on.t
- the transformation to apply to the element.s
- the style of the element.
-
getDisplayBounds
Description copied from class:K2DElement
Determines the bounding box of the displayed element in DC. The bounding box is the smallest possible rectangle in which the displayed element fits entirely.- Specified by:
getDisplayBounds
in classK2DElement
- Parameters:
t
- the transformation used to calculate the display bounds of the element.s
- the style used to calculate the display bounds of the element.- Returns:
- the bounding box of the displayed element
-
getGeometry
Description copied from class:K2DElement
Returns the geometry object associated with the element.- Specified by:
getGeometry
in classK2DElement
- Returns:
- The geometry object associated with the element.
-
setGeometry
Description copied from class:K2DElement
Sets the geometry object associated with the element.- Specified by:
setGeometry
in classK2DElement
- Parameters:
geometry
- the geometry
-
touches
Description copied from class:K2DElement
Determines if the specified device coordinate touches the displayed element. A point touches the element if it overlaps the graphical representation of the element. The style of the element influences the result.- Specified by:
touches
in classK2DElement
- Parameters:
dcCoord
- the device coordinatet
- the transformation used to display the elements
- the style used to display the element- Returns:
- true if the element contains the point, false otherwise
- See Also:
-
getElements
-
setElements
-
getType
public int getType()Description copied from class:K2DElement
Return the current element type.- Specified by:
getType
in classK2DElement
- Returns:
- the element type.
- See Also:
-
setSelected
public void setSelected(boolean selected) Description copied from class:K2DElement
Sets the selection state of the element.- Overrides:
setSelected
in classK2DElement
- Parameters:
selected
- if true, the element will be selected else it will be unselected
-
getDisplayBoundsWc
Determines the bounding box including the style of element in WC (World Coordinates). The bounding box is the smallest possible rectangle in which the displayed element fits entirely. This method offers a basic implementation by transforming the DC getDisplayBounds method result in WC. To optimize performance, each K2DElement should override this method with its own implementation. See existing implementations (K2DPolygon, K2DPoint, K2DPolyline, etc.) for examples.- Overrides:
getDisplayBoundsWc
in classK2DElement
- Parameters:
vs
- the view state that provides context information to calculate the display bounds of the element.s
- the style used used to calculate the display bounds of the element.- Returns:
- the bounding box of the displayed element in WC
-