Package org.pathvisio.libgpml.model
Class ShapedElement
java.lang.Object
org.pathvisio.libgpml.model.PathwayObject
org.pathvisio.libgpml.model.PathwayElement
org.pathvisio.libgpml.model.ShapedElement
- All Implemented Interfaces:
java.lang.Cloneable
,Drawable
,GraphLink.LinkableTo
,Groupable
,Referenceable
,Referenceable.Annotatable
,Referenceable.Citable
,Referenceable.Evidenceable
- Direct Known Subclasses:
DataNode
,DataNode.State
,Group
,Label
,Shape
public abstract class ShapedElement extends PathwayElement implements GraphLink.LinkableTo, Groupable
This class stores information for shaped pathway element
DataNode
,
DataNode.State
, Label
, Shape
, and Group
.- Author:
- finterly
-
Nested Class Summary
Nested classes/interfaces inherited from class org.pathvisio.libgpml.model.PathwayElement
PathwayElement.AnnotationRef, PathwayElement.CitationRef, PathwayElement.Comment, PathwayElement.EvidenceRef, PathwayElement.InfoRef
Nested classes/interfaces inherited from interface org.pathvisio.libgpml.model.Referenceable
Referenceable.Annotatable, Referenceable.Citable, Referenceable.Evidenceable
-
Field Summary
Fields Modifier and Type Field Description private java.awt.Color
borderColor
private LineStyleType
borderStyle
private double
borderWidth
private double
centerX
private double
centerY
private java.awt.Color
fillColor
private boolean
fontDecoration
private java.lang.String
fontName
private double
fontSize
private boolean
fontStrikethru
private boolean
fontStyle
private boolean
fontWeight
private Group
groupRef
private HAlignType
hAlign
private double
height
private double
rotation
private IShape
shapeType
private java.awt.Color
textColor
private VAlignType
vAlign
private double
width
private int
zOrder
Fields inherited from class org.pathvisio.libgpml.model.PathwayObject
noFire, pathwayModel
-
Constructor Summary
Constructors Constructor Description ShapedElement()
Instantiates a shaped pathway element. -
Method Summary
Modifier and Type Method Description void
copyValuesFrom(ShapedElement src)
Copies values from the given source pathway element.java.awt.Color
getBorderColor()
Returns the border color of this shaped pathway element.LineStyleType
getBorderStyle()
Returns the visual appearance of a border, e.g.double
getBorderWidth()
Returns the pixel value for the border of this shaped pathway element.java.awt.geom.Rectangle2D
getBounds()
Returns the rectangular bounds of this shaped pathway element without rotation taken into account.double
getCenterX()
Returns the center x coordinate for this shaped pathway element.double
getCenterY()
Returns the center y coordinate for this shaped pathway element.java.awt.Color
getFillColor()
Returns the color used to paint the area of this shaped pathway element., not including its border.boolean
getFontDecoration()
Returns the typographic style for underline or normal.java.lang.String
getFontName()
Returns the name of the set of printable text characters to be used for visualization, e.g., Arial.double
getFontSize()
Returns the point value for the size of the font.boolean
getFontStrikethru()
Returns the typographic style for strikethru or normal.boolean
getFontStyle()
Returns the typographic style applied to displayed text, e.g.boolean
getFontWeight()
Returns the thickness of the font used, a bold font would have more weight.Group
getGroupRef()
Returns the parent group of this pathway element.HAlignType
getHAlign()
Returns the horizontal alignment of displayed text, e.g., Left, Center, Right.double
getHeight()
Returns the height of this shaped pathway element.double
getLeft()
Returns the left x coordinate of the bounding box around (start, end) this shaped pathway element.java.util.Set<GraphLink.LinkableFrom>
getLinkableFroms()
ReturnsGraphLink.LinkableFrom
pathway elements, at this time that only goes forLineElement.LinePoint
, for thisGraphLink.LinkableTo
pathway element.java.awt.geom.Rectangle2D
getRotatedBounds()
Returns the rectangular bounds of this shaped pathway element after rotation is applied.double
getRotation()
Returns the rotation of this shaped pathway element.IShape
getShapeType()
Returns the visual appearance of a two dimensional object, e.g.java.lang.Object
getStaticProperty(StaticProperty key)
Returns static property value for given key.java.util.Set<StaticProperty>
getStaticPropertyKeys()
Returns all static properties for this pathway object.java.awt.Color
getTextColor()
Returns the color of text for this shaped pathway element..abstract java.lang.String
getTextLabel()
Returns text label for shaped pathway elements.double
getTop()
Returns the top y coordinate of the bounding box around (start, end) this shaped pathway element.VAlignType
getVAlign()
Returns the vertical alignment of displayed text, e.g., Top, Middle, Bottom.double
getWidth()
Returns the width of this shaped pathway element.int
getZOrder()
Returns the z-order of this pathway element.boolean
hasGroupRef()
Checks whether this pathway element belongs to a group.void
setBorderColor(java.awt.Color v)
Sets the border color of this shaped pathway element.void
setBorderStyle(LineStyleType v)
Sets the visual appearance of a border, e.g.void
setBorderWidth(double v)
Sets the pixel value for the border of this shaped pathway element.void
setCenterX(double v)
Sets the center x coordinate for this shaped pathway element.void
setCenterY(double v)
Sets the center y coordinate for this shaped pathway element.void
setFillColor(java.awt.Color v)
Sets the color used to paint the area of this shaped pathway element, not including its border.void
setFontDecoration(boolean v)
Sets the typographic style for underline or normal.void
setFontName(java.lang.String v)
Sets the name of the set of printable text characters to be used for visualization, e.g., Arial.void
setFontSize(double v)
Sets point value for the size of the font.void
setFontStrikethru(boolean v)
Sets the typographic style for strikethru or normal.void
setFontStyle(boolean v)
Sets the typographic style applied to displayed text, e.g.void
setFontWeight(boolean v)
Sets the thickness of the font used, a bold font would have more weight.private void
setGroupRef(Group v)
Sets the parent group for this pathway element.void
setGroupRefTo(Group v)
Verifies if given parent group is new and valid.void
setHAlign(HAlignType v)
Sets the horizontal alignment of displayed text, e.g., Left, Center, Right.void
setHeight(double v)
Sets the height of this shaped pathway element.void
setLeft(double v)
Sets the center x coordinate given the left x coordinate of the bounding box around (start, end) this shaped pathway element.void
setRotation(java.lang.Double v)
Sets the rotation of this shaped pathway element.void
setShapeType(IShape v)
Returns the visual appearance of a two dimensional object, e.g.void
setStaticProperty(StaticProperty key, java.lang.Object value)
This works so that o.setNotes(x) is the equivalent of o.setProperty("Notes", x); Value may be null in some cases, e.g.void
setTextColor(java.awt.Color v)
Sets the color of text for this shaped pathway element.abstract void
setTextLabel(java.lang.String v)
Sets text label for this shaped pathway elements.void
setTop(double v)
Sets the center y coordinate given the top y coordinate of the bounding box around (start, end) this shaped pathway element.void
setVAlign(VAlignType v)
Sets the vertical alignment of displayed text, e.g., Top, Middle, Bottom.void
setWidth(double v)
Sets the width of this shaped pathway element.void
setZOrder(int v)
Sets the z-order of this pathway element.protected void
terminate()
Terminates this pathway element.java.awt.geom.Point2D
toAbsoluteCoordinate(java.awt.geom.Point2D p)
Converts a point to pathway coordinates (relative to the pathway).java.awt.geom.Point2D
toRelativeCoordinate(java.awt.geom.Point2D p)
Converts a point to shape coordinates (relative to the bounds of the shape).void
unsetAllLinkableFroms()
Removes links from allGraphLink.LinkableFrom
line points to thisGraphLink.LinkableTo
pathway element.void
unsetGroupRef()
Unsets the parent group, if any, from this pathway element.Methods inherited from class org.pathvisio.libgpml.model.PathwayElement
addAnnotation, addAnnotation, addAnnotation, addCitation, addCitation, addCitation, addComment, addComment, addEvidence, addEvidence, addEvidence, copy, copyReferencesFrom, copyValuesFrom, findComment, getAnnotationRefs, getCitationRefs, getComments, getDynamicProperties, getDynamicProperty, getDynamicPropertyKeys, getEvidenceRefs, getPropertyEx, getPropertyKeys, hasAnnotationRef, hasCitationRef, hasEvidenceRef, removeAnnotationRef, removeAnnotationRefs, removeCitationRef, removeCitationRefs, removeComment, removeEvidenceRef, removeEvidenceRefs, setComments, setDynamicProperty, setPropertyEx
Methods inherited from class org.pathvisio.libgpml.model.PathwayObject
addListener, dontFireEvents, fireObjectModifiedEvent, getElementId, getListeners, getObjectType, getPathwayModel, hasPathwayModel, removeListener, setElementId, setGeneratedElementId, setPathwayModel, setPathwayModelTo, unsetPathwayModel
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.pathvisio.libgpml.model.Drawable
getObjectType, getPathwayModel
Methods inherited from interface org.pathvisio.libgpml.model.GraphLink.LinkableTo
getElementId, getObjectType
-
Field Details
-
groupRef
-
centerX
private double centerX -
centerY
private double centerY -
width
private double width -
height
private double height -
textColor
private java.awt.Color textColor -
fontName
private java.lang.String fontName -
fontWeight
private boolean fontWeight -
fontStyle
private boolean fontStyle -
fontDecoration
private boolean fontDecoration -
fontStrikethru
private boolean fontStrikethru -
fontSize
private double fontSize -
hAlign
-
vAlign
-
borderColor
private java.awt.Color borderColor -
borderStyle
-
borderWidth
private double borderWidth -
fillColor
private java.awt.Color fillColor -
shapeType
-
zOrder
private int zOrder -
rotation
private double rotation
-
-
Constructor Details
-
ShapedElement
public ShapedElement()Instantiates a shaped pathway element. Property groupRef is to be set bysetGroupRefTo(Group)
. In GPML, groupRef refers to the elementId (formerly groupId) of the parent gpml:Group. Note, a group can also belong in another group. Graphics properties have default values and can be set after a shaped pathway element is already instantiated.
-
-
Method Details
-
getTextLabel
public abstract java.lang.String getTextLabel()Returns text label for shaped pathway elements. Text labels are required forDataNode
,DataNode.State
andLabel
; and optional forShape
andGroup
.- Returns:
- the text of of the shaped pathway element.
-
setTextLabel
public abstract void setTextLabel(java.lang.String v)Sets text label for this shaped pathway elements.- Parameters:
v
- the the text to set for this shaped pathway element.
-
getGroupRef
Returns the parent group of this pathway element. In GPML, groupRef refers to the elementId (formerly groupId) of the parent gpml:Group.- Specified by:
getGroupRef
in interfaceGroupable
- Returns:
- groupRef the parent group of this pathway element.
-
hasGroupRef
public boolean hasGroupRef()Checks whether this pathway element belongs to a group.- Specified by:
hasGroupRef
in interfaceGroupable
- Returns:
- true if and only if the group of this pathway element is effective.
-
setGroupRefTo
Verifies if given parent group is new and valid. Sets the parent group of this pathway element. Adds this pathway element to the the pathwayElements list of the new parent group. If there is an old parent group, this pathway element is removed from its pathwayElements list.- Specified by:
setGroupRefTo
in interfaceGroupable
- Parameters:
v
- the new parent group to set.
-
setGroupRef
Sets the parent group for this pathway element.- Parameters:
v
- the given group to set.
-
unsetGroupRef
public void unsetGroupRef()Unsets the parent group, if any, from this pathway element.- Specified by:
unsetGroupRef
in interfaceGroupable
-
getCenterX
public double getCenterX()Returns the center x coordinate for this shaped pathway element.- Specified by:
getCenterX
in interfaceGroupable
- Returns:
- centerX the middle of an object in the x direction.
-
setCenterX
public void setCenterX(double v)Sets the center x coordinate for this shaped pathway element.- Specified by:
setCenterX
in interfaceGroupable
- Parameters:
v
- the middle of an object in the x direction to set.
-
getCenterY
public double getCenterY()Returns the center y coordinate for this shaped pathway element.- Specified by:
getCenterY
in interfaceGroupable
- Returns:
- centerY the middle of an object in the y direction.
-
setCenterY
public void setCenterY(double v)Sets the center y coordinate for this shaped pathway element.- Specified by:
setCenterY
in interfaceGroupable
- Parameters:
v
- the middle of an object in the y direction to set.
-
getWidth
public double getWidth()Returns the width of this shaped pathway element. -
setWidth
public void setWidth(double v)Sets the width of this shaped pathway element.- Parameters:
v
- the width to set for this shaped pathway element.- Throws:
java.lang.IllegalArgumentException
- if width is a negative value.
-
getHeight
public double getHeight()Returns the height of this shaped pathway element. -
setHeight
public void setHeight(double v)Sets the height of this shaped pathway element.- Parameters:
v
- the height to set for this shaped pathway element.- Throws:
java.lang.IllegalArgumentException
- if height is a negative value.
-
getTextColor
public java.awt.Color getTextColor()Returns the color of text for this shaped pathway element..- Returns:
- textColor the color of text.
-
setTextColor
public void setTextColor(java.awt.Color v)Sets the color of text for this shaped pathway element.- Parameters:
v
- the color of text for this shaped pathway element.- Throws:
java.lang.IllegalArgumentException
- if color null.
-
getFontName
public java.lang.String getFontName()Returns the name of the set of printable text characters to be used for visualization, e.g., Arial.- Returns:
- fontName the name of the font.
-
setFontName
public void setFontName(java.lang.String v)Sets the name of the set of printable text characters to be used for visualization, e.g., Arial.- Parameters:
v
- the name of the font.- Throws:
java.lang.IllegalArgumentException
- if given fontName is null.
-
getFontWeight
public boolean getFontWeight()Returns the thickness of the font used, a bold font would have more weight.- Returns:
- fontWeight the boolean, if true font weight is bold. If false, font weight is normal.
-
setFontWeight
public void setFontWeight(boolean v)Sets the thickness of the font used, a bold font would have more weight.- Parameters:
v
- the boolean, if true font weight is bold. If false, font weight is normal.
-
getFontStyle
public boolean getFontStyle()Returns the typographic style applied to displayed text, e.g. normal or italic.- Returns:
- fontStyle the boolean, if true typographic style is italic. If false, typographic style is normal.
-
setFontStyle
public void setFontStyle(boolean v)Sets the typographic style applied to displayed text, e.g. normal or italic.- Parameters:
v
- the boolean, if true typographic style is italic. If false, typographic style is normal.
-
getFontDecoration
public boolean getFontDecoration()Returns the typographic style for underline or normal.- Returns:
- fontDecoration the boolean, if true typographic style is underline. If false, typographic style is normal.
-
setFontDecoration
public void setFontDecoration(boolean v)Sets the typographic style for underline or normal.- Parameters:
v
- the boolean, if true typographic style is underline. If false, typographic style is normal.
-
getFontStrikethru
public boolean getFontStrikethru()Returns the typographic style for strikethru or normal.- Returns:
- fontStrikethru the boolean, if true typographic style is strikethru. If false, typographic style is normal.
-
setFontStrikethru
public void setFontStrikethru(boolean v)Sets the typographic style for strikethru or normal.- Parameters:
v
- the boolean, if true typographic style is strikethru. If false, typographic style is normal.
-
getFontSize
public double getFontSize()Returns the point value for the size of the font.- Returns:
- fontSize the value for the size of the font.
-
setFontSize
public void setFontSize(double v)Sets point value for the size of the font. Rounds any decimals to the nearest 0.5.- Parameters:
v
- the value for the size of the font.- Throws:
java.lang.IllegalArgumentException
- if fontSize is a negative value.
-
getHAlign
Returns the horizontal alignment of displayed text, e.g., Left, Center, Right.- Returns:
- hAlign the horizontal alignment value of displayed text.
-
setHAlign
Sets the horizontal alignment of displayed text, e.g., Left, Center, Right.- Parameters:
v
- the horizontal alignment value of displayed text.
-
getVAlign
Returns the vertical alignment of displayed text, e.g., Top, Middle, Bottom.- Returns:
- vAlign the vertical alignment value of displayed text.
-
setVAlign
Sets the vertical alignment of displayed text, e.g., Top, Middle, Bottom.- Parameters:
v
- the vertical alignment value of displayed text.
-
getBorderColor
public java.awt.Color getBorderColor()Returns the border color of this shaped pathway element.- Returns:
- borderColor the border color of this shaped pathway element.
-
setBorderColor
public void setBorderColor(java.awt.Color v)Sets the border color of this shaped pathway element.- Parameters:
v
- the border color of this shaped pathway element.- Throws:
java.lang.IllegalArgumentException
- if color null.
-
getBorderStyle
Returns the visual appearance of a border, e.g. Solid or Broken.- Returns:
- borderStyle the style of a border.
-
setBorderStyle
Sets the visual appearance of a border, e.g. Solid or Broken.- Parameters:
v
- the style of a border.
-
getBorderWidth
public double getBorderWidth()Returns the pixel value for the border of this shaped pathway element.- Returns:
- borderWidth the width of a border.
-
setBorderWidth
public void setBorderWidth(double v)Sets the pixel value for the border of this shaped pathway element.- Parameters:
v
- the width of a border.- Throws:
java.lang.IllegalArgumentException
- if borderWidth is a negative value.
-
getFillColor
public java.awt.Color getFillColor()Returns the color used to paint the area of this shaped pathway element., not including its border.- Returns:
- fillColor the fill color of this shaped pathway element.
-
setFillColor
public void setFillColor(java.awt.Color v)Sets the color used to paint the area of this shaped pathway element, not including its border.- Parameters:
v
- the fill color of this shaped pathway element.- Throws:
java.lang.IllegalArgumentException
- if fillColor null.
-
getShapeType
Returns the visual appearance of a two dimensional object, e.g. Rectangle, Arc, Mitochondria, Oval. NB: Shape.type is for object type while shapeType is the visual appearance. For example, an object may have Shape.type "Nucleus" and shapeType "Oval".- Returns:
- shapeType the visual appearance of this shaped pathway element.
-
setShapeType
Returns the visual appearance of a two dimensional object, e.g. Rectangle, Arc, Mitochondria, Oval. NB: Shape.type is for object type while shapeType is the visual appearance. For example, an object may have Shape.type "Nucleus" and shapeType "Oval".- Parameters:
v
- the visual appearance of this shaped pathway element.- Throws:
java.lang.IllegalArgumentException
- if shapeType null.
-
getZOrder
public int getZOrder()Returns the z-order of this pathway element. -
setZOrder
public void setZOrder(int v)Sets the z-order of this pathway element. -
getRotation
public double getRotation()Returns the rotation of this shaped pathway element.- Returns:
- rotation the rotation of this shaped pathway element.
-
setRotation
public void setRotation(java.lang.Double v)Sets the rotation of this shaped pathway element.- Parameters:
v
- the rotation of this shaped pathway element.
-
getLinkableFroms
ReturnsGraphLink.LinkableFrom
pathway elements, at this time that only goes forLineElement.LinePoint
, for thisGraphLink.LinkableTo
pathway element.- Specified by:
getLinkableFroms
in interfaceGraphLink.LinkableTo
- Returns:
- the LinkableFrom line points.
-
unsetAllLinkableFroms
public void unsetAllLinkableFroms()Removes links from allGraphLink.LinkableFrom
line points to thisGraphLink.LinkableTo
pathway element. -
terminate
protected void terminate()Terminates this pathway element. The pathway model, if any, is unset from this pathway element. Links to all annotationRefs, citationRefs, and evidenceRefs are removed from this data node.- Overrides:
terminate
in classPathwayElement
-
getRotatedBounds
public java.awt.geom.Rectangle2D getRotatedBounds()Returns the rectangular bounds of this shaped pathway element after rotation is applied.- Specified by:
getRotatedBounds
in interfaceGroupable
- Returns:
- the rectangular bounds for this shaped pathway element with rotation taken into account.
-
getBounds
public java.awt.geom.Rectangle2D getBounds()Returns the rectangular bounds of this shaped pathway element without rotation taken into account. -
getLeft
public double getLeft()Returns the left x coordinate of the bounding box around (start, end) this shaped pathway element. -
setLeft
public void setLeft(double v)Sets the center x coordinate given the left x coordinate of the bounding box around (start, end) this shaped pathway element. -
getTop
public double getTop()Returns the top y coordinate of the bounding box around (start, end) this shaped pathway element. -
setTop
public void setTop(double v)Sets the center y coordinate given the top y coordinate of the bounding box around (start, end) this shaped pathway element. -
toAbsoluteCoordinate
public java.awt.geom.Point2D toAbsoluteCoordinate(java.awt.geom.Point2D p)Converts a point to pathway coordinates (relative to the pathway).- Specified by:
toAbsoluteCoordinate
in interfaceDrawable
- Specified by:
toAbsoluteCoordinate
in interfaceGraphLink.LinkableTo
- Specified by:
toAbsoluteCoordinate
in interfaceGroupable
- Parameters:
p
- the point2d.- Returns:
- the absolute point2d coordinate.
-
toRelativeCoordinate
public java.awt.geom.Point2D toRelativeCoordinate(java.awt.geom.Point2D p)Converts a point to shape coordinates (relative to the bounds of the shape).- Specified by:
toRelativeCoordinate
in interfaceDrawable
- Specified by:
toRelativeCoordinate
in interfaceGraphLink.LinkableTo
- Specified by:
toRelativeCoordinate
in interfaceGroupable
- Parameters:
p
- a point in absolute model coordinates- Returns:
- the same point relative to the bounding box of this pathway element: -1,-1 meaning the top-left corner, 1,1 meaning the bottom right corner, and 0,0 meaning the center.
-
copyValuesFrom
Copies values from the given source pathway element.NB:
- GroupRef is not copied, but can be set later if the parent group and all other pathway element members are copied.
- Parameters:
src
- the source pathway element.
-
getStaticPropertyKeys
Returns all static properties for this pathway object.- Overrides:
getStaticPropertyKeys
in classPathwayElement
- Returns:
- result the set of static property for this pathway object.
-
getStaticProperty
Returns static property value for given key.- Overrides:
getStaticProperty
in classPathwayElement
- Parameters:
key
- the key.- Returns:
- the static property value.
-
setStaticProperty
This works so that o.setNotes(x) is the equivalent of o.setProperty("Notes", x); Value may be null in some cases, e.g. graphRef- Overrides:
setStaticProperty
in classPathwayElement
- Parameters:
key
- the key.value
- the static property value.
-