y.view
Class Port

java.lang.Object
  |
  +--y.view.Port
Direct Known Subclasses:
InterfacePort

public class Port
extends 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
           
protected  double xoff
           
protected  double yoff
           
 
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(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, Point2D result)
          Returns true iff the coord (ix,iy) lies within the visual shape of this port and the coord (ox,oy> lies outside of that shape.
 double getOffsetX()
          Returns the center x-coord of this port relative to the center of the node it is connected to.
 double getOffsetY()
          Returns the center y-coord 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-coord of this port.
 double getY(NodeRealizer nr)
          Returns the absolute center y-coord of this port.
 void paint(Graphics2D gfx, NodeRealizer r)
          Paints a little black rectangle if the edge realizer this port belongs to is selected.
 void read(ObjectInputStream in)
          Reads in a serialized form of a port that was previously written out by the method Port.write(ObjectOutputStream out).
protected  void setDirty()
          Marks this port and it's associated edge realizer as dirty.
 void setOffsets(double xoff, double yoff)
          Sets the center coords of this port relative to the center of the node is connected to.
 void setOffsetX(double xoff)
          Sets the center x-coord of this port relative to the center of the node is connected to.
 void setOffsetY(double yoff)
          Sets the center x-coord of this port relative to the center of the node is connected to.
 String toString()
          Returns a string representation of this port.
 void write(ObjectOutputStream out)
          Writes out this port in a serialized form.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

xoff

protected double xoff

yoff

protected double yoff

realizer

protected EdgeRealizer realizer
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,
                                Point2D result)
Returns true iff the coord (ix,iy) lies within the visual shape of this port and the coord (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(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 behaviour.


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(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-coord of this port relative to the center of the node it is connected to.


getOffsetY

public double getOffsetY()
Returns the center y-coord 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-coord of this port. The given node realizer is used as a reference point to translate relative to absolute coords.


getY

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


setOffsetX

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


setOffsetY

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


setOffsets

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


write

public void write(ObjectOutputStream out)
           throws IOException
Writes out this port in a serialized form.

IOException

read

public void read(ObjectInputStream in)
          throws IOException,
                 ClassNotFoundException
Reads in a serialized form of a port that was previously written out by the method Port.write(ObjectOutputStream out).

IOException
ClassNotFoundException

toString

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

Overrides:
toString in class Object

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

2003