Class K2DEllipse
java.lang.Object
com.kheops.jmap.client.graphics2D.K2DElement
com.kheops.jmap.client.graphics2D.K2DEllipse
- All Implemented Interfaces:
Shareable
,Serializable
,Cloneable
A class used to display 2D ellipse type geometries.
- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionprotected EllipseTypeGeometry
Defines the geometry of this element.Fields inherited from class com.kheops.jmap.client.graphics2D.K2DElement
attributes, DEFAULT_DC_BUFFER, id, selected
-
Constructor Summary
ConstructorDescriptionConstructs an default empty ellipse.K2DEllipse
(K2DEllipse ellipse) Constructs a copy of the specified ellipse element.K2DEllipse
(EllipseTypeGeometry geometry, Object[] attributes, long id) Creates a K2DEllipse from the specified parameters. -
Method Summary
Modifier and TypeMethodDescriptionclone()
This will clone the current instance of K2DElement.protected static Rectangle
computeDisplayBounds
(EllipseTypeGeometry geometry, K2DTransform t, Style s) Computes the DC bounding box of the specified geometry using the specified parameters.void
draw
(GraphicsRef gr, K2DTransform t, Style s) Draws the element on the specified graphics object using the specified transformation and 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
setGeometry
(Geometry geometry) Sets the geometry object associated with 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.toString()
This method overrides the toString methodboolean
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, setSelected, sizeOfAttributes, toByteArray, toByteArray, touches
-
Field Details
-
geometry
Defines the geometry of this element.
-
-
Constructor Details
-
K2DEllipse
public K2DEllipse()Constructs an default empty ellipse. The coordinates, width and height of the ellipse remains unspecified. -
K2DEllipse
Constructs a copy of the specified ellipse element.- Parameters:
ellipse
- K2DEllipse instance that will be used to create a clone object
-
K2DEllipse
Creates a K2DEllipse from the specified parameters.- Parameters:
geometry
- the ellipse type geometry to use.attributes
- the attributes of the elementid
- the id of the element
-
-
Method Details
-
clone
This will clone the current instance of K2DElement. The cloned element is always a deep copy of the source element.- Specified by:
clone
in classK2DElement
- Returns:
- a new instance of K2DElement which is equal to the specified the current element.
-
draw
Draws the element on the specified graphics object using the specified transformation and style.
If the specified style contains a painter, that one will be used to fill ellipses. Otherwise, the fill color of the style will be used.
The border color of the specified style will be used to draw the ellipses border.- Specified by:
draw
in classK2DElement
- Parameters:
gr
- a wrapper to the Graphics object to draw ont
- the transformation to apply to the elements
- the style that defines the appearance of the element- See Also:
-
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.
-
toString
This method overrides the toString method -
drawHandles
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
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
-
computeDisplayBounds
protected static Rectangle computeDisplayBounds(EllipseTypeGeometry geometry, K2DTransform t, Style s) Computes the DC bounding box of the specified geometry using the specified parameters.- Parameters:
geometry
- the geometry to use when computing the bounding box.t
- the view transformation matrix.s
- the current style associated to the geometry.- Returns:
- the DC bounding box of the geometry.
-
getGeometry
Returns the geometry object associated with the element.
The returned object is an instance of EllipseTypeGeometry.- Specified by:
getGeometry
in classK2DElement
- Returns:
- The geometry object associated with the element.
-
setGeometry
Sets the geometry object associated with the element.- Specified by:
setGeometry
in classK2DElement
- Parameters:
geometry
- the geometry- Throws:
IllegalArgumentException
- if the specified geometry is not a valid EllipseTypeGeometry instance.
-
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:
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:
-
getType
public int getType()Return the current element type.- Specified by:
getType
in classK2DElement
- Returns:
- the element type.
- See Also:
-
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
-