Class Group

All Implemented Interfaces:
java.lang.Cloneable, Drawable, GraphLink.LinkableTo, Groupable, Referenceable, Referenceable.Annotatable, Referenceable.Citable, Referenceable.Evidenceable, Xrefable

public class Group
extends ShapedElement
implements Xrefable
This class stores all information relevant to a Group pathway element.
Author:
finterly
  • Field Details

    • type

      private GroupType type
    • textLabel

      private java.lang.String textLabel
    • xref

      private org.bridgedb.Xref xref
    • pathwayElements

      private java.util.List<Groupable> pathwayElements
    • DEFAULT_M_MARGIN

      public static final double DEFAULT_M_MARGIN
      Default margins for group bounding-box in GPML2013a. Makes the bounds slightly larger than the summed bounds of the containing elements.
      See Also:
      Constant Field Values
    • COMPLEX_M_MARGIN

      public static final double COMPLEX_M_MARGIN
      See Also:
      Constant Field Values
  • Constructor Details

    • Group

      public Group​(GroupType type, org.bridgedb.Xref xref)
      Instantiates a Group given all required parameters and xref.
      Parameters:
      type - the type of the group.
      xref - the group Xref.
    • Group

      public Group​(GroupType type)
      Instantiates a Group given all required parameters.
  • Method Details

    • getObjectType

      public ObjectType getObjectType()
      Returns the object type of this pathway element.
      Specified by:
      getObjectType in interface Drawable
      Specified by:
      getObjectType in interface GraphLink.LinkableTo
      Specified by:
      getObjectType in class PathwayObject
      Returns:
      the object type.
    • getPathwayElements

      public java.util.List<Groupable> getPathwayElements()
      Returns the list of pathway element members of the group.
      Returns:
      pathwayElements the list of pathway elements belonging to the group.
    • hasPathwayElement

      public boolean hasPathwayElement​(Groupable pathwayElement)
      Checks whether pathwayElements has the given pathwayElement.
      Parameters:
      pathwayElement - the pathway element to look for.
      Returns:
      true if has pathwayElement, false otherwise.
    • addPathwayElement

      public void addPathwayElement​(Groupable pathwayElement)
      Adds the given pathway element to pathwayElements list of this group. Checks if pathway element is valid. Sets groupRef of pathway element to this group if necessary. NB: States are not added to group pathway elements lists. States appear outside of groups in the view.
      Parameters:
      pathwayElement - the given pathwayElement to add.
    • updateDimensions

      public void updateDimensions()
      Updates Group centerX, centerY, width, and height.

      NB:

      1. Generally called after addPathwayElement(org.pathvisio.libgpml.model.Groupable) or setGroupRefTo Methods, when pathway elements are added to group.
      2. Called after reading methods in GPMLFormatAbstract.updateGroups(org.pathvisio.libgpml.model.PathwayModel).
      3. Also called in copy and paste methods.
    • removePathwayElement

      public void removePathwayElement​(Groupable pathwayElement)
      Removes the given pathway element from pathwayElements list of the group. Checks if pathway element is valid. Unsets groupRef of pathway element from this group if necessary.
      Parameters:
      pathwayElement - the given pathwayElement to remove.
    • addPathwayElements

      public void addPathwayElements​(java.util.List<? extends Groupable> pathwayElements)
      Adds the given list of pathway elements to pathwayElements list of this group.
      Parameters:
      pathwayElements - the given list of pathwayElement to add.
    • removePathwayElements

      public void removePathwayElements()
      Removes all pathway elements from the pathwayElements list.
    • getType

      public GroupType getType()
      Returns GroupType. GroupType is GROUP by default.
      Returns:
      type the type of group, e.g. complex.
    • setType

      public void setType​(GroupType v)
      Sets GroupType to the given groupType.
      Parameters:
      v - the type to set for this group, e.g. complex.
    • getTextLabel

      public java.lang.String getTextLabel()
      Returns the text of of this group.
      Specified by:
      getTextLabel in class ShapedElement
      Returns:
      textLabel the text of of this group.
    • setTextLabel

      public void setTextLabel​(java.lang.String v)
      Sets the text of this shaped pathway element.
      Specified by:
      setTextLabel in class ShapedElement
      Parameters:
      v - the text to set.
    • getXref

      public org.bridgedb.Xref getXref()
      Returns the Xref for the group.
      Specified by:
      getXref in interface Xrefable
      Returns:
      xref the xref of this group
    • setXref

      public void setXref​(org.bridgedb.Xref v)
      Sets the Xref for this group.
      Specified by:
      setXref in interface Xrefable
      Parameters:
      v - the xref to set for this group.
    • addAlias

      public DataNode addAlias​(java.lang.String textLabel)
      Creates and returns an Alias data node for this group.
    • terminate

      protected void terminate()
      Terminates this group and removes all references and links. NB: Must LineElement.LinePoint.unlink() before removing pathway element members, so that line points stays in the same position when the group disappears. If you remove pathway elements first, the group bounds changes before you can unlink(), effecting the position of line points.
      Overrides:
      terminate in class ShapedElement
    • setRotation

      public void setRotation​(java.lang.Double v)
      Rotation is not allowed for Groups and will always be set to 0 (default).
      Overrides:
      setRotation in class ShapedElement
      Parameters:
      v -
    • getMargin

      public double getMargin()
      Returns margin for group bounding-box around contained elements depending on group type, as specified in GPML2013a.
      Returns:
      the margin for group.
    • getRotatedBounds

      public java.awt.geom.Rectangle2D getRotatedBounds()
      Iterates over all group elements to find the TOTAL rectangular bounds, taking into account rotation of the nested elements. NB: For now, groups should never be rotated.
      Specified by:
      getRotatedBounds in interface Groupable
      Overrides:
      getRotatedBounds in class ShapedElement
      Returns:
      the rectangular bounds for this group with rotation taken into account.
    • getBounds

      public java.awt.geom.Rectangle2D getBounds()
      Iterates over all group elements to find the TOTAL rectangular bounds.
      Specified by:
      getBounds in interface Groupable
      Overrides:
      getBounds in class ShapedElement
      Returns:
      the rectangular bounds for this group.
    • getMinBounds

      public java.awt.geom.Rectangle2D getMinBounds​(boolean rotated)
      Iterates over all group elements to find the MINIMAL total rectangular bounds.
      Parameters:
      rotated - if true, take into account rotation.
      Returns:
      the rectangular bounds for this group.
    • copyValuesFrom

      public void copyValuesFrom​(Group src)
      Copies values from the given source pathway element.
      Parameters:
      src - the source pathway element.
    • copy

      public CopyElement copy()
      Copies this pathway element.
      Specified by:
      copy in class PathwayElement
      Returns:
      the copyElement for the new pathway element and this source pathway element.
    • getStaticPropertyKeys

      public java.util.Set<StaticProperty> getStaticPropertyKeys()
      Returns all static properties for this pathway object.
      Overrides:
      getStaticPropertyKeys in class ShapedElement
      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 ShapedElement
      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 ShapedElement
      Parameters:
      key - the key.
      value - the static property value.
    • toString

      public java.lang.String toString()
      Writes this group out as a string.
      Overrides:
      toString in class java.lang.Object
      Returns:
      the string representing this group.