Class ShapedElement

java.lang.Object
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
  • Field Details

    • groupRef

      private Group 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

      private HAlignType hAlign
    • vAlign

      private VAlignType vAlign
    • borderColor

      private java.awt.Color borderColor
    • borderStyle

      private LineStyleType borderStyle
    • borderWidth

      private double borderWidth
    • fillColor

      private java.awt.Color fillColor
    • shapeType

      private IShape 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 by setGroupRefTo(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 for DataNode, DataNode.State and Label; and optional for Shape and Group.
      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

      public Group 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 interface Groupable
      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 interface Groupable
      Returns:
      true if and only if the group of this pathway element is effective.
    • setGroupRefTo

      public void setGroupRefTo​(Group v)
      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 interface Groupable
      Parameters:
      v - the new parent group to set.
    • setGroupRef

      private void setGroupRef​(Group v)
      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 interface Groupable
    • getCenterX

      public double getCenterX()
      Returns the center x coordinate for this shaped pathway element.
      Specified by:
      getCenterX in interface Groupable
      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 interface Groupable
      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 interface Groupable
      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 interface Groupable
      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.
      Specified by:
      getWidth in interface Groupable
      Returns:
      width 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.
      Specified by:
      getHeight in interface Groupable
      Returns:
      height 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

      public HAlignType getHAlign()
      Returns the horizontal alignment of displayed text, e.g., Left, Center, Right.
      Returns:
      hAlign the horizontal alignment value of displayed text.
    • setHAlign

      public void setHAlign​(HAlignType v)
      Sets the horizontal alignment of displayed text, e.g., Left, Center, Right.
      Parameters:
      v - the horizontal alignment value of displayed text.
    • getVAlign

      public VAlignType getVAlign()
      Returns the vertical alignment of displayed text, e.g., Top, Middle, Bottom.
      Returns:
      vAlign the vertical alignment value of displayed text.
    • setVAlign

      public void setVAlign​(VAlignType v)
      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

      public LineStyleType getBorderStyle()
      Returns the visual appearance of a border, e.g. Solid or Broken.
      Returns:
      borderStyle the style of a border.
    • setBorderStyle

      public void setBorderStyle​(LineStyleType v)
      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

      public IShape 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

      public void setShapeType​(IShape v)
      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.
      Specified by:
      getZOrder in interface Drawable
      Returns:
      zOrder the order of this pathway element.
    • setZOrder

      public void setZOrder​(int v)
      Sets the z-order of this pathway element.
      Specified by:
      setZOrder in interface Drawable
      Parameters:
      v - the 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

      public java.util.Set<GraphLink.LinkableFrom> getLinkableFroms()
      Returns GraphLink.LinkableFrom pathway elements, at this time that only goes for LineElement.LinePoint, for this GraphLink.LinkableTo pathway element.
      Specified by:
      getLinkableFroms in interface GraphLink.LinkableTo
      Returns:
      the LinkableFrom line points.
    • unsetAllLinkableFroms

      public void unsetAllLinkableFroms()
      Removes links from all GraphLink.LinkableFrom line points to this GraphLink.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 class PathwayElement
    • getRotatedBounds

      public java.awt.geom.Rectangle2D getRotatedBounds()
      Returns the rectangular bounds of this shaped pathway element after rotation is applied.
      Specified by:
      getRotatedBounds in interface Groupable
      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.
      Specified by:
      getBounds in interface Groupable
      Returns:
      the rectangular bounds for this shaped pathway element.
    • getLeft

      public double getLeft()
      Returns the left x coordinate of the bounding box around (start, end) this shaped pathway element.
      Specified by:
      getLeft in interface Groupable
      Returns:
      left the left x coordinate.
    • 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.
      Specified by:
      setLeft in interface Groupable
      Parameters:
      v - the left coordinate.
    • getTop

      public double getTop()
      Returns the top y coordinate of the bounding box around (start, end) this shaped pathway element.
      Specified by:
      getTop in interface Groupable
      Returns:
      the top y coordinate.
    • 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.
      Specified by:
      setTop in interface Groupable
      Parameters:
      v - the y top coordinate.
    • 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 interface Drawable
      Specified by:
      toAbsoluteCoordinate in interface GraphLink.LinkableTo
      Specified by:
      toAbsoluteCoordinate in interface Groupable
      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 interface Drawable
      Specified by:
      toRelativeCoordinate in interface GraphLink.LinkableTo
      Specified by:
      toRelativeCoordinate in interface Groupable
      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

      public void copyValuesFrom​(ShapedElement src)
      Copies values from the given source pathway element.

      NB:

      1. 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

      public java.util.Set<StaticProperty> getStaticPropertyKeys()
      Returns all static properties for this pathway object.
      Overrides:
      getStaticPropertyKeys in class PathwayElement
      Returns:
      result the set of static property for this pathway object.
    • getStaticProperty

      public java.lang.Object getStaticProperty​(StaticProperty key)
      Returns static property value for given key.
      Overrides:
      getStaticProperty in class PathwayElement
      Parameters:
      key - the key.
      Returns:
      the static property value.
    • setStaticProperty

      public 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. graphRef
      Overrides:
      setStaticProperty in class PathwayElement
      Parameters:
      key - the key.
      value - the static property value.