Class LineElement.LinePoint

java.lang.Object
All Implemented Interfaces:
Drawable, GraphLink.LinkableFrom
Enclosing class:
LineElement

public class LineElement.LinePoint
extends LineElement.GenericPoint
implements GraphLink.LinkableFrom
This class stores information for a Point pathway element. This class is named LinePoint to avoid name conflict with awt.Point in downstream applications.
Author:
finterly
  • Field Details

    • x

      private double x
    • y

      private double y
    • elementRef

      private GraphLink.LinkableTo elementRef
    • relX

      private double relX
    • relY

      private double relY
  • Constructor Details

    • LinePoint

      public LinePoint​(double x, double y)
      Instantiates a Point pathway element, with no reference to another pathway element. Method linkTo(org.pathvisio.libgpml.model.GraphLink.LinkableTo) to set elementRef, relX, relY.
      Parameters:
      x - the x coordinate position of the point.
      y - the y coordinate position of the point.
  • Method Details

    • getObjectType

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

      public double getX()
      Returns x coordinate value.
      Returns:
      x the coordinate value for x.
    • setX

      public void setX​(double v)
      Sets x coordinate to given value.
      Parameters:
      v - the coordinate value to set for x.
    • getY

      public double getY()
      Returns y coordinate value.
      Returns:
      y the coordinate value for y.
    • setY

      public void setY​(double v)
      Sets y coordinate to given value.
      Parameters:
      v - the coordinate value to set for y.
    • getElementRef

      public GraphLink.LinkableTo getElementRef()
      Returns the pathway element to which this point refers to. In GPML, this is elementRef which refers to the elementId of a pathway element.
      Specified by:
      getElementRef in interface GraphLink.LinkableFrom
      Returns:
      elementRef the pathway element to which this point refers.
    • setElementRef

      private void setElementRef​(GraphLink.LinkableTo v)
      Sets the pathway element to which the point refers to. In GPML, this is elementRef which refers to the elementId of a pathway element. If a pathwayModel is set, this will automatically deregister the previously held elementRef and register the new elementRef as necessary
      Parameters:
      v - reference to set.
    • getRelX

      public double getRelX()
      Returns the relative x coordinate. When the given point is linked to a pathway element, relX and relY are the relative coordinates on the element, where 0,0 is at the center of the object and 1,1 at the bottom right corner of the object.
      Specified by:
      getRelX in interface GraphLink.LinkableFrom
      Returns:
      relX the relative x coordinate.
    • setRelX

      private void setRelX​(double v)
      Sets the relative x coordinate. When the given point is linked to a pathway element, relX and relY are the relative coordinates on the element, where 0,0 is at the center of the object and 1,1 at the bottom right corner of the object.
      Parameters:
      v - the relative x coordinate.
      Throws:
      java.lang.IllegalArgumentException - if relX is not between -1.0 and 1.0. t
    • getRelY

      public double getRelY()
      Returns the relative y coordinate. When the given point is linked to a pathway element, relX and relY are the relative coordinates on the element, where 0,0 is at the center of the object and 1,1 at the bottom right corner of the object.
      Specified by:
      getRelY in interface GraphLink.LinkableFrom
      Returns:
      relY the relative y coordinate.
    • setRelY

      private void setRelY​(double v)
      Sets the relative y coordinate. When the given point is linked to a pathway element, relX and relY are the relative coordinates on the element, where 0,0 is at the center of the object and 1,1 at the bottom right corner of the object.
      Parameters:
      v - the relative y coordinate.
    • isRelative

      public boolean isRelative()
      Checks if the position of this point should be stored as relative or absolute coordinates.
      Returns:
      true if the coordinates are relative, false otherwise.
    • getAbsolute

      private java.awt.geom.Point2D getAbsolute()
      Returns absolute coordinates based on elementRef.
      Returns:
    • toPoint2D

      public java.awt.geom.Point2D toPoint2D()
      Returns this line point as a Point2D.
      Returns:
      this point as point2d.
    • toAbsoluteCoordinate

      public java.awt.geom.Point2D toAbsoluteCoordinate​(java.awt.geom.Point2D p)
      Returns the absolute coordinate as a Point2D.
      Specified by:
      toAbsoluteCoordinate in interface Drawable
      Parameters:
      p - the point2d.
      Returns:
      the absolute coordinate as point2d.
    • toRelativeCoordinate

      public java.awt.geom.Point2D toRelativeCoordinate​(java.awt.geom.Point2D p)
      Returns the relative coordinate as a Point2D.
      Specified by:
      toRelativeCoordinate in interface Drawable
      Parameters:
      p - a point in absolute model coordinates
      Returns:
      the relative coordinate as point2d.
    • linkTo

      public void linkTo​(GraphLink.LinkableTo elementRef)
      Links this line point to the given object. Updates xy and relXY coordinates.
      Parameters:
      elementRef - the linkableTo pathway element or anchor to link to.
    • linkTo

      public void linkTo​(GraphLink.LinkableTo elementRef, double relX, double relY)
      Links this line point to the given object. Updates xy and relXY coordinates.
      Specified by:
      linkTo in interface GraphLink.LinkableFrom
      Parameters:
      elementRef - the linkableTo pathway element or anchor to link to.
      relX - the relative x coordinate to set.
      relY - the relative y coordinate to set.
    • unlink

      public void unlink()
      Unlinks this LinePoint from its LinkableTo elementRef. NB: This may be called any number of times when this point is already unlinked
      Specified by:
      unlink in interface GraphLink.LinkableFrom
    • setRelativePosition

      public void setRelativePosition​(double relX, double relY)
      Sets X, Y, relX and relY for this point. Updates x and y absolute coordinates for this point which is now relative. When the given point is linked to a pathway element, relX and relY are the relative coordinates on the element, where 0,0 is at the center of the object and 1,1 at the bottom right corner of the object.
      Parameters:
      relX - the relative x coordinate.
      relY - the relative y coordinate.
    • moveBy

      public void moveBy​(double deltaX, double deltaY)
      Moves x and y coordinates for this line point by the given values.
      Parameters:
      deltaX - the value to move x coordinate by.
      deltaY - the value to move y coordinate by.
    • moveTo

      public void moveTo​(double vx, double vy)
      Moves x and y coordinates for this line point to given values.
      Parameters:
      vx - the value to move x coordinate to.
      vy - the value to move y coordinate to.
    • moveTo

      public void moveTo​(LineElement.LinePoint linePoint)
      Moves the xy and relXY coordinates for this line point to the coordinate values of the given line point.
      Parameters:
      linePoint - the linePoint to move to.
    • refeeChanged

      public void refeeChanged()
      Called whenever the object being referred to has changed.
      Specified by:
      refeeChanged in interface GraphLink.LinkableFrom
    • getZOrder

      public int getZOrder()
      Returns the z-order of this pathway element. NB: LinePoint z-order is always z-order of parent line +1. This is because z-order is not written out to the gpml file.
      Specified by:
      getZOrder in interface Drawable
      Returns:
      zOrder the order of this pathway element.
    • setZOrder

      public void setZOrder​(int v)
      Do nothing. LinePoint z-order is always z-order of parent line +1. This is because z-order is not written out to the gpml file.
      Specified by:
      setZOrder in interface Drawable
      Parameters:
      v - the input
    • terminate

      protected void terminate()
      Terminates this line point and removes all links and references.
      Overrides:
      terminate in class PathwayObject