Package org.pathvisio.libgpml.model
Class LineElement.LinePoint
java.lang.Object
org.pathvisio.libgpml.model.PathwayObject
org.pathvisio.libgpml.model.LineElement.GenericPoint
org.pathvisio.libgpml.model.LineElement.LinePoint
- 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 Summary
Fields Modifier and Type Field Description private GraphLink.LinkableTo
elementRef
private double
relX
private double
relY
private double
x
private double
y
Fields inherited from class org.pathvisio.libgpml.model.PathwayObject
noFire, pathwayModel
-
Constructor Summary
Constructors Constructor Description LinePoint(double x, double y)
Instantiates a Point pathway element, with no reference to another pathway element. -
Method Summary
Modifier and Type Method Description private java.awt.geom.Point2D
getAbsolute()
Returns absolute coordinates based on elementRef.GraphLink.LinkableTo
getElementRef()
Returns the pathway element to which this point refers to.ObjectType
getObjectType()
Returns the object type of this pathway element.double
getRelX()
Returns the relative x coordinate.double
getRelY()
Returns the relative y coordinate.double
getX()
Returns x coordinate value.double
getY()
Returns y coordinate value.int
getZOrder()
Returns the z-order of this pathway element.boolean
isRelative()
Checks if the position of this point should be stored as relative or absolute coordinates.void
linkTo(GraphLink.LinkableTo elementRef)
Links this line point to the given object.void
linkTo(GraphLink.LinkableTo elementRef, double relX, double relY)
Links this line point to the given object.void
moveBy(double deltaX, double deltaY)
Moves x and y coordinates for this line point by the given values.void
moveTo(double vx, double vy)
Moves x and y coordinates for this line point to given values.void
moveTo(LineElement.LinePoint linePoint)
Moves the xy and relXY coordinates for this line point to the coordinate values of the given line point.void
refeeChanged()
Called whenever the object being referred to has changed.private void
setElementRef(GraphLink.LinkableTo v)
Sets the pathway element to which the point refers to.void
setRelativePosition(double relX, double relY)
Sets X, Y, relX and relY for this point.private void
setRelX(double v)
Sets the relative x coordinate.private void
setRelY(double v)
Sets the relative y coordinate.void
setX(double v)
Sets x coordinate to given value.void
setY(double v)
Sets y coordinate to given value.void
setZOrder(int v)
Do nothing.protected void
terminate()
Terminates this line point and removes all links and references.java.awt.geom.Point2D
toAbsoluteCoordinate(java.awt.geom.Point2D p)
Returns the absolute coordinate as aPoint2D
.java.awt.geom.Point2D
toPoint2D()
Returns this line point as aPoint2D
.java.awt.geom.Point2D
toRelativeCoordinate(java.awt.geom.Point2D p)
Returns the relative coordinate as aPoint2D
.void
unlink()
Unlinks this LinePoint from its LinkableTo elementRef.Methods inherited from class org.pathvisio.libgpml.model.LineElement.GenericPoint
getLineElement, setPathwayModelTo
Methods inherited from class org.pathvisio.libgpml.model.PathwayObject
addListener, dontFireEvents, fireObjectModifiedEvent, getElementId, getListeners, getPathwayModel, getPropertyEx, getPropertyKeys, getStaticProperty, getStaticPropertyKeys, hasPathwayModel, removeListener, setElementId, setGeneratedElementId, setPathwayModel, setPropertyEx, setStaticProperty, 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
getPathwayModel
-
Field Details
-
x
private double x -
y
private double y -
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. MethodlinkTo(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
Returns the object type of this pathway element.- Specified by:
getObjectType
in interfaceDrawable
- Specified by:
getObjectType
in classPathwayObject
- 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
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 interfaceGraphLink.LinkableFrom
- Returns:
- elementRef the pathway element to which this point refers.
-
setElementRef
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 interfaceGraphLink.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 interfaceGraphLink.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 aPoint2D
.- Returns:
- this point as point2d.
-
toAbsoluteCoordinate
public java.awt.geom.Point2D toAbsoluteCoordinate(java.awt.geom.Point2D p)Returns the absolute coordinate as aPoint2D
.- Specified by:
toAbsoluteCoordinate
in interfaceDrawable
- 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 aPoint2D
.- Specified by:
toRelativeCoordinate
in interfaceDrawable
- Parameters:
p
- a point in absolute model coordinates- Returns:
- the relative coordinate as point2d.
-
linkTo
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
Links this line point to the given object. Updates xy and relXY coordinates.- Specified by:
linkTo
in interfaceGraphLink.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 interfaceGraphLink.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
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 interfaceGraphLink.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. -
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. -
terminate
protected void terminate()Terminates this line point and removes all links and references.- Overrides:
terminate
in classPathwayObject
-