Class K2DStyledElement
java.lang.Object
com.kheops.jmap.client.graphics2D.K2DElement
com.kheops.jmap.client.graphics2D.K2DStyledElement
- All Implemented Interfaces:
Shareable,Serializable,Cloneable
- Direct Known Subclasses:
StyleAnimationWrapper
A class encapsulating a Style object and a K2DElement object. When drawn,
the element will have the appearance specified by the associated style. This
class is useful when elements must have a specific style, independent from
the style of the layer they belong to.
- See Also:
-
Field Summary
FieldsFields inherited from class com.kheops.jmap.client.graphics2D.K2DElement
attributes, DEFAULT_DC_BUFFER, id, selected -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for bean compliance only.K2DStyledElement(K2DElement element, Style style) Creates an object containing a K2DElement and a Style.K2DStyledElement(K2DElement element, Style style, Style selectionStyle) Creates an object containing a K2DElement and a Style. -
Method Summary
Modifier and TypeMethodDescriptionclone()Clones the current K2DStyledElement.voiddraw(GraphicsRef gr, K2DTransform t, Style s) Deprecated.use draw(GraphicsRef, ViewState, Style) insteadvoiddraw(GraphicsRef gr, ViewState vs, Style s) Draws the element on the specified graphics object using the specified ViewState.voiddrawHandles(GraphicsRef gr, K2DTransform t, Style s) This method draws handles around the element.Object[]Gets the attributes of 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).Gets the K2DElementReturns the geometry object associated with the element.longgetId()Gets the id of the element.getStyle()Gets the Style associated with the K2DElementintgetType()Return the current element type.inthashCode()booleanDetermines if the element is selected.voidsetAttributes(Object[] attributes) Sets the attributes of the element.voidsetElement(K2DElement element) Sets the K2DElementvoidsetElementAndStyle(K2DElement element, Style style) Sets the Style and The K2DElementvoidsetGeometry(Geometry geometry) Sets the geometry object associated with the element.voidsetId(long id) Sets the id of the element.voidsetSelected(boolean selected) Sets the selection state of the element.voidSets the Style associated with the K2DElementshare()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, drawHandles, equals, fromByteArray, generateUniqueId, getDisplayBounds, sizeOfAttributes, toByteArray, toByteArray, touches
-
Field Details
-
style
-
selectionStyle
-
element
-
-
Constructor Details
-
K2DStyledElement
public K2DStyledElement()Constructor for bean compliance only. -
K2DStyledElement
Creates an object containing a K2DElement and a Style. The id of this element will be the same as the specified element.- Parameters:
element- The K2DElementstyle- The Style associated with the K2DElement
-
K2DStyledElement
Creates an object containing a K2DElement and a Style. The id of this element will be the same as the specified element.- Parameters:
element- The K2DElementstyle- The Style associated with the K2DElementselectionStyle- The selection Style associated with the K2DElement. If null, the default style will be used.
-
-
Method Details
-
clone
Clones the current K2DStyledElement.- Specified by:
clonein classK2DElement- Returns:
- a new instance of the current K2DStyledElement
-
getElement
Gets the K2DElement- Returns:
- the element of this StyledElement
-
getStyle
Gets the Style associated with the K2DElement- Returns:
- style the corresponding style.
-
setElement
Sets the K2DElement- Parameters:
element- the associated element.
-
setStyle
Sets the Style associated with the K2DElement- Parameters:
style- the corresponding style
-
setElementAndStyle
Sets the Style and The K2DElement- Parameters:
element- the K2Delement that will associated with this K2DStyledElement instancestyle- the style that will associated with this K2DElement instance
-
getId
public long getId()Gets the id of the element.- Overrides:
getIdin classK2DElement- Returns:
- the id of the element
-
setId
public void setId(long id) Sets the id of the element.- Overrides:
setIdin classK2DElement- Parameters:
id- the new id of the element
-
getAttributes
Description copied from class:K2DElementGets the attributes of the element.- Overrides:
getAttributesin classK2DElement- Returns:
- the attributes
-
isSelected
public boolean isSelected()Description copied from class:K2DElementDetermines if the element is selected.- Overrides:
isSelectedin classK2DElement- Returns:
- if the element is selected
- See Also:
-
setAttributes
Description copied from class:K2DElementSets the attributes of the element.- Overrides:
setAttributesin classK2DElement- Parameters:
attributes-
-
setSelected
public void setSelected(boolean selected) Description copied from class:K2DElementSets the selection state of the element.- Overrides:
setSelectedin classK2DElement- Parameters:
selected-
-
draw
Deprecated.use draw(GraphicsRef, ViewState, Style) insteadDraws the element on the specified graphics object using the specified transformation. If the element is selected the style sent will be used to draw the element. Else the style specified in the constructor will be used to draw the element.- Specified by:
drawin classK2DElement- Parameters:
gr- a wrapper to the Graphics object to draw on.t- the transformation to apply to the elements- the style that defines the appearance of the element, only used if the style of this K2DStyledElement is null
-
draw
Draws the element on the specified graphics object using the specified ViewState. If the element is selected the style sent will be used to draw the element. Else the style specified in the constructor will be used to draw the element.- Overrides:
drawin classK2DElement- Parameters:
gr- a wrapper to the Graphics object to draw onvs- the view state that provides context information to draw the element.s- the style that defines the appearance of the element, only used if the style of this K2DStyledElement is null
-
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
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:
touchesin classK2DElement- Parameters:
dcCoord- the device coordinatet- the transformation used to display the elements- the style used to display the element - not used by the K2DStyledElement.- Returns:
- true if the element contains the point, false otherwise
- See Also:
-
getType
public int getType()Description copied from class:K2DElementReturn the current element type.- Specified by:
getTypein classK2DElement- Returns:
- the element type.
- See Also:
-
hashCode
public int hashCode()- Overrides:
hashCodein classK2DElement
-
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
-