public class Shape
extends java.lang.Object
A shape is used by applying it to a ShapeNode
instance by calling the
ShapeNode.setShape(com.mindfusion.diagramming.Shape)
method.
Constructor and Description |
---|
Shape(ElementTemplate[] outline,
ElementTemplate[] decorations,
ElementTemplate[] textArea,
int windingRule,
java.lang.String id)
Initializes a new
Shape instance by setting its outline,
decorations, text area, fill rule and shape identifier. |
Shape(ElementTemplate[] elements,
ElementTemplate[] decorations,
ElementTemplate[] textArea,
int windingRule,
java.lang.String id,
ShapeDecoration[] closedDecorations) |
Shape(ElementTemplate[] outline,
int windingRule,
java.lang.String id)
Initializes a new
Shape instance by setting its outline,
fill rule and shape identifier. |
Shape(short[] outline,
java.lang.String id)
Initializes a new instance of the Shape class with the
specified outline and id.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(java.awt.Graphics2D graphics,
Brush brush,
Pen pen,
boolean shadow)
Draws this shape on the specified Graphics2D surface.
|
static Shape |
fromId(java.lang.String id)
Returns the shape that has the specified identifier.
|
static Shape |
fromXmlElement(org.w3c.dom.Element e)
Creates a ShapeTemplate from xml shape element
|
static Shape[] |
fromXmlElements(org.w3c.dom.Element shapes) |
AnchorPattern |
getAnchorPattern()
Gets the anchor pattern to use for nodes using this shape,
if their anchor pattern is set to null.
|
ElementTemplate[] |
getDecorations()
Gets a list of all decorations of this shape.
|
java.lang.String |
getDisplayName() |
java.awt.geom.GeneralPath |
getHitPath(java.awt.geom.Rectangle2D rect,
boolean flipX,
boolean flipY,
double rotationAngle) |
java.lang.String |
getId()
Return the shape identifier.
|
java.awt.Image |
getImage()
Gets an image that is displayed by default in all instances of this shape.
|
java.lang.String |
getImageLocation()
Get the image location.
|
java.awt.geom.Rectangle2D.Float |
getImageRectangle()
Gets the location of the shape image relatively to the bounding rectangles of boxes of this shape.
|
boolean |
getIsArrowhead()
Gets a value indicating if this shape is used as arrowhead.
|
float |
getLinkSegmentInset()
Gets what length of link's line segment is drawn inside the arrowhead shape, expressed as percents of arrowhead size.
|
ElementTemplate[] |
getOutline()
Gets the outline of this shape.
|
java.awt.geom.GeneralPath |
getRenderPath(ShapeData data,
boolean flipX,
boolean flipY,
double rotationAngle) |
static ShapeList |
getShapes()
Returns a list of all shapes definitions.
|
ElementTemplate[] |
getTextArea()
Gets the outline of the text area of this shape.
|
ShapeData |
initData(java.awt.geom.Rectangle2D rc,
double rotation) |
boolean |
isEllipse()
Gets a value indicating whether this shape is elliptic.
|
void |
setAnchorPattern(AnchorPattern value)
Sets the anchor pattern to use for nodes using this shape,
if their anchor pattern is set to null.
|
void |
setDisplayName(java.lang.String displayName) |
void |
setId(java.lang.String value) |
void |
setImage(java.awt.Image image)
Sets an image that should be displayed by default in all instances of this shape.
|
void |
setImageLocation(java.lang.String url)
Accepted are absolute URLs, and relative paths with both back and forward slashes
.NET ShapeEditor may produce absolute filesystem image paths when the images are on different drive
than the shape library xml, and they will not work on java.
|
void |
setImageRectangle(java.awt.geom.Rectangle2D.Float imageRectangle)
Sets the location of the shape image relatively to the bounding rectangles of boxes of this shape.
|
void |
setLinkSegmentInset(float value)
Sets what length of link's line segment is drawn inside the arrowhead shape, expressed as percents of arrowhead size.
|
void |
setTextArea(ElementTemplate[] value)
Sets the outline of the text area of this shape.
|
org.w3c.dom.Element |
toDOM(org.w3c.dom.Document owner) |
static org.w3c.dom.Element[] |
toDOM(Shape[] shapes,
org.w3c.dom.Document owner) |
public Shape(ElementTemplate[] outline, int windingRule, java.lang.String id)
Shape
instance by setting its outline,
fill rule and shape identifier.outline
- An array of ElementTemplate
objects representing
the shape outline, which specifies what region of a box is filled,
used for hit-testing and for aligning link end point to the box.windingRule
- GeneralPath.WIND_EVEN_ODD or GeneralPath.WIND_NON_ZERO.id
- An unique String
identifier of this shape.public Shape(ElementTemplate[] outline, ElementTemplate[] decorations, ElementTemplate[] textArea, int windingRule, java.lang.String id)
Shape
instance by setting its outline,
decorations, text area, fill rule and shape identifier.outline
- An array of ElementTemplate
objects representing
the shape outline, which specifies what region of a box is filled,
used for hit-testing and for aligning link end point to the box.decorations
- An array of ElementTemplate
objects representing
the shape decoration lines.textArea
- An array of ElementTemplate
objects representing
the region of the shape where box' text is laid out.windingRule
- GeneralPath.WIND_EVEN_ODD or GeneralPath.WIND_NON_ZERO.id
- An unique String
identifier of this shape.public Shape(ElementTemplate[] elements, ElementTemplate[] decorations, ElementTemplate[] textArea, int windingRule, java.lang.String id, ShapeDecoration[] closedDecorations)
public Shape(short[] outline, java.lang.String id)
outline
- An array containing even number of coordinate values,
which define the points of the shape outline.id
- The string identifier of the new shape.public ShapeData initData(java.awt.geom.Rectangle2D rc, double rotation)
public java.awt.geom.GeneralPath getHitPath(java.awt.geom.Rectangle2D rect, boolean flipX, boolean flipY, double rotationAngle)
public java.awt.geom.GeneralPath getRenderPath(ShapeData data, boolean flipX, boolean flipY, double rotationAngle)
public java.lang.String getId()
String
object containing the shape identifier.public void setId(java.lang.String value)
public static ShapeList getShapes()
ShapeList
that contains all shape definitions.public static Shape fromId(java.lang.String id)
id
- The identifier of the looked-for shape.Shape
identified by the specified string.public static Shape[] fromXmlElements(org.w3c.dom.Element shapes) throws javax.xml.transform.TransformerException, XmlException
javax.xml.transform.TransformerException
XmlException
public static Shape fromXmlElement(org.w3c.dom.Element e) throws javax.xml.transform.TransformerException, XmlException
javax.xml.transform.TransformerException
XmlException
public java.lang.String getImageLocation()
public void setImageLocation(java.lang.String url)
url
- public static org.w3c.dom.Element[] toDOM(Shape[] shapes, org.w3c.dom.Document owner)
public org.w3c.dom.Element toDOM(org.w3c.dom.Document owner)
public java.awt.Image getImage()
Image
displayed inside boxes of this shape.public void setImage(java.awt.Image image)
image
- An Image
that should be displayed inside boxes of this shape.public java.awt.geom.Rectangle2D.Float getImageRectangle()
public void setImageRectangle(java.awt.geom.Rectangle2D.Float imageRectangle)
imageRectangle
- A Rectangle2D object specifying the image
coordinates as percents of the box bounds.public AnchorPattern getAnchorPattern()
AnchorPattern
instance.public void setAnchorPattern(AnchorPattern value)
value
- An AnchorPattern
instance.public void setDisplayName(java.lang.String displayName)
displayName
- The name that should be displayed for this shape
in user interface, e.g. in the ShapeListBox.public java.lang.String getDisplayName()
public boolean getIsArrowhead()
public ElementTemplate[] getOutline()
ElementTemplate
objects specifying the outline of the shape.public ElementTemplate[] getDecorations()
ElementTemplate
objects specifying the decorations of this shape.public ElementTemplate[] getTextArea()
ElementTemplate
objects specifying the text area of this shape.public void setTextArea(ElementTemplate[] value)
value
- An array of ElementTemplate
objects specifying the text area of this shape.public boolean isEllipse()
public void draw(java.awt.Graphics2D graphics, Brush brush, Pen pen, boolean shadow)
graphics
- The Graphics2D surface on which to draw the shape.brush
- A Brush used to fill the shape.pen
- A Pen used to draw the shape outline.shadow
- When shadow is true the brush and pen parameters have higher priority over shape's brush and pen.public float getLinkSegmentInset()
public void setLinkSegmentInset(float value)
value
- A float value specifying percentage of arrowhead size.