Search this API

y.view
Class Port

java.lang.Object
  extended by y.view.Port
Direct Known Subclasses:
InterfacePort

public class Port
extends java.lang.Object

Defines a logical end point of an edge relative to the center location of a node. Port locations are specified relative to the center location of the corresponding node.

A port can be thought of as the first or last control point of an edge realizer.

 

Field Summary
protected  EdgeRealizer realizer
          The EdgeRealizer associated to this Port instance.
protected  double xoff
          The port's offset in x-direction.
protected  double yoff
          The port's offset in y-direction.
 
Constructor Summary
Port()
          Constructs a new Port with default offset 0.0.
Port(double xoff, double yoff)
          Constructs a new Port with offset location (xoff,yoff).
Port(Port port)
          Constructs a new Port as a copy of a given port.
 
Method Summary
 void calcUnionRect(java.awt.geom.Rectangle2D rect, NodeRealizer r)
          Enlarges the given rectangle such that it will contain the complete visual representation of this port.
 boolean contains(double x, double y)
          Returns true if the given coordinates lie within the visual shape of this port.
 Port createCopy()
          Creates an unbound copy of this port.
 Port createRotatedPort()
          Creates an unbound copy of this port that is rotated by 90 degrees.
 boolean findIntersection(NodeRealizer r, double ix, double iy, double ox, double oy, java.awt.geom.Point2D result)
          Returns true iff the coordinates (ix,iy) lies within the visual shape of this port and the coordinates (ox,oy> lies outside of that shape.
 double getOffsetX()
          Returns the center x-coordinate of this port relative to the center of the node it is connected to.
 double getOffsetY()
          Returns the center y-coordinate of this port relative to the center of the node it is connected to.
 EdgeRealizer getOwner()
          Returns the edge realizer this port belongs to.
 double getX(NodeRealizer nr)
          Returns the absolute center x-coordinate of this port.
 double getY(NodeRealizer nr)
          Returns the absolute center y-coordinate of this port.
 void paint(java.awt.Graphics2D gfx, NodeRealizer r)
          Paints a little black rectangle if the edge realizer this port belongs to is selected.
 void read(java.io.ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
protected  void setDirty()
          Marks this port and it's associated edge realizer as dirty.
 void setOffsets(double xoff, double yoff)
          Sets the center coordinates of this port relative to the center of the node is connected to.
 void setOffsetX(double xoff)
          Sets the center x-coordinate of this port relative to the center of the node is connected to.
 void setOffsetY(double yoff)
          Sets the center x-coordinate of this port relative to the center of the node is connected to.
 java.lang.String toString()
          Returns a string representation of this port.
 void write(java.io.ObjectOutputStream out)
          Deprecated. Use the GraphML format instead.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xoff

protected double xoff
The port's offset in x-direction.


yoff

protected double yoff
The port's offset in y-direction.


realizer

protected EdgeRealizer realizer
The EdgeRealizer associated to this Port instance.

Constructor Detail

Port

public Port()
Constructs a new Port with default offset 0.0.


Port

public Port(double xoff,
            double yoff)
Constructs a new Port with offset location (xoff,yoff).


Port

public Port(Port port)
Constructs a new Port as a copy of a given port.

Method Detail

createCopy

public Port createCopy()
Creates an unbound copy of this port.


createRotatedPort

public Port createRotatedPort()
Creates an unbound copy of this port that is rotated by 90 degrees.


getOwner

public EdgeRealizer getOwner()
Returns the edge realizer this port belongs to.


findIntersection

public boolean findIntersection(NodeRealizer r,
                                double ix,
                                double iy,
                                double ox,
                                double oy,
                                java.awt.geom.Point2D result)
Returns true iff the coordinates (ix,iy) lies within the visual shape of this port and the coordinates (ox,oy> lies outside of that shape. In that case the intersection point of the line (ix,iy) - (ox,oy) with that shape will be stored in the given point.


paint

public void paint(java.awt.Graphics2D gfx,
                  NodeRealizer r)
Paints a little black rectangle if the edge realizer this port belongs to is selected. Otherwise nothing will be painted.


setDirty

protected void setDirty()
Marks this port and it's associated edge realizer as dirty. This method should be called whenever the port changes its bounds or location in order to ensure proper repaint behavior.


contains

public boolean contains(double x,
                        double y)
Returns true if the given coordinates lie within the visual shape of this port.


calcUnionRect

public void calcUnionRect(java.awt.geom.Rectangle2D rect,
                          NodeRealizer r)
Enlarges the given rectangle such that it will contain the complete visual representation of this port.

Parameters:
r - The node realizer this port is connected to.

getOffsetX

public double getOffsetX()
Returns the center x-coordinate of this port relative to the center of the node it is connected to.


getOffsetY

public double getOffsetY()
Returns the center y-coordinate of this port relative to the center of the node it is connected to.


getX

public double getX(NodeRealizer nr)
Returns the absolute center x-coordinate of this port. The given node realizer is used as a reference point to translate relative to absolute coordinates.


getY

public double getY(NodeRealizer nr)
Returns the absolute center y-coordinate of this port. The given node realizer is used as a reference point to translate relative to absolute coordinates.


setOffsetX

public void setOffsetX(double xoff)
Sets the center x-coordinate of this port relative to the center of the node is connected to.


setOffsetY

public void setOffsetY(double yoff)
Sets the center x-coordinate of this port relative to the center of the node is connected to.


setOffsets

public void setOffsets(double xoff,
                       double yoff)
Sets the center coordinates of this port relative to the center of the node is connected to.


write

public void write(java.io.ObjectOutputStream out)
           throws java.io.IOException
Deprecated. Use the GraphML format instead.

Writes out this port in a serialized form.

Throws:
java.io.IOException

read

public void read(java.io.ObjectInputStream in)
          throws java.io.IOException,
                 java.lang.ClassNotFoundException
Deprecated. Use the GraphML format instead.

Reads in a serialized form of a port that was previously written out by the method write(ObjectOutputStream out).

Throws:
java.io.IOException
java.lang.ClassNotFoundException

toString

public java.lang.String toString()
Returns a string representation of this port.

Overrides:
toString in class java.lang.Object

© Copyright 2000-2021,
yWorks GmbH.
All rights reserved.