public class K2DPolygon extends K2DElement
Modifier and Type | Field and Description |
---|---|
protected static byte |
FILL_COLOR |
protected PolygonTypeGeometry |
geometry
Defines the geometry of the current element.
|
protected static byte |
LINE_COLOR |
attributes, DEFAULT_DC_BUFFER, id, selected
Constructor and Description |
---|
K2DPolygon()
Creates a new empty K2DPolygon without any geometry.
|
K2DPolygon(K2DPolygon polygon)
Creates a K2DPolygon from the specified K2DPolygon Object.
|
K2DPolygon(PolygonTypeGeometry geometry,
java.lang.Object[] attributes,
long id)
Creates a K2DPolygon from the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
clone()
This will clone the current instance of K2DElement.
|
protected static Rectangle |
computeDisplayBounds(PolygonTypeGeometry 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.
|
Rectangle |
getDisplayBounds(K2DTransform t,
Style s)
Determines the bounding box of the displayed element in DC.
|
Rectangle |
getDisplayBoundsWc(ViewState vs,
Style s)
Determines the bounding box including the style of element in WC (World Coordinates).
|
Geometry |
getGeometry()
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.
|
Shareable |
share()
Creates a clone of the current element excluding the geometry which remains
the same instance in both elements.
Use clone() to create a real copy of the current element. |
int |
sizeOf()
Returns the estimated memory used by this object in bytes.
|
java.lang.String |
toString()
This method overrides the toString method
|
boolean |
touches(Point dcCoord,
K2DTransform t,
Style s)
Determines if the specified device coordinate touches the displayed element.
|
copyAttributes, draw, drawHandles, equals, fromByteArray, generateUniqueId, getAttributes, getDisplayBounds, getId, hashCode, isSelected, setAttributes, setId, setSelected, sizeOfAttributes, toByteArray, toByteArray, touches
protected static final byte LINE_COLOR
protected static final byte FILL_COLOR
protected PolygonTypeGeometry geometry
public K2DPolygon()
public K2DPolygon(PolygonTypeGeometry geometry, java.lang.Object[] attributes, long id)
geometry
- the polygon type geometry to use.attributes
- the attributes of the elementid
- the id of the elementpublic K2DPolygon(K2DPolygon polygon)
polygon
- the K2DPolygon to copy.public void draw(GraphicsRef gr, K2DTransform t, Style s)
draw
in class K2DElement
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 elementKPaint
public final boolean touches(Point dcCoord, K2DTransform t, Style s)
touches
in class K2DElement
dcCoord
- the device coordinatet
- the transformation used to display the elements
- the style used to display the elementK2DTransform
,
Style
protected static Rectangle computeDisplayBounds(PolygonTypeGeometry geometry, K2DTransform t, Style s)
geometry
- the geometry to use when computing the bounding box.t
- the view transformation matrix.s
- the current style associated to the geometry.public Rectangle getDisplayBounds(K2DTransform t, Style s)
getDisplayBounds
in class K2DElement
t
- the transformation used to calculate the display bounds of the element.s
- the style used used to calculate the display bounds of the element.public java.lang.Object clone()
clone
in class K2DElement
public int sizeOf()
sizeOf
in class K2DElement
public java.lang.String toString()
toString
in class java.lang.Object
public Shareable share()
clone()
to create a real copy of the current element.share
in interface Shareable
share
in class K2DElement
K2DElement.clone()
public void drawHandles(GraphicsRef gr, K2DTransform t, Style s)
drawHandles
in class K2DElement
gr
- the Graphics object to draw on.t
- the transformation to apply to the element.s
- the style of the element.public Geometry getGeometry()
getGeometry
in class K2DElement
public void setGeometry(Geometry geometry)
setGeometry
in class K2DElement
geometry
- the geometryjava.lang.IllegalArgumentException
- if the specified geometry is not a valid PolygonTypeGeometry instance.public int getType()
getType
in class K2DElement
ElementTypes
public Rectangle getDisplayBoundsWc(ViewState vs, Style s)
getDisplayBoundsWc
in class K2DElement
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.