| 
 | Search this API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.NodePort
public class NodePort
Graphical representation of a port object (a possible connection point for an edge) associated to a node.
The class provides methods to bind edges to ports, determine connected edges, paint ports, determine port locations, perform hit tests, and store business objects for ports.
 Similar to GenericNodeRealizer and
 GenericEdgeRealizer, this class uses the concept of a
 configuration that consists of multiple pluggable instances of specialized
 interfaces to allow for easy customization of its visual appearance.
 
This class knows multiple nested interfaces that can be used as callback routines to customize
NodePort.Painter)NodePort.ContainsTest and
     NodePort.IntersectionTest)NodePort.UnionRectCalculator and
     NodePort.BoundsProvider)NodePort.UserDataHandler)NodePort.SelectionChangeHandler)
 This class provides access to a factory,
 that is used by the implementation to manage different port style configurations.
 
Programmers have to use that factory to register different style configurations using their own implementations of the interfaces described above.
The following piece of code demonstrates how to correctly initialize a custom node port.
 // Get the static default factory instance
 NodePort.Factory factory = NodePort.getFactory();
 // Retrieve a map that holds the default NodePort configuration.
 // The implementations contained therein can be replaced one by one in order
 // to create custom configurations...
 Map implementationsMap = factory.createDefaultConfigurationMap();
 // create and register customizations...
 // e.g. create a custom painter
 MyCustomPainter painter = new MyCustomPainter();
 // put it into the map using the interface class as the key
 implementationsMap.put(NodePort.Painter.class, painter);
 // add the configuration using an arbitrary String identifier to the factory
 factory.addConfiguration("type1", implementationsMap);
 // now create an instance that uses our customizations
 NodePort port = new NodePort();
 // initialize the instance using the previously registered configuration
 port.setConfiguration("type1");
 
 
 Note: Serialization/deserialization of node ports is only
 supported in the GraphML format.
 
| Nested Class Summary | |
|---|---|
| static interface | NodePort.BoundsProviderThis interface is used by NodePortto delegate the work of
 thegetBounds()method to. | 
| static interface | NodePort.ContainsTestThis interface is used by NodePortto delegate the work of
 thecontains(double, double)method to. | 
| static class | NodePort.FactoryThis class is used to manage the different configurations for NodePortinstances. | 
| static interface | NodePort.IntersectionTestThis interface is used by NodePortto delegate the work of
 thefindIntersection(double, double, double, double, java.awt.geom.Point2D)method to. | 
| static interface | NodePort.PainterThis interface is used by NodePortto delegate the work of thepaint(java.awt.Graphics2D)method to. | 
| static interface | NodePort.SelectionChangeHandlerThis interface is used by NodePortto notify interested
 parties of selection state changes. | 
| static interface | NodePort.UnionRectCalculatorThis interface is used by NodePortto delegate the work of
 thecalcUnionRect(java.awt.geom.Rectangle2D)method
 to. | 
| static interface | NodePort.UserDataHandlerThis interface is used by NodePortto delegate the copying
 of any user-defined data to. | 
| Constructor Summary | |
|---|---|
| NodePort()Initializes a new NodePortinstance. | |
| NodePort(NodePort prototype)Initializes a new NodePortinstance with the values from
 the specified template instance. | |
| Method Summary | |
|---|---|
| protected  void | bindRealizer(NodeRealizer nr)Associates this port instance to the specified node realizer. | 
|  void | bindSourcePort(Edge edge)Registers this port instance as connection point at source side for the specified edge. | 
|  void | bindSourcePort(EdgeRealizer er)Registers this port instance as connection point at source side for the specified edge. | 
| static void | bindSourcePort(NodePort port,
               Edge edge)Registers the specified port as connection point at source side for the specified edge. | 
| static void | bindSourcePort(NodePort port,
               EdgeRealizer er)Registers the specified port as connection point at source side for the specified edge. | 
|  void | bindTargetPort(Edge edge)Registers this port instance as connection point at target side for the specified edge. | 
|  void | bindTargetPort(EdgeRealizer er)Registers this port instance as connection point at target side for the specified edge. | 
| static void | bindTargetPort(NodePort port,
               Edge edge)Registers the specified port as connection point at target side for the specified edge. | 
| static void | bindTargetPort(NodePort port,
               EdgeRealizer er)Registers the specified port as connection point at target side for the specified edge. | 
|  void | calcUnionRect(java.awt.geom.Rectangle2D rectangle)Calculates the rectangular union of the specified rectangle and this port's bounds. | 
|  boolean | contains(double x,
         double y)Returns trueif this port's visual representation
 contains the specified point andfalseotherwise. | 
|  NodePort | createCopy()Creates a copy of this port instance that is not associated to any node realizer. | 
|  NodePort | createCopy(NodePort prototype)Creates a copy of the specified template instance that is not associated to any node realizer. | 
|  EdgeCursor | edges()Returns a cursor over all edges that are bound to this port instance. | 
|  boolean | findIntersection(double ix,
                 double iy,
                 double ox,
                 double oy,
                 java.awt.geom.Point2D result)Returns trueif the pointi=(ix,iy)lies inside
 and the pointo=(ox,oy)lies outside this port's visual
 representation andfalse<otherwise. | 
|  YRectangle | getBounds()Returns the bounds of this port's visual representation in absolute world (graph) coordinates. | 
|  java.lang.String | getConfiguration()Returns the name of the current configuration of this port instance. | 
| static NodePort.Factory | getFactory()Returns the factory instance that will be used to read and write customization configurations. | 
|  YPoint | getLocation()Returns the position of this port instance in absolute world coordinates. | 
|  PortLocationModelParameter | getModelParameter()Returns the model parameter that determines the position of this port instance. | 
|  NodeRealizer | getRealizer()Returns the node realizer instance associated to this port instance. | 
| static NodePort | getSourcePort(Edge edge)Returns the port instance that is registered as the specified edge's source port. | 
| static NodePort | getSourcePort(EdgeRealizer er)Returns the port instance that is registered as the specified edge's source port. | 
| static NodePort | getTargetPort(Edge edge)Returns the port instance that is registered as the specified edge's target port. | 
| static NodePort | getTargetPort(EdgeRealizer er)Returns the port instance that is registered as the specified edge's target port. | 
|  java.lang.Object | getUserData()Returns the user or business data associated to this port instance. | 
|  EdgeCursor | inEdges()Returns a cursor over all incoming edges that are bound to this port. | 
|  boolean | isSelected()Returns the selection state of this port instance. | 
|  EdgeCursor | outEdges()Returns a cursor over all outgoing edges that are bound to this port. | 
|  void | paint(java.awt.Graphics2D g)Paints this port instance. | 
| static void | remove(NodePort port)Removes the specified node port from its owner realizer as well as all labels that are associated to the port and all edges connecting to it. | 
|  void | setConfiguration(java.lang.String id)Configures this instance to use the implementations provided by the factoryunder the given configuration name. | 
|  void | setModelParameter(PortLocationModelParameter parameter)Specifies the model parameter that determines the position of this port instance. | 
|  void | setSelected(boolean selected)Specifies the selection state of this port instance. | 
|  void | setUserData(java.lang.Object userData)Specifies the user or business data for this port instance. | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Constructor Detail | 
|---|
public NodePort()
NodePort instance.
public NodePort(NodePort prototype)
NodePort instance with the values from
 the specified template instance.
prototype - the template instance for the new instance's data.| Method Detail | 
|---|
public NodePort createCopy()
createCopy(this).
createCopy(NodePort)public NodePort createCopy(NodePort prototype)
prototype - the template instance for the new instance's data.
protected void bindRealizer(NodeRealizer nr)
nr - the node realizer to which this port instance has to be bound.public NodeRealizer getRealizer()
null if this port is not associated to any realizer instance.public void bindSourcePort(Edge edge)
bindSourcePort(y.view.EdgeRealizer).
edge - the edge to which the port is bound. Must belong to a
 Graph2D instance.
java.lang.NullPointerException - if the specified edge does not belong to a
 graph.bindSourcePort(NodePort, EdgeRealizer)public void bindSourcePort(EdgeRealizer er)
NodePort.bindSourcePort(this, er).
er - the visual representation of the edge to which the port is bound.bindSourcePort(NodePort, EdgeRealizer)
public static void bindSourcePort(NodePort port,
                                  Edge edge)
port - the port instance to bind as source connection point. May be
 null.edge - the edge to which the port is bound. Must belong to a
 Graph2D instance.
java.lang.IllegalArgumentException - if the specified port either has no
 associated NodeRealizer or does not belong to the port
 collection of its associated NodeRealizer.
java.lang.NullPointerException - if the specified edge does not belong to a
 graph.getSourcePort(EdgeRealizer)
public static void bindSourcePort(NodePort port,
                                  EdgeRealizer er)
port - the port instance to bind as source connection point. May be
 null.er - the visual representation of the edge to which the port is bound.
java.lang.IllegalArgumentException - if the specified port either has no
 associated NodeRealizer or does not belong to the port
 collection of its associated NodeRealizer.getSourcePort(EdgeRealizer)public static NodePort getSourcePort(Edge edge)
edge - the edge to which the port is bound. Must belong to a
 Graph2D instance.
null if the edge is not bound to a source port.
java.lang.NullPointerException - if the specified edge does not belong to a
 graph.bindSourcePort(NodePort, EdgeRealizer)public static NodePort getSourcePort(EdgeRealizer er)
er - the visual representation of the edge to which the port is bound.
null if the edge is not bound to a source port.bindSourcePort(NodePort, EdgeRealizer)public void bindTargetPort(Edge edge)
bindTargetPort(y.view.EdgeRealizer).
edge - the edge to which the port is bound. Must belong to a
 Graph2D instance.
java.lang.NullPointerException - if the specified edge does not belong to a
 graph.bindTargetPort(NodePort, EdgeRealizer)public void bindTargetPort(EdgeRealizer er)
NodePort.bindTargetPort(this, er).
er - the visual representation of the edge to which the port is bound.bindTargetPort(NodePort, EdgeRealizer)
public static void bindTargetPort(NodePort port,
                                  Edge edge)
port - the port instance to bind as target connection point. May be
 null.edge - the edge to which the port is bound. Must belong to a
 Graph2D instance.
java.lang.IllegalArgumentException - if the specified port either has no
 associated NodeRealizer or does not belong to the port
 collection of its associated NodeRealizer.
java.lang.NullPointerException - if the specified edge does not belong to a
 graph.getTargetPort(EdgeRealizer)
public static void bindTargetPort(NodePort port,
                                  EdgeRealizer er)
port - the port instance to bind as target connection point. May be
 null.er - the visual representation of the edge to which the port is bound.
java.lang.IllegalArgumentException - if the specified port either has no
 associated NodeRealizer or does not belong to the port
 collection of its associated NodeRealizer.getTargetPort(EdgeRealizer)public static NodePort getTargetPort(Edge edge)
edge - the edge to which the port is bound. Must belong to a
 Graph2D instance.
null if the edge is not bound to a target port.
java.lang.NullPointerException - if the specified edge does not belong to a
 graph.bindTargetPort(NodePort, EdgeRealizer)public static NodePort getTargetPort(EdgeRealizer er)
er - the visual representation of the edge to which the port is bound.
null if the edge is not bound to a target port.bindTargetPort(NodePort, EdgeRealizer)public EdgeCursor edges()
EdgeRealizer instance
 satisfies
 
 NodePort.getSourcePort(realizer) == this || NodePort.getTargetPort(realizer) == this
 
 If this port is not bound to any node or the associated node does not
 belong to any graph, the cursor will be empty.
public EdgeCursor inEdges()
EdgeRealizer instance
 satisfies
 
 NodePort.getTargetPort(realizer) == this
 
 If this port is not bound to any node or the associated node does not
 belong to any graph, the cursor will be empty.
public EdgeCursor outEdges()
EdgeRealizer instance
 satisfies
 
 NodePort.getSourcePort(realizer) == this
 
 If this port is not bound to any node or the associated node does not
 belong to any graph, the cursor will be empty.
public static void remove(NodePort port)
port - the port instance to be removed.PortLabelModel.findLabels(NodePort), 
edges()public boolean isSelected()
setSelected(boolean)public void setSelected(boolean selected)
selected - the new selection state of this port instance.isSelected(), 
NodePort.SelectionChangeHandlerpublic PortLocationModelParameter getModelParameter()
setModelParameter(PortLocationModelParameter)public void setModelParameter(PortLocationModelParameter parameter)
parameter - the new model parameter.getModelParameter()public YPoint getLocation()
public java.lang.Object getUserData()
setUserData(Object), 
NodePort.UserDataHandlerpublic void setUserData(java.lang.Object userData)
userData - the new user or business data for this port instance.getUserData(), 
NodePort.UserDataHandlerpublic java.lang.String getConfiguration()
setConfiguration(String)public void setConfiguration(java.lang.String id)
factory under the given configuration name.
id - The name of the configuration to use.
 The specified name must have been registered with the factory prior to the
 invocation of this method.getConfiguration()public static NodePort.Factory getFactory()
public boolean contains(double x,
                        double y)
true if this port's visual representation
 contains the specified point and false otherwise.
 The check is delegated to the NodePort.ContainsTest
 implementation that is registered for this port's configuration.
 If no such implementation is registered,
 ShapePortConfiguration.contains(NodePort, double, double)
 is used instead.
x - the x-coordinate of the point to check.y - the y-coordinate of the point to check.
true if this port's visual representation
 contains the specified point and false otherwise.
public boolean findIntersection(double ix,
                                double iy,
                                double ox,
                                double oy,
                                java.awt.geom.Point2D result)
true if the point i=(ix,iy) lies inside
 and the point o=(ox,oy) lies outside this port's visual
 representation and false< otherwise.
 If i lies inside and o lies outside, then the
 intersection of the line segment through i and o
 and the boundary of this port's visual representation is stored in the
 result parameter.
 The calculation is delegated to the NodePort.IntersectionTest
 implementation that is registered for this port's configuration.
 If no such implementation is registered,
 ShapePortConfiguration.findIntersection(NodePort, double, double, double, double, java.awt.geom.Point2D)
 is used instead.
ix - the x-coordinate of the point that has to lie inside the port's
 visual representation.iy - the y-coordinate of the point that has to lie inside the port's
 visual representation.ox - the x-coordinate of the point that has to lie outside the port's
 visual representation.oy - the y-coordinate of the point that has to lie outside the port's
 visual representation.result - an output parameter to store the intersection of the line
 segment through i and o and the
 port's visual representation. If this method returns false,
 the value of this parameter is undefined.
true if (ix,iy) lies inside and
 (ox,oy) lies outside this port's visual representation and
 false< otherwise.public void paint(java.awt.Graphics2D g)
NodePort.Painter
 implementation that is registered for this port's configuration.
 If no such implementation is registered,
 ShapePortConfiguration.paint(NodePort, java.awt.Graphics2D)
 is used instead.
g - the graphics context to paint upon.public YRectangle getBounds()
NodePort.BoundsProvider
 implementation that is registered for this port's configuration.
 If no such implementation is registered,
 ShapePortConfiguration.getBounds(NodePort) is queried
 instead.
public void calcUnionRect(java.awt.geom.Rectangle2D rectangle)
NodePort.UnionRectCalculator
 implementation is registered for this port's configuration.
 If no such implementation is registered,
 ShapePortConfiguration.calcUnionRect(NodePort, java.awt.geom.Rectangle2D)
 is used instead.
rectangle - the rectangle to be enlarged such that it contains the
 bounds of this port instance.| 
 | © Copyright 2000-2025, yWorks GmbH. All rights reserved. | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||