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
ConstructorsConstructorDescriptionConstructs 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 TypeMethodDescriptionvoidaddElement(K2DElement element) Adds a K2DElement to the complex element.voidaddElements(K2DElement[] elements) clone()Clones this complex element.voiddraw(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.voiddrawHandles(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.intgetType()Return the current element type.voidremoveElement(K2DElement element) Removes an element from this complex element.voidsetElements(K2DElement[] elements) voidsetGeometry(Geometry geometry) Sets the geometry object associated with the element.voidsetSelected(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.intsizeOf()Returns the estimated memory used by this object in bytes.booleantouches(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:
drawin 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:
clonein classK2DElement- Returns:
- a new instance of the drawing vector
-
sizeOf
public int sizeOf()Returns the estimated memory used by this object in bytes.- Overrides:
sizeOfin classK2DElement- Returns:
- the estimated memory used by this object in bytes.
-
drawHandles
Description copied from class:K2DElementThis 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:
drawHandlesin 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:K2DElementDetermines 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:
getDisplayBoundsin 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:K2DElementReturns the geometry object associated with the element.- Specified by:
getGeometryin classK2DElement- Returns:
- The geometry object associated with the element.
-
setGeometry
Description copied from class:K2DElementSets the geometry object associated with the element.- Specified by:
setGeometryin classK2DElement- Parameters:
geometry- the geometry
-
touches
Description copied from class:K2DElementDetermines 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:
touchesin 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:K2DElementReturn the current element type.- Specified by:
getTypein classK2DElement- Returns:
- the element type.
- See Also:
-
setSelected
public void setSelected(boolean selected) Description copied from class:K2DElementSets the selection state of the element.- Overrides:
setSelectedin 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:
getDisplayBoundsWcin 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
-