public abstract class DiagramItem
extends java.lang.Object
implements java.io.Externalizable
The interior and borders of the diagram items are painted using the brush
and pen specified via setBrush(com.mindfusion.drawing.Brush)
and setPen(com.mindfusion.drawing.Pen)
. The font of
items text is set via the setFont(com.mindfusion.drawing.Font)
method.
The order in which items are painted from bottom to top is called the Zorder.
Moving items up or down the Zorder can be done by means of the zBottom(boolean)
,
zTop(boolean)
, zLevelUp(boolean)
and zLevelDown(boolean)
methods. Accessing and
setting the index of an item in the Z-order can be done using setZIndex(int)
and getZIndex()
.
A hierarchy of items can be built, such that when an item higher in the
hierarchy is moved, all subordinated items move too. The immediate subordinates
of an item are represented by a Group
instance. The group of items
attached to another item can be accessed via the getSubordinateGroup()
method of the latter. DiagramNode.getMasterGroup()
gets the group in which an
object is subordinate.
Every item can cast a shadow, whose offset from the object is specified via
the setShadowOffsetX(float)
and setShadowOffsetY(float)
methods. The
shadow is painted using the brush specified via setShadowBrush(com.mindfusion.drawing.Brush)
.
An application can associate custom data with an item by means of the
getTag()
and setTag(java.lang.Object)
methods. The tags are only meant to
hold data related to the entities represented by the chart items. They are
not used or modified by JDiagram in any way. The tags are saved and
loaded together with the diagram elements when serializing the document to
a disk file or a stream.
Items can be locked for interactive modification via the setLocked(boolean)
method. Locked items can still be modified programmatically. Items can also
be marked as locked for automatic layout methods via the setIgnoreLayout(boolean)
method.
Modifier and Type | Field and Description |
---|---|
protected Brush |
brush |
protected boolean |
cycleDetected |
protected boolean |
cycleProtect |
protected float |
modifyDX |
protected float |
modifyDY |
protected AdjustmentHandle |
modifyHandle |
protected boolean |
modifying |
protected Pen |
pen |
protected android.graphics.PointF |
ptEnd |
protected android.graphics.PointF |
ptMdfLast |
protected android.graphics.PointF |
ptOrg |
protected android.graphics.PointF |
ptSavedEnd |
protected android.graphics.PointF |
ptSavedOrg |
protected Group |
subordinateGroup |
Constructor and Description |
---|
DiagramItem()
Initializes a new instance of the DiagramItem class.
|
DiagramItem(Diagram parent)
Initializes a new DiagramItem instance by copying property values
from a Diagram's default-value instance members.
|
DiagramItem(DiagramItem prototype)
Initializes a new DiagramItem instance by copying property values
from another DiagramItem's instance members.
|
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
allowCreate(android.graphics.PointF current,
InteractionState ist)
Invoked while the user draws this item to test whether the operation can be
completed in the current context.
|
protected abstract boolean |
allowModify(android.graphics.PointF current,
InteractionState ist)
Invoked during interactive modification of items
to test whether the operation can be completed in
the current context.
|
protected void |
cancelModify(InteractionState ist)
Invoked when the interactive modification of this item has been canceled.
|
DiagramItem |
clone(boolean clipboard)
Creates a copy of this item.
|
protected void |
completeCreate(android.graphics.PointF end)
Invoked when the user finishes drawing this item.
|
protected void |
completeModify(android.graphics.PointF end,
InteractionState ist)
Invoked when the item modification has been completed.
|
abstract boolean |
containsPoint(android.graphics.PointF point)
Checks whether this item contains the specified point.
|
protected DiagramItemProperties |
createProperties()
Creates an item property set corresponding to the type of this diagram item.
|
protected DiagramItemState |
createState()
Creates an item state corresponding to the type of this diagram item.
|
protected abstract void |
draw(android.graphics.Canvas g,
RenderOptions options)
Draws this item on the specified Canvas surface.
|
protected abstract void |
drawShadow(android.graphics.Canvas g,
RenderOptions options)
Draws the item's shadow on the specified Canvas surface.
|
abstract android.graphics.RectF |
getBounds()
Gets the item bounds in logical document coordinates.
|
Brush |
getBrush()
Gets the brush used to fill the item's interior.
|
Brush |
getEffectiveBrush()
Gets the effective brush of the item.
|
Font |
getEffectiveFont()
Gets the currently effective font of the item.
|
Pen |
getEffectivePen()
Gets the effective pen of the item.
|
Brush |
getEffectiveShadowBrush()
Creates a
Brush object representing the currently
effective shadow brush of the item. |
Brush |
getEffectiveTextBrush()
Gets the effective text brush of the item.
|
Font |
getFont()
Gets the font used to draw the text of an item.
|
java.lang.String |
getHyperLink()
Gets the hyperlink associated with an item.
|
java.lang.Object |
getId()
Gets user-defined identifier associated with this item.
|
boolean |
getIgnoreLayout()
Gets a value indicating whether an item should be ignored
by the automatic layout algorithms.
|
int |
getLayerIndex()
Gets the zero-based index of the layer this item is associated
with, or -1, if the item is not associated with any layer.
|
java.util.Hashtable<java.lang.Object,java.lang.Object> |
getLayoutTraits()
Gets properties specific to each layout algorithm.
|
boolean |
getLocked()
Gets a value indicating whether users are allowed to modify an item.
|
Group |
getMasterGroup()
Gets the hierarchical group in which this item is a subordinate.
|
protected GraphicsUnit |
getMeasureUnit() |
Diagram |
getParent()
Gets the diagram that contains this item.
|
Pen |
getPen()
Gets the pen used to draw the item frame lines.
|
boolean |
getPrintable()
Gets a value indicating whether an item will be printed.
|
protected android.graphics.RectF |
getRepaintRect(boolean includeConnected)
Gets the repaint region for this item, taking into account
factors such as pen, selection handles and shadow.
|
int |
getRuntimeIndex()
For internal use.
|
boolean |
getSelected()
Gets a value indicating whether this item is selected.
|
Brush |
getShadowBrush()
Gets the brush of the item's shadow.
|
float |
getShadowOffsetX()
Gets the horizontal distance between a shadow and the item that casts it.
|
float |
getShadowOffsetY()
Gets the vertical distance between a shadow and the item that casts it.
|
DiagramItemStyle |
getStyle()
Gets the style associated with the item.
|
Group |
getSubordinateGroup()
Gets the group of subordinated items attached to this one.
|
java.lang.Object |
getTag()
Gets user-defined data assigned to an item.
|
Brush |
getTextBrush()
Gets the brush used to paint texts inside the item.
|
Thickness |
getTextPadding()
Gets the spacing between the item boundaries and its text.
|
java.lang.String |
getToolTip()
Gets the tooltip text displayed when the pointer rests over an item.
|
protected java.lang.Object |
getValue(java.lang.String name)
Gets the effective value of the style property with the specified name.
|
boolean |
getVisible()
Gets a value indicating whether an item is visible.
|
float |
getWeight()
Gets a weight value used in layout and path-finding algorithms.
|
int |
getZIndex()
Gets the position of an item within the diagram's Z order.
|
boolean |
hasSubordinates()
Checks whether there are any nodes attached to this item.
|
abstract AdjustmentHandle |
hitTestHandle(android.graphics.PointF point)
Determines whether a selection handle of this item is located at the specified point.
|
protected void |
loadFromXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
Loads the item content from an XML element.
|
protected void |
onAdd()
Called when an item is added to a
Diagram , either by the user,
programmatically or via undo / redo. |
protected void |
onChangeFont() |
protected void |
onChangeTextPadding() |
protected void |
onChildModified(DiagramNode node,
AdjustmentHandle handle)
Called when a group child node has been modified.
|
protected void |
onClick(int mouseButton,
android.graphics.PointF pointerPosition)
Invoked when the user clicks this item.
|
protected void |
onDoubleClick(int mouseButton,
android.graphics.PointF pointerPosition)
Invoked when the user double-clicks this item.
|
protected void |
onLoad(Diagram diagram) |
protected void |
onMeasureUnitChanged()
Called when the diagram's MeasureUnit changes.
|
protected void |
onRemove()
Called when an item is removed from a
Diagram , either by
the user, programmatically or via undo / redo. |
protected void |
onStyleChanged()
Invoked when the associated style or theme have changed.
|
protected void |
putSelected(boolean newVal) |
DiagramItemList |
query(java.lang.String query)
Returns the items that can be reached from this item by following
the path specified in the given query expression.
|
void |
readExternal(java.io.ObjectInput in) |
protected void |
repaint()
Repaints the region of the diagram where this item is located.
|
protected void |
repaint(boolean includeConnected)
Repaints the specified region of the diagram.
|
protected void |
repaint(android.graphics.RectF invalidRect)
Repaints the specified region of the diagram.
|
protected void |
restoreProperties(DiagramItemProperties props)
Restores the properties of this diagram item.
|
protected void |
restoreState(DiagramItemState state)
Restores the state of this diagram item.
|
protected void |
saveProperties(DiagramItemProperties props)
Saves the properties of this diagram item.
|
protected void |
saveState(DiagramItemState state)
Saves the state of this diagram item.
|
protected void |
saveToXml(org.w3c.dom.Element xmlElement,
XmlPersistContext context)
Saves the item content into an XML element.
|
void |
setBrush(Brush value)
Sets the brush used to fill the item's interior.
|
protected void |
setDiagramDirty()
Marks the diagram as changed.
|
void |
setFont(Font value)
Sets the font used to draw the text of an item.
|
void |
setHyperLink(java.lang.String value)
Sets the hyperlink associated with an item.
|
void |
setId(java.lang.Object value)
Assigns user-defined identifier to this item.
|
void |
setIgnoreLayout(boolean value)
Sets a value indicating whether an item should be ignored
by the automatic layout algorithms.
|
void |
setLayerIndex(int value)
Sets the zero-based index of the layer this item is associated
with, or -1, if the item is not associated with any layer.
|
void |
setLocked(boolean value)
Sets a value indicating whether users are allowed to modify an item.
|
void |
setPen(Pen value)
Sets the pen used to draw the item frame lines.
|
void |
setPrintable(boolean value)
Sets a value indicating whether an item will be printed.
|
void |
setSelected(boolean value)
Selects or deselects an item.
|
void |
setShadowBrush(Brush value)
Sets the color of the item's shadow.
|
void |
setShadowOffsetX(float value)
Sets the horizontal distance between a shadow and the item that casts it.
|
void |
setShadowOffsetY(float value)
Sets the vertical distance between a shadow and the item that casts it.
|
void |
setStyle(DiagramItemStyle value)
Sets the style associated with the item.
|
void |
setTag(java.lang.Object value)
Assigns user-defined data to an item.
|
void |
setTextBrush(Brush value)
Sets the brush used to paint texts inside the item.
|
void |
setTextPadding(Thickness value)
Sets the spacing between the item boundaries and its text.
|
void |
setToolTip(java.lang.String value)
Sets the tooltip text that should be displayed when the pointer rests over an item.
|
void |
setVisible(boolean value)
Sets a value indicating whether an item is visible.
|
void |
setWeight(float value)
Sets a weight value used in layout and path-finding algorithms.
|
void |
setZIndex(int value)
Sets the position of an item within the diagram's Z order.
|
protected boolean |
shouldRender()
Determines whether the item should be rendered in the current context
|
protected void |
startCreate(android.graphics.PointF org)
Invoked once when the user starts drawing a new item interactively.
|
protected void |
startModify(android.graphics.PointF org,
AdjustmentHandle handle,
InteractionState ist)
Invoked when the user starts modifying this item interactively.
|
protected void |
updateCreate(android.graphics.PointF current)
Invoked during interactive creation of this item.
|
protected void |
updateModify(android.graphics.PointF current,
InteractionState ist)
Invoked during interactive modification of this item.
|
void |
writeExternal(java.io.ObjectOutput out) |
void |
zBottom(boolean keepInLayer)
Moves an item to the bottom of the Z order.
|
void |
zLevelDown(boolean keepInLayer)
Moves an item down in the Z order.
|
void |
zLevelUp(boolean keepInLayer)
Moves an item up in the Z order.
|
void |
zTop(boolean keepInLayer)
Moves an item to the top of the Z order.
|
protected Group subordinateGroup
protected boolean cycleProtect
protected boolean cycleDetected
protected android.graphics.PointF ptOrg
protected android.graphics.PointF ptEnd
protected android.graphics.PointF ptSavedOrg
protected android.graphics.PointF ptSavedEnd
protected Brush brush
protected Pen pen
protected boolean modifying
protected float modifyDX
protected float modifyDY
protected AdjustmentHandle modifyHandle
protected android.graphics.PointF ptMdfLast
public DiagramItem()
public DiagramItem(Diagram parent)
parent
- A Diagram
instance whose default item
attributes are copied to this item.public DiagramItem(DiagramItem prototype)
prototype
- An DiagramItem
instance whose attributes are
copied to this item.public DiagramItem clone(boolean clipboard)
clipboard
- true if the copy will be stored in the OS clipboard; or false otherwise.public DiagramItemList query(java.lang.String query)
query
- A query expression consisting of selectors and boolean predicates.public Diagram getParent()
Diagram
that contains this item.protected void onAdd()
Diagram
, either by the user,
programmatically or via undo / redo.protected void onRemove()
Diagram
, either by
the user, programmatically or via undo / redo.public boolean hasSubordinates()
true
if there are some nodes attached to this item,
otherwise public Group getSubordinateGroup()
Group
for which this item
is the master item.protected void onChildModified(DiagramNode node, AdjustmentHandle handle)
node
- The node that has been modified.handle
- The adjustment handle used to modify the node.public Group getMasterGroup()
Group
to which this item is attached.public java.lang.Object getTag()
Object
.public void setTag(java.lang.Object value)
DiagramListener.serializeTag(com.mindfusion.diagramming.SerializeTagEvent)
event.value
- An Object
containing custom data.public java.lang.Object getId()
Object
.public void setId(java.lang.Object value)
DiagramListener.serializeTag(com.mindfusion.diagramming.SerializeTagEvent)
event.value
- An Object
containing custom data.public java.lang.String getToolTip()
String
that contains the tooltip text.public void setToolTip(java.lang.String value)
value
- A String
that contains the tooltip text.public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
protected void onLoad(Diagram diagram)
protected void saveToXml(org.w3c.dom.Element xmlElement, XmlPersistContext context)
xmlElement
- An Element
the item's data should be stored into.context
- An XmlPersistContext
object providing contextual information about the serialization process and some helper serialization methods.protected void loadFromXml(org.w3c.dom.Element xmlElement, XmlPersistContext context) throws javax.xml.transform.TransformerException, XmlException
xmlElement
- An XmlElement containing the item's data.context
- An XmlPersistContext
object providing contextual
information about the serialization process and some helper serialization methodsjavax.xml.transform.TransformerException
XmlException
public boolean getLocked()
true
if the item cannot be modified,
otherwise false
.public void setLocked(boolean value)
value
- true
if the item should not be modified,
otherwise false
.public boolean getIgnoreLayout()
true
if the item is ignored by layout algorithms,
otherwise false
.public void setIgnoreLayout(boolean value)
value
- true
if the item should be ignored by
automatic layout algorithms, otherwise false
.public abstract android.graphics.RectF getBounds()
RectF
object representing the item's bounds.public void zLevelUp(boolean keepInLayer)
public void zLevelDown(boolean keepInLayer)
public void zBottom(boolean keepInLayer)
public void zTop(boolean keepInLayer)
public int getZIndex()
public void setZIndex(int value)
value
- An integer value specifying the position of the item
within the diagram Z order.public int getLayerIndex()
public void setLayerIndex(int value)
value
- An integer value specifying the layer index.public int getRuntimeIndex()
protected abstract void draw(android.graphics.Canvas g, RenderOptions options)
g
- An android.graphics.Canvas instance.options
- Provides options for the drawing operation.protected abstract void drawShadow(android.graphics.Canvas g, RenderOptions options)
g
- An android.graphics.Canvas instance.options
- Provides options for the drawing operation.protected boolean shouldRender()
protected android.graphics.RectF getRepaintRect(boolean includeConnected)
includeConnected
- true if related items should be considered too; otherwise, false.protected void onMeasureUnitChanged()
protected GraphicsUnit getMeasureUnit()
protected void setDiagramDirty()
protected void repaint()
protected void repaint(boolean includeConnected)
protected void repaint(android.graphics.RectF invalidRect)
public boolean getVisible()
true
if the item is visible,
otherwise false
.public void setVisible(boolean value)
value
- true
if the item should be visible,
otherwise false
.public boolean getPrintable()
true
if the item will be drawn when printing
the diagram, otherwise false
.public void setPrintable(boolean value)
value
- true
if the item should be drawn
when printing the diagram, otherwise false
.public Font getFont()
Font
object representing the font used
to draw this item's text.public void setFont(Font value)
value
- A Font
object representing the font
used to draw this item's text.public Font getEffectiveFont()
Font
if it is not null
,
or a font with the FontFamily
,
FontSize
, and
FontStyle
properties of the item's style.protected void onChangeFont()
public Thickness getTextPadding()
Thickness
instance specifying the size of the padding space left around the text.public void setTextPadding(Thickness value)
value
- A Thickness
instance specifying the size of the padding space left around the text.protected void onChangeTextPadding()
public Brush getTextBrush()
public void setTextBrush(Brush value)
public Brush getEffectiveTextBrush()
public Pen getPen()
Pen
object representing the item's pen.public void setPen(Pen value)
value
- A Pen
object representing the item's pen.public Pen getEffectivePen()
public Brush getBrush()
Brush
-derived object representing the item's brush.public void setBrush(Brush value)
value
- A Brush
-derived object representing the item's brush.public Brush getEffectiveBrush()
public Brush getShadowBrush()
Brush
object representing the brush of the
item's shadow.public void setShadowBrush(Brush value)
value
- A Brush
object representing the brush of the
item's shadow.public Brush getEffectiveShadowBrush()
Brush
object representing the currently
effective shadow brush of the item.
This method returns a system brush corresponding to the item's
ShadowBrush
if the item's
ShadowBrush
is not null
,
or a system brush corresponding to the
ShadowBrush
property of the item's style.public float getShadowOffsetX()
public void setShadowOffsetX(float value)
value
- A float value representing the horizontal offset of the
item's shadow.public float getShadowOffsetY()
public void setShadowOffsetY(float value)
value
- A float value representing the vertical offset of the
item's shadow.protected void startCreate(android.graphics.PointF org)
org
- The initial position of the pointer.protected void updateCreate(android.graphics.PointF current)
current
- The current position of the pointer.protected void completeCreate(android.graphics.PointF end)
end
- The pointer position.protected abstract boolean allowCreate(android.graphics.PointF current, InteractionState ist)
current
- The current pointer position.ist
- An InteractionState
object containing more information about the current state of the operation.protected void startModify(android.graphics.PointF org, AdjustmentHandle handle, InteractionState ist)
org
- The initial position of the pointer.handle
- The adjustment handle used to modify this item.ist
- An InteractionState
object containing more information about the current state of the operation.protected void updateModify(android.graphics.PointF current, InteractionState ist)
current
- The current position of the pointer.ist
- An InteractionState
object containing more information about the current state of the operation.protected void completeModify(android.graphics.PointF end, InteractionState ist)
end
- The pointer position.ist
- An InteractionState
object containing more information about the current state of the operation.protected abstract boolean allowModify(android.graphics.PointF current, InteractionState ist)
current
- The current pointer position.ist
- An InteractionState object containing more information about the current state of the operation.protected void cancelModify(InteractionState ist)
ist
- An InteractionState
object containing more information about the current state of the operation.protected void onClick(int mouseButton, android.graphics.PointF pointerPosition)
mouseButton
- Specifies the mouse button used to click the item.pointerPosition
- Specifies the pointer position.protected void onDoubleClick(int mouseButton, android.graphics.PointF pointerPosition)
mouseButton
- Specifies the mouse button used to click the item.pointerPosition
- Specifies the pointer positionpublic abstract boolean containsPoint(android.graphics.PointF point)
point
- The point to check.public abstract AdjustmentHandle hitTestHandle(android.graphics.PointF point)
point
- A PointF instance specifying the location where to look for adjustment handles.AdjustmentHandle
instance representing the adjustment
handle found at the specified location, or null if there is none.public boolean getSelected()
true
if the item is selected,
otherwise false
.public void setSelected(boolean value)
value
- true
if the item should be selected,
otherwise false
.protected void putSelected(boolean newVal)
protected DiagramItemState createState()
protected void saveState(DiagramItemState state)
protected void restoreState(DiagramItemState state)
protected DiagramItemProperties createProperties()
ChangeItemCmd
instance.protected void saveProperties(DiagramItemProperties props)
ChangeItemCmd
instance.props
- A DiagramItemProperties-derived object where
the item's properties should be saved.protected void restoreProperties(DiagramItemProperties props)
ChangeItemCmd
instance.props
- A DiagramItemProperties -derived object containing a
snapshot of the item's properties.public java.lang.String getHyperLink()
String
containing the hyperlink.public void setHyperLink(java.lang.String value)
value
- A String
containing the hyperlink.public java.util.Hashtable<java.lang.Object,java.lang.Object> getLayoutTraits()
public float getWeight()
public void setWeight(float value)
value
- A float value representing the item's weight.protected java.lang.Object getValue(java.lang.String name)
protected void onStyleChanged()
public DiagramItemStyle getStyle()
public void setStyle(DiagramItemStyle value)