public abstract class K2DElement extends java.lang.Object implements java.io.Serializable, Shareable, java.lang.Cloneable
Serializable,
Cloneable,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
java.lang.Object[] |
attributes
Defines the values associated with this elements.
|
static int |
DEFAULT_DC_BUFFER |
protected long |
id
The unique id of this element, -1 by default.
|
protected boolean |
selected
Defines whether this element is selected or not.
|
| Constructor and Description |
|---|
K2DElement() |
| Modifier and Type | Method and Description |
|---|---|
abstract java.lang.Object |
clone()
This will clone the current instance of K2DElement.
|
protected static java.lang.Object[] |
copyAttributes(java.lang.Object[] attribs) |
abstract void |
draw(GraphicsRef gr,
K2DTransform t,
Style s)
Deprecated.
use draw(GraphicsRef, ViewState, Style) instead
|
void |
draw(GraphicsRef gr,
ViewState vs,
Style s)
Draws the element on the specified graphics object using the specified
transformation and style.
|
abstract void |
drawHandles(GraphicsRef gr,
K2DTransform t,
Style s)
Deprecated.
use drawHandles(GraphicsRef, ViewState, Style) instead
|
void |
drawHandles(GraphicsRef gr,
ViewState vs,
Style s)
This method draws handles around the element.
|
boolean |
equals(java.lang.Object o)
Tests the equality of this element compared to the specified element.
Two elements are equals if they have the same id. |
static K2DElement |
fromByteArray(byte[] buf)
Transforms a byte array buffer to a K2DElement
|
static long |
generateUniqueId()
Utility method that generates a unique element id based on current time.
|
java.lang.Object[] |
getAttributes()
Gets the attributes of the element.
|
abstract Rectangle |
getDisplayBounds(K2DTransform t,
Style s)
Deprecated.
use getDisplayBounds(ViewState, Style) instead
|
Rectangle |
getDisplayBounds(ViewState vs,
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).
|
abstract Geometry |
getGeometry()
Returns the geometry object associated with the element.
|
long |
getId()
Gets the id of the element.
|
abstract int |
getType()
Return the current element type.
|
int |
hashCode() |
boolean |
isSelected()
Determines if the element is selected.
|
void |
setAttributes(java.lang.Object[] attributes)
Sets the attributes of the element.
|
abstract void |
setGeometry(Geometry geometry)
Sets the geometry object associated with the element.
|
void |
setId(long id)
Sets the id of the element.
|
void |
setSelected(boolean selected)
Sets the selection state of the element.
|
abstract 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.
|
protected static int |
sizeOfAttributes(java.lang.Object[] attributes)
Returns the estimated memory used by the specified attributes in bytes.
|
static byte[] |
toByteArray(java.io.ByteArrayOutputStream baos,
K2DElement elem)
Transforms the specified K2DElement into an array of bytes.
|
static byte[] |
toByteArray(K2DElement elem)
Transforms the specified K2DElement into an array of bytes.
|
abstract boolean |
touches(Point dcCoord,
K2DTransform t,
Style s)
Deprecated.
use touches(Point, ViewState, Style) instead
|
boolean |
touches(Point dcCoord,
ViewState vs,
Style s)
Determines if the specified device coordinate touches the displayed element.
|
public static final int DEFAULT_DC_BUFFER
protected long id
protected boolean selected
public java.lang.Object[] attributes
public static long generateUniqueId()
public long getId()
public void setId(long id)
id - of the elementpublic java.lang.Object[] getAttributes()
public void setAttributes(java.lang.Object[] attributes)
attributes - array of attributes.public boolean isSelected()
setSelected(boolean)public void setSelected(boolean selected)
selected - if true, the element will be selected else it will be unselectedpublic abstract Geometry getGeometry()
public abstract void setGeometry(Geometry geometry)
geometry - the geometry@Deprecated public abstract boolean touches(Point dcCoord, K2DTransform t, Style s)
dcCoord - the device coordinatet - the transformation used to display the elements - the style used to display the elementK2DTransform,
Stylepublic boolean touches(Point dcCoord, ViewState vs, Style s)
dcCoord - the device coordinatevs - the view state that provides context information to draw the element.s - the style used to display the elementK2DTransform,
Style@Deprecated public abstract Rectangle getDisplayBounds(K2DTransform t, Style s)
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 Rectangle getDisplayBounds(ViewState vs, Style s)
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.public int sizeOf()
@Deprecated public abstract void draw(GraphicsRef gr, K2DTransform t, Style s)
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 elementpublic void draw(GraphicsRef gr, ViewState vs, Style s)
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@Deprecated public abstract void drawHandles(GraphicsRef gr, K2DTransform t, Style s)
gr - the Graphics object to draw on.t - the transformation to apply to the element.s - the style of the element.public void drawHandles(GraphicsRef gr, ViewState vs, Style s)
gr - the Graphics object to draw on.vs - the view state that provides context information to draw the handles of the element.s - the style of the element.public abstract java.lang.Object clone()
clone in class java.lang.Objectpublic abstract int getType()
ElementTypesprotected static java.lang.Object[] copyAttributes(java.lang.Object[] attribs)
protected static int sizeOfAttributes(java.lang.Object[] attributes)
attributes - attributes to include in the computation.sizeOf()public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - the element to be tested.public static byte[] toByteArray(K2DElement elem)
elem - the K2DElement to be transformed.public static byte[] toByteArray(java.io.ByteArrayOutputStream baos,
K2DElement elem)
baos - the ByteArrayOutputStream to use.elem - the K2DElement to be transformed.public static K2DElement fromByteArray(byte[] buf)
buf - the byte array bufferpublic abstract Shareable share()
clone() to create a real copy of the current element.public Rectangle getDisplayBoundsWc(ViewState vs, Style s)
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.