|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.mindfusion.diagramming.DiagramItem
public abstract class DiagramItem
The DiagramItem class represents an element in a diagram. It defines the basic drawing, interaction, undo/redo and serialization functionality for all the types of elements that can be contained in JDiagram documents.
The interior and borders of the diagram items are painted using the brush
and pen specified via setBrush(com.mindfusion.diagramming.Brush)
and setPen(com.mindfusion.diagramming.Pen)
. The font of
items text is set via the setFont(java.awt.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.diagramming.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.
Field Summary | |
---|---|
protected Brush |
brush
|
protected boolean |
cycleDetected
|
protected boolean |
cycleProtect
|
protected double |
modifyDX
|
protected double |
modifyDY
|
protected int |
modifyHandle
|
protected boolean |
modifying
|
protected Pen |
pen
|
protected java.awt.geom.Point2D |
ptEnd
|
protected java.awt.geom.Point2D |
ptMdfLast
|
protected java.awt.geom.Point2D |
ptOrg
|
protected java.awt.geom.Point2D |
ptSavedEnd
|
protected java.awt.geom.Point2D |
ptSavedOrg
|
protected Group |
subordinateGroup
|
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
protected abstract boolean |
allowCreate(java.awt.geom.Point2D current,
InteractionState ist)
Invoked during interactive creation of items to test whether the operation can be completed in the current context. |
protected abstract boolean |
allowModify(java.awt.geom.Point2D 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 object has been canceled. |
DiagramItem |
clone(boolean clipboard)
|
protected void |
completeCreate(java.awt.geom.Point2D end)
Invoked when the item creation has been completed. |
protected void |
completeModify(java.awt.geom.Point2D end,
InteractionState ist)
Invoked when the item modification has been completed. |
abstract boolean |
containsPoint(java.awt.geom.Point2D point)
Determines 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(java.awt.Graphics2D g,
RenderOptions options)
|
protected abstract void |
drawShadow(java.awt.Graphics2D g,
RenderOptions options)
|
abstract java.awt.geom.Rectangle2D.Float |
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. |
java.awt.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. |
java.awt.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 int |
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 java.awt.geom.Rectangle2D |
getRepaintRect(boolean includeConnected)
Gets the repaint region for this item, taking into account factors such as pen, selection handles and shadow. |
int |
getRuntimeIndex()
|
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 mouse 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. |
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,
int handle)
Called when a group child node has been modified. |
protected void |
onClick(int mouseButton,
java.awt.geom.Point2D mousePosition)
Invoked when the user clicks this item. |
protected void |
onDoubleClick(int mouseButton,
java.awt.geom.Point2D mousePosition)
Invoked when the user double-clicks this item. |
protected void |
onLoad(Diagram diagram)
|
protected void |
onModify(java.awt.geom.Point2D mousePosition,
int adjustmentHandle)
Called when an item is modified |
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)
Implements Externalizable. |
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(java.awt.geom.Rectangle2D 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(java.awt.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 mouse 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(java.awt.geom.Point2D org)
Invoked once when the user starts creating a new item interactively. |
protected void |
startModify(java.awt.geom.Point2D org,
int handle,
InteractionState ist)
Invoked when the user starts modifying this item interactively. |
protected void |
updateCreate(java.awt.geom.Point2D current)
Invoked during interactive creation of this item. |
protected void |
updateModify(java.awt.geom.Point2D current,
InteractionState ist)
Invoked during interactive modification of this item. |
void |
writeExternal(java.io.ObjectOutput out)
Implements Externalizable. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected Group subordinateGroup
protected boolean cycleProtect
protected boolean cycleDetected
protected java.awt.geom.Point2D ptOrg
protected java.awt.geom.Point2D ptEnd
protected java.awt.geom.Point2D ptSavedOrg
protected java.awt.geom.Point2D ptSavedEnd
protected Brush brush
protected Pen pen
protected boolean modifying
protected double modifyDX
protected double modifyDY
protected int modifyHandle
protected java.awt.geom.Point2D ptMdfLast
Constructor Detail |
---|
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.Method Detail |
---|
public DiagramItem clone(boolean clipboard)
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, int 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 methods
javax.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 java.awt.geom.Rectangle2D.Float getBounds()
Rectangle2D
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(java.awt.Graphics2D g, RenderOptions options)
protected abstract void drawShadow(java.awt.Graphics2D g, RenderOptions options)
protected boolean shouldRender()
protected java.awt.geom.Rectangle2D getRepaintRect(boolean includeConnected)
includeConnected
- true if related items should be considered too; otherwise, false.
protected int getMeasureUnit()
protected void setDiagramDirty()
protected void repaint()
protected void repaint(boolean includeConnected)
protected void repaint(java.awt.geom.Rectangle2D 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 java.awt.Font getFont()
Font
object representing the font used
to draw this item's text.public void setFont(java.awt.Font value)
value
- A Font
object representing the font
used to draw this item's text.public java.awt.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(java.awt.geom.Point2D org)
org
- Position of the mouse pointer.protected void updateCreate(java.awt.geom.Point2D current)
current
- Position of the mouse pointer.protected void completeCreate(java.awt.geom.Point2D end)
end
- The mouse pointer position.protected abstract boolean allowCreate(java.awt.geom.Point2D current, InteractionState ist)
current
- The current mouse pointer position.ist
- An InteractionState
object containing more information about the current state of the operation.
protected void startModify(java.awt.geom.Point2D org, int handle, InteractionState ist)
org
- Position of the mouse pointer.handle
- Index of the adjustment handle used to modify the item.ist
- An InteractionState
object containing more information about the current state of the operation.protected void updateModify(java.awt.geom.Point2D current, InteractionState ist)
current
- Position of the mouse pointer.ist
- An InteractionState
object containing more information about the current state of the operation.protected void completeModify(java.awt.geom.Point2D end, InteractionState ist)
end
- The mouse pointer position.ist
- An InteractionState
object containing more information about the current state of the operation.protected abstract boolean allowModify(java.awt.geom.Point2D current, InteractionState ist)
current
- The current mouse 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, java.awt.geom.Point2D mousePosition)
mouseButton
- Specifies the mouse button used to click the item.mousePosition
- Specifies the mouse position.protected void onDoubleClick(int mouseButton, java.awt.geom.Point2D mousePosition)
mouseButton
- Specifies the mouse button used to click the item.mousePosition
- Specifies the mouse positionprotected void onModify(java.awt.geom.Point2D mousePosition, int adjustmentHandle)
mousePosition
- Specifies the mouse position.adjustmentHandle
- The adjustment handle used to modify the node.public abstract boolean containsPoint(java.awt.geom.Point2D point)
point
- The point to check.
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)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |