Search this API

y.view
Class NodeRealizer

java.lang.Object
  extended by y.view.NodeRealizer
All Implemented Interfaces:
NodeLayout
Direct Known Subclasses:
GenericNodeRealizer, ImageNodeRealizer, ShapeNodeRealizer

public abstract class NodeRealizer
extends java.lang.Object
implements NodeLayout

Abstract graphical representation of a node. This class provides methods to draw a node. For this to happen a node must be bound to the realizer.

 

Field Summary
protected  double height
          The height of the rectangle describing the node.
static byte HOTSPOT_E
          Hotspot type identifier.
static byte HOTSPOT_N
          Hotspot type identifier.
static byte HOTSPOT_NE
          Hotspot type identifier.
static byte HOTSPOT_NONE
          Hotspot type identifier.
static byte HOTSPOT_NW
          Hotspot type identifier.
static byte HOTSPOT_S
          Hotspot type identifier.
static byte HOTSPOT_SE
          Hotspot type identifier.
static byte HOTSPOT_SW
          Hotspot type identifier.
static byte HOTSPOT_W
          Hotspot type identifier.
protected  double width
          The width of the rectangle describing the node.
protected  double x
          The x coordinate (left) of the rectangle describing the node.
protected  double y
          The y coordinate (top) of the rectangle describing the node.
 
Constructor Summary
NodeRealizer()
          Creates instance of NodeRealizer at location (0,0).
NodeRealizer(double x, double y)
          Creates instance of NodeRealizer at a certain position .
NodeRealizer(double x, double y, java.lang.String label)
          Creates instance of NodeRealizer at a certain position with given label.
NodeRealizer(NodeRealizer argNodeRealizer)
          Create instance of NodeRealizer and initialize it according to a given NodeRealizer.
 
Method Summary
 void addLabel(NodeLabel nl)
          Add the given label to this realizer.
 void addPort(NodePort port)
          Adds and binds the specified node port to this realizer.
protected  void boundsChanged()
          Callback method that should be overwritten by subclasses, that are interested in changes of the bounds of this realizer.
 void calcUnionRect(java.awt.geom.Rectangle2D r)
          Enlarges the given rectangle such that it will contain the bounding box of this realizer, all the bounding boxes of the realizer's labels, and all the bounding boxes of the realizer's NodePorts.
 void calcUnionRect(java.awt.geom.Rectangle2D r, byte layer)
          Enlarges the given rectangle such that it will contain the bounding box of this realizer and the bounding box of the realizer label.
protected  void calcUnionRectImpl(java.awt.geom.Rectangle2D r)
          Enlarges the specified rectangle such that it will contain the bounding box of this realizer.
protected  void calcUnionRectLabels(java.awt.geom.Rectangle2D r)
          Enlarges the specified rectangle such that it will contain the bounding boxes of all labels associated to this realizer.
protected  void calcUnionRectPorts(java.awt.geom.Rectangle2D r)
          Enlarges the specified rectangle such that it will contain the bounding boxes of all NodePorts associated to this realizer.
 boolean contains(double x, double y)
          Determines whether or not the bounding box of this realizer contains the specified point.
 NodeRealizer createCopy()
          Returns a copy of this realizer that is not bound to any node.
abstract  NodeRealizer createCopy(NodeRealizer nr)
          Returns a realizer of the same type as this realizer, that adopts as many attributes as possible from the given realizer.
 NodeLabel createNodeLabel()
          Creates a new node label that can be added to this realizer.
 boolean findBBIntersection(double ix, double iy, double ox, double oy, java.awt.geom.Point2D result)
          Calculates the intersection point of a line segment and this realizer's rectangular bounding box.
 boolean findIntersection(double ix, double iy, double ox, double oy, java.awt.geom.Point2D result)
          Calculates the intersection point of a line segment and this realizer's visual bounds.
 AutoBoundsFeature getAutoBoundsFeature()
          Returns a feature, that can be used to automatically adjust the NodeRealizers bounds.
 java.awt.geom.Rectangle2D.Double getBoundingBox()
          Return the bounding box of this realizer.
 double getCenterX()
          Get X-Coordinate of the center of the node.
 double getCenterY()
          Get Y-Coordinate of the center of the node.
 java.awt.Color getFillColor()
          Returns the fill color of this realizer.
 java.awt.Color getFillColor2()
          Returns the fill color of this realizer.
 double getHeight()
          Returns the height of this realizer.
static java.awt.Color getHotSpotColor()
          Returns the color of the hotspot marks for all realizers.
 NodeLabel getLabel()
          Returns the first label associated with this realizer.
 NodeLabel getLabel(int i)
          Returns the i-th label associated with this realizer.
 java.lang.String getLabelText()
          Returns the text of the first label associated with this realizer.
 byte getLayer()
          Returns the logical graphical layer for this realizer.
 java.awt.Color getLineColor()
          Returns the outline color of this realizer.
 LineType getLineType()
          Returns the line type of this realizer.
 MouseInputEditorProvider getMouseInputEditorProvider()
          Returns a provider, that can be used to query for a mouse input editor for this realizer.
 Node getNode()
          Returns the node this realizer is bound to.
 NodePort getPort(int i)
          Returns the i-th node port that is associated to this realizer.
 YList getPortCandidates(double gridResolution)
          Returns a list of YPoints that contains absolute(!)
 SizeConstraintProvider getSizeConstraintProvider()
          Returns a provider, that can be used to request information about size constraints for this realizer.
static java.awt.Color getSloppySelectionColor()
          Returns the fill color of the node used when drawing a selected node in sloppy mode.
 double getWidth()
          Returns the width of this realizer.
 double getX()
          Get X-Coordinate of the upper left corner of the node.
 double getY()
          Get Y-Coordinate of the upper left corner of the node.
 byte hotSpotHit(double hx, double hy)
          Returns one of the predefined hotspot type constants to signal which hotspot is hit by the given coordinates.
 boolean intersects(double rx, double ry, double rw, double rh)
          Determines whether or not the bounding box of this realizer intersects the specified rectangle.
protected  void invalidatePortPositions()
          Invalidates the positions of all associated NodePorts.
 boolean isInBox(double xb, double yb, double wb, double hb)
          Determines whether or not the center of this realizer lies within the specified rectangle.
 boolean isSelected()
          Returns the selection state of this realizer.
 boolean isTransparent()
          Returns the transparency state of this realizer.
 boolean isVisible()
          Returns true iff this realizer is marked as visible.
protected  void labelBoundsChanged(NodeLabel label)
          Callback method that should be overwritten by subclasses, that are interested in changes of the realizer label bounds.
 int labelCount()
          Returns the number of labels associated with this realizer.
 void moveBy(double dx, double dy)
          Moves the node relatively to the current position.
 void paint(java.awt.Graphics2D gfx)
          Paints this realizer and its label(s) on the given graphics context.
 void paintHotSpots(java.awt.Graphics2D g)
          Paints graphical hotspots around this realizer.
 void paintLayer(java.awt.Graphics2D g, byte layer)
          Requests this realizer to paint itself on the given graphics context under the constraint that the given layer is active.
 void paintLayerSloppy(java.awt.Graphics2D g, byte layer)
          Paints the realizer in a cheap, uniform and sloppy way on g.
protected abstract  void paintNode(java.awt.Graphics2D g)
          This method must be implemented by subclasses.
 void paintPorts(java.awt.Graphics2D gfx)
          Paints the NodePorts associated to this realizer.
 void paintSloppy(java.awt.Graphics2D g)
          Paints the realizer in a cheap, uniform and sloppy way on g.
 void paintText(java.awt.Graphics2D gfx)
          Paints the labels that belong to this realizer
 int portCount()
          Returns the number of node ports associated to this realizer.
 void read(java.io.ObjectInputStream in)
          Deprecated. Use the GraphML format instead.
 void removeLabel(int i)
          Removes the i-th node label from this realizer.
 void removeLabel(NodeLabel label)
          Remove the given label from this realizer.
 void removePort(int i)
          Removes the i-th node port from this realizer.
 void removePort(NodePort port)
          Removes the specified node port from this realizer.
 void repaint()
          Repaints this realizer.
 void setCenter(double x, double y)
          Set the coordinates of the center of the node.
 void setCenterX(double x)
          Set the x coordinate of the center of the node.
 void setCenterY(double y)
          Set the y coordinate of the center of the node.
 void setEdgesDirty()
          Marks adjacent edge realizers as dirty.
 void setFillColor(java.awt.Color c)
          Sets the fill color for this realizer.
 void setFillColor2(java.awt.Color c)
          Sets the second fill color for this realizer.
 void setFrame(double x, double y, double width, double height)
          Sets the frame of the realizer, i.e. its size and its location.
 void setFrame(java.awt.geom.Rectangle2D frame)
          Sets the frame of the realizer, i.e. its size and its location.
 void setHeight(double height)
          Sets the height of this realizer.
static void setHotSpotColor(java.awt.Color c)
          Sets the color of the hotspot marks for all realizers.
 void setLabel(NodeLabel nl)
          Sets the first label associated with this realizer.
 void setLabelText(java.lang.String label)
          Sets the text of the first label associated with this realizer.
 void setLayer(byte l)
          Sets the logical graphical layer for this realizer.
 void setLayer(byte l, boolean adjacentEdgesAsWell)
          Sets the layer this realizer should be painted on.
 void setLineColor(java.awt.Color c)
          Sets the outline color for this realizer.
 void setLineType(LineType lt)
          Sets the line type for this realizer.
 void setLocation(double x, double y)
          Sets the coordinates of the upper left corner of the node.
 void setSelected(boolean s)
          Sets the selection state of this realizer.
 void setSize(double width, double height)
          Sets the size of the realizer.
static void setSloppySelectionColor(java.awt.Color c)
          Sets the fill color of the node used when drawing a selected node in sloppy mode.
 void setTransparent(boolean b)
          Sets the transparency of the realizer.
 void setVisible(boolean visible)
          Sets the visibility state of this realizer.
 void setWidth(double width)
          Sets the width of this realizer.
 void setX(double xp)
          Sets the X-Coordinate of the upper left corner of the node.
 void setY(double yp)
          Sets the Y-Coordinate of the upper left corner of the node.
 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, toString, wait, wait, wait
 

Field Detail

HOTSPOT_NW

public static final byte HOTSPOT_NW
Hotspot type identifier. Identifies the hotspot located north west of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_N

public static final byte HOTSPOT_N
Hotspot type identifier. Identifies the hotspot located north of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_NE

public static final byte HOTSPOT_NE
Hotspot type identifier. Identifies the hotspot located north east of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_SW

public static final byte HOTSPOT_SW
Hotspot type identifier. Identifies the hotspot located south west of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_S

public static final byte HOTSPOT_S
Hotspot type identifier. Identifies the hotspot located south of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_SE

public static final byte HOTSPOT_SE
Hotspot type identifier. Identifies the hotspot located south east of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_W

public static final byte HOTSPOT_W
Hotspot type identifier. Identifies the hotspot located west of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_E

public static final byte HOTSPOT_E
Hotspot type identifier. Identifies the hotspot located east of this realizer.

See Also:
hotSpotHit(double,double), Constant Field Values

HOTSPOT_NONE

public static final byte HOTSPOT_NONE
Hotspot type identifier. This identifier signals that no hotspot was hit.

See Also:
hotSpotHit(double,double), Constant Field Values

x

protected double x
The x coordinate (left) of the rectangle describing the node.


y

protected double y
The y coordinate (top) of the rectangle describing the node.


width

protected double width
The width of the rectangle describing the node.


height

protected double height
The height of the rectangle describing the node.

Constructor Detail

NodeRealizer

public NodeRealizer()
Creates instance of NodeRealizer at location (0,0).


NodeRealizer

public NodeRealizer(double x,
                    double y)
Creates instance of NodeRealizer at a certain position .

Parameters:
x - X-Position of the center of the node
y - Y-Position of the center of the node

NodeRealizer

public NodeRealizer(double x,
                    double y,
                    java.lang.String label)
Creates instance of NodeRealizer at a certain position with given label.

Parameters:
x - X-Position of the center of the node
y - Y-Position of the center of the node
label - The label of the node

NodeRealizer

public NodeRealizer(NodeRealizer argNodeRealizer)
Create instance of NodeRealizer and initialize it according to a given NodeRealizer.

Parameters:
argNodeRealizer - A NodeRealizer
Method Detail

createCopy

public NodeRealizer createCopy()
Returns a copy of this realizer that is not bound to any node.

This method simply returns createCopy(this).


createCopy

public abstract NodeRealizer createCopy(NodeRealizer nr)
Returns a realizer of the same type as this realizer, that adopts as many attributes as possible from the given realizer.

Subclass realizers should always implement or overwrite this method, to guarantee correct copy behavior of the realizer.

Note: This method must not return null.

Parameters:
nr - the prototype realizer whose attributes will be copied.

getNode

public Node getNode()
Returns the node this realizer is bound to. If this realizer is not bound to any node, then null is returned.


setFillColor

public void setFillColor(java.awt.Color c)
Sets the fill color for this realizer.


getFillColor

public java.awt.Color getFillColor()
Returns the fill color of this realizer.


setFillColor2

public void setFillColor2(java.awt.Color c)
Sets the second fill color for this realizer. If a second fill color is set, then the realizer will be filled with a gradient paint from fillColor to fillColor2. By default this color is not set, i.e. it is null.


getFillColor2

public java.awt.Color getFillColor2()
Returns the fill color of this realizer.


setLineColor

public void setLineColor(java.awt.Color c)
Sets the outline color for this realizer.


getLineColor

public java.awt.Color getLineColor()
Returns the outline color of this realizer.


setLineType

public void setLineType(LineType lt)
Sets the line type for this realizer.


getLineType

public LineType getLineType()
Returns the line type of this realizer.


setTransparent

public void setTransparent(boolean b)
Sets the transparency of the realizer. Here transparency means that the node is not filled with a color.


isTransparent

public boolean isTransparent()
Returns the transparency state of this realizer.


setLabelText

public void setLabelText(java.lang.String label)
Sets the text of the first label associated with this realizer.

Parameters:
label - the text of the label

repaint

public void repaint()
Repaints this realizer.


getLabelText

public java.lang.String getLabelText()
Returns the text of the first label associated with this realizer.


createNodeLabel

public NodeLabel createNodeLabel()
Creates a new node label that can be added to this realizer.


setLabel

public void setLabel(NodeLabel nl)
Sets the first label associated with this realizer.


addLabel

public void addLabel(NodeLabel nl)
Add the given label to this realizer. By default a node realizer is associated with one label. By calling this method more labels can be added to the realizer.


removeLabel

public void removeLabel(NodeLabel label)
Remove the given label from this realizer. Removing a label is only permitted if it is not the last label associated with this realizer.

Parameters:
label - the node label to remove from this realizer,
See Also:
removeLabel(int)

removeLabel

public void removeLabel(int i)
Removes the i-th node label from this realizer.

Parameters:
i - the index of the node label to remove.
Throws:
java.lang.IndexOutOfBoundsException - if i >= labelCount or i < 0.
See Also:
removeLabel(NodeLabel)

getLabel

public NodeLabel getLabel()
Returns the first label associated with this realizer. If no label is associated with this realizer, a default label will be created, added to the realizer, and returned.

Returns:
the first node label of this realizer

getLabel

public NodeLabel getLabel(int i)
Returns the i-th label associated with this realizer.


labelCount

public int labelCount()
Returns the number of labels associated with this realizer.


getPort

public NodePort getPort(int i)
Returns the i-th node port that is associated to this realizer.

Parameters:
i - the index of the node port to return.
Returns:
the i-th node port that is associated to this realizer.
Throws:
java.lang.IndexOutOfBoundsException - if i >= portCount.

addPort

public void addPort(NodePort port)
Adds and binds the specified node port to this realizer. Calls NodePort.bindRealizer(NodeRealizer).

Parameters:
port - the node port to add.

removePort

public void removePort(NodePort port)
Removes the specified node port from this realizer. Use NodePort.remove(NodePort) to remove a node port and the edges connected to as well as the node labels associated with the node port.

Parameters:
port - the node port to remove.
See Also:
NodePort.remove(NodePort), PortLabelModel.findLabels(NodePort), NodePort.edges()

removePort

public void removePort(int i)
Removes the i-th node port from this realizer. Use NodePort.remove(NodePort) to remove a node port and the edges connected to as well as the node labels associated with the node port.

Parameters:
i - the index of the node port to remove.
Throws:
java.lang.IndexOutOfBoundsException - if i >= portCount.
See Also:
NodePort.remove(NodePort), PortLabelModel.findLabels(NodePort), NodePort.edges()

portCount

public int portCount()
Returns the number of node ports associated to this realizer.

Returns:
the number of node ports associated to this realizer.

getCenterX

public double getCenterX()
Get X-Coordinate of the center of the node.

See Also:
getX()

getCenterY

public double getCenterY()
Get Y-Coordinate of the center of the node.

See Also:
getY()

setCenter

public void setCenter(double x,
                      double y)
Set the coordinates of the center of the node.

See Also:
setLocation(double, double)

setCenterX

public void setCenterX(double x)
Set the x coordinate of the center of the node.

See Also:
setX(double)

setCenterY

public void setCenterY(double y)
Set the y coordinate of the center of the node.

See Also:
setY(double)

getX

public double getX()
Get X-Coordinate of the upper left corner of the node.

Specified by:
getX in interface NodeLayout
Returns:
the x-coordinate of the node
See Also:
getCenterX()

getY

public double getY()
Get Y-Coordinate of the upper left corner of the node.

Specified by:
getY in interface NodeLayout
Returns:
the y-coordinate of the node
See Also:
getCenterY()

setLocation

public void setLocation(double x,
                        double y)
Sets the coordinates of the upper left corner of the node.

Specified by:
setLocation in interface NodeLayout
Parameters:
x - the x-coordinates of the upper left corner.
y - the y-coordinates of the upper left corner.
See Also:
setCenter(double, double)

setX

public void setX(double xp)
Sets the X-Coordinate of the upper left corner of the node.

See Also:
setCenterX(double)

setY

public void setY(double yp)
Sets the Y-Coordinate of the upper left corner of the node.

See Also:
setCenterY(double)

moveBy

public void moveBy(double dx,
                   double dy)
Moves the node relatively to the current position.


getWidth

public double getWidth()
Returns the width of this realizer.

Specified by:
getWidth in interface NodeLayout
Returns:
the width of the node

getHeight

public double getHeight()
Returns the height of this realizer.

Specified by:
getHeight in interface NodeLayout
Returns:
the height of the node

setFrame

public void setFrame(double x,
                     double y,
                     double width,
                     double height)
Sets the frame of the realizer, i.e. its size and its location.


setFrame

public void setFrame(java.awt.geom.Rectangle2D frame)
Sets the frame of the realizer, i.e. its size and its location.


setSize

public void setSize(double width,
                    double height)
Sets the size of the realizer. Note that this method resizes the node in a way that the center location of this realizer won't change. The upper left corner of this realizer *will* change though.

Specified by:
setSize in interface NodeLayout
Parameters:
width - the new width of the node
height - the new height of the node

boundsChanged

protected void boundsChanged()
Callback method that should be overwritten by subclasses, that are interested in changes of the bounds of this realizer. This method is called after the bounds of this realizer (position or size) have changed.


labelBoundsChanged

protected void labelBoundsChanged(NodeLabel label)
Callback method that should be overwritten by subclasses, that are interested in changes of the realizer label bounds. This method is called after the bounds of a NodeLabel (position or size) have changed.

Parameters:
label - the label whose bounds have changed.

setWidth

public void setWidth(double width)
Sets the width of this realizer. This method delegates to setSize(double, double).


setHeight

public void setHeight(double height)
Sets the height of this realizer. This method delegates to setSize(double,double).


setVisible

public void setVisible(boolean visible)
Sets the visibility state of this realizer. By default a realizer is visible.


isVisible

public boolean isVisible()
Returns true iff this realizer is marked as visible. Invisible realizers won't paint themselves on a graphics context.


setLayer

public void setLayer(byte l)
Sets the logical graphical layer for this realizer. Layer information can be used by viewers to optimize redraws.

See Also:
Graph2DView.FG_LAYER, Graph2DView.BG_LAYER

getLayer

public byte getLayer()
Returns the logical graphical layer for this realizer. Layer information can be used by viewers to optimize redraws.

See Also:
Graph2DView.FG_LAYER, Graph2DView.BG_LAYER

setLayer

public void setLayer(byte l,
                     boolean adjacentEdgesAsWell)
Sets the layer this realizer should be painted on. The layer of the adjacent edges will be set as well if the second argument has value true.


setSelected

public void setSelected(boolean s)
Sets the selection state of this realizer. Selected realizers will paint themselves in a highlighted fashion on a graphics context.


isSelected

public boolean isSelected()
Returns the selection state of this realizer.


setHotSpotColor

public static void setHotSpotColor(java.awt.Color c)
Sets the color of the hotspot marks for all realizers. By default Color.gr

See Also:
paintHotSpots(Graphics2D)

getHotSpotColor

public static java.awt.Color getHotSpotColor()
Returns the color of the hotspot marks for all realizers.

See Also:
setHotSpotColor(Color)

setSloppySelectionColor

public static void setSloppySelectionColor(java.awt.Color c)
Sets the fill color of the node used when drawing a selected node in sloppy mode. By default Color.gray is used.

See Also:
paintSloppy(Graphics2D)

getSloppySelectionColor

public static java.awt.Color getSloppySelectionColor()
Returns the fill color of the node used when drawing a selected node in sloppy mode.

See Also:
paintSloppy(Graphics2D)

getAutoBoundsFeature

public AutoBoundsFeature getAutoBoundsFeature()
Returns a feature, that can be used to automatically adjust the NodeRealizers bounds.

Returns:
an implementation of interface AutoBoundsFeature or null, if no feature is bound to this realizer.

getSizeConstraintProvider

public SizeConstraintProvider getSizeConstraintProvider()
Returns a provider, that can be used to request information about size constraints for this realizer. E.g. minimum and maximum sizes can be defined.

Returns:
an implementation of interface SizeConstraintProvider or null, if no such provider is bound to this realizer.

getMouseInputEditorProvider

public MouseInputEditorProvider getMouseInputEditorProvider()
Returns a provider, that can be used to query for a mouse input editor for this realizer. The default implementation returns this realizer, if it implements the MouseInputEditorProvider interface.

Returns:
an implementation of interface MouseInputEditorProvider or null, if no such provider is bound to this realizer.

getBoundingBox

public java.awt.geom.Rectangle2D.Double getBoundingBox()
Return the bounding box of this realizer. The bounding box does not necessarily contain the bounding box of the realizer label.


hotSpotHit

public byte hotSpotHit(double hx,
                       double hy)
Returns one of the predefined hotspot type constants to signal which hotspot is hit by the given coordinates.


findBBIntersection

public boolean findBBIntersection(double ix,
                                  double iy,
                                  double ox,
                                  double oy,
                                  java.awt.geom.Point2D result)
Calculates the intersection point of a line segment and this realizer's rectangular bounding box. This method returns true if and only if the coordinates (ix,iy) are identical to (getCenterX(),getCenterY()) and the coordinates (ox,oy) lie outside this realizer's rectangular bounding box. In this case, the absolute coordinates of the intersection point of line segment (ix,iy) - (ox,oy) and this realizer's rectangular bounding box are stored in the given Point2D instance.

Parameters:
ix - the x-coordinate of a point inside the realizer's rectangular bounding box. Must equal getCenterX().
iy - the y-coordinate of a point inside the realizer's rectangular bounding box. Must equal getCenterY().
ox - the x-coordinate of a point outside the realizer's rectangular bounding box.
oy - the y-coordinate of a point outside the realizer's rectangular bounding box.
result - output parameter for the absolute world coordinates of the calculated intersection point.
Returns:
true if (ix,iy) is the center of this realizer's rectangular bounding box and (ox,oy) lies outside this realizer's rectangular bounding box; false otherwise.
See Also:
findIntersection(double, double, double, double, java.awt.geom.Point2D)

findIntersection

public boolean findIntersection(double ix,
                                double iy,
                                double ox,
                                double oy,
                                java.awt.geom.Point2D result)
Calculates the intersection point of a line segment and this realizer's visual bounds. This method returns true if and only if the coordinates (ix,iy) lie inside and the coordinates (ox,oy) lie outside this realizer's visual bounds. In this case, the absolute coordinates of the intersection point of line segment (ix,iy) - (ox,oy) and this realizer's visual bounds are stored in the given Point2D instance.

Subclasses may overwrite this method for efficient intersection calculation.

Parameters:
ix - the x-coordinate of a point inside the realizer's visual bounds.
iy - the y-coordinate of a point inside the realizer's visual bounds.
ox - the x-coordinate of a point outside the realizer's visual bounds.
oy - the y-coordinate of a point outside the realizer's visual bounds.
result - output parameter for the absolute world coordinates of the calculated intersection point.
Returns:
true if (ix,iy) lies inside and (ox,oy) lies outside this realizer's visual bounds; false otherwise.
See Also:
contains(double, double)

calcUnionRect

public void calcUnionRect(java.awt.geom.Rectangle2D r,
                          byte layer)
Enlarges the given rectangle such that it will contain the bounding box of this realizer and the bounding box of the realizer label. The given layer indicates for which graphics layer clipping information is collected by doing this call.


calcUnionRect

public void calcUnionRect(java.awt.geom.Rectangle2D r)
Enlarges the given rectangle such that it will contain the bounding box of this realizer, all the bounding boxes of the realizer's labels, and all the bounding boxes of the realizer's NodePorts. Calls calcUnionRectImpl(java.awt.geom.Rectangle2D), calcUnionRectLabels(java.awt.geom.Rectangle2D), and calcUnionRectPorts(java.awt.geom.Rectangle2D).


calcUnionRectImpl

protected void calcUnionRectImpl(java.awt.geom.Rectangle2D r)
Enlarges the specified rectangle such that it will contain the bounding box of this realizer.

Parameters:
r - the rectangle to enlarge.

calcUnionRectLabels

protected void calcUnionRectLabels(java.awt.geom.Rectangle2D r)
Enlarges the specified rectangle such that it will contain the bounding boxes of all labels associated to this realizer.

Parameters:
r - the rectangle to enlarge.

calcUnionRectPorts

protected void calcUnionRectPorts(java.awt.geom.Rectangle2D r)
Enlarges the specified rectangle such that it will contain the bounding boxes of all NodePorts associated to this realizer.

Parameters:
r - the rectangle to enlarge.

intersects

public boolean intersects(double rx,
                          double ry,
                          double rw,
                          double rh)
Determines whether or not the bounding box of this realizer intersects the specified rectangle.

Parameters:
rx - the smallest x-coordinate of the rectangle to check.
ry - the smallest y-coordinate of the rectangle to check.
rw - the width of the rectangle to check.
rh - the height of the rectangle to check.
Returns:
true if the bounding box of this realizer intersects the specified rectangle; false otherwise.

contains

public boolean contains(double x,
                        double y)
Determines whether or not the bounding box of this realizer contains the specified point.

Parameters:
x - the x-coordinate of the point to check.
y - the y-coordinate of the point to check.
Returns:
true if the bounding box of this realizer contains the specified point; false otherwise.

isInBox

public boolean isInBox(double xb,
                       double yb,
                       double wb,
                       double hb)
Determines whether or not the center of this realizer lies within the specified rectangle.

Parameters:
xb - the smallest x-coordinate of the rectangle to check.
yb - the smallest y-coordinate of the rectangle to check.
wb - the width of the rectangle to check.
hb - the height of the rectangle to check.
Returns:
true if the center of this realizer lies within the specified rectangle; false otherwise.

getPortCandidates

public YList getPortCandidates(double gridResolution)
Returns a list of YPoints that contains absolute(!) coordinates of port candidate locations that are suitable for the given grid resolution.

Parameters:
gridResolution - the distance between two grid points, the origin of the grid is at (0,0) in world coordinates
Returns:
a YList of YPoint instances, each specifying an absolute port position

paintNode

protected abstract void paintNode(java.awt.Graphics2D g)
This method must be implemented by subclasses. It defines in which way the realizer paints itself on a graphics context.


paintHotSpots

public void paintHotSpots(java.awt.Graphics2D g)
Paints graphical hotspots around this realizer. The hotspots mark regions on which hit tests can be performed.


paintLayer

public void paintLayer(java.awt.Graphics2D g,
                       byte layer)
Requests this realizer to paint itself on the given graphics context under the constraint that the given layer is active. By default this method will do nothing if the given layer does not match the layer of this realizer. Otherwise the regular paint method will be invoked.


paintLayerSloppy

public void paintLayerSloppy(java.awt.Graphics2D g,
                             byte layer)
Paints the realizer in a cheap, uniform and sloppy way on g. The given layer indicates what kind of layer objects should be painted. By default this method does nothing if layer != this.getLayer(). Otherwise paintSloppy gets called.


paintSloppy

public void paintSloppy(java.awt.Graphics2D g)
Paints the realizer in a cheap, uniform and sloppy way on g. By default this call draws a rectangle with this realizer's bounds and colors. No label will be painted.


paint

public void paint(java.awt.Graphics2D gfx)
Paints this realizer and its label(s) on the given graphics context. this method will do nothing if the realizer is marked as invisible.


paintText

public void paintText(java.awt.Graphics2D gfx)
Paints the labels that belong to this realizer


paintPorts

public void paintPorts(java.awt.Graphics2D gfx)
Paints the NodePorts associated to this realizer.

Parameters:
gfx - the graphics context to paint upon.

invalidatePortPositions

protected void invalidatePortPositions()
Invalidates the positions of all associated NodePorts. The position of each associated node port as well as source/target point of all edges connecting to each associated node port have to be recalculated.


setEdgesDirty

public void setEdgesDirty()
Marks adjacent edge realizers as dirty. Dirty realizers will definitely recalculate their features before painting themselves.


write

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

Writes this realizer in a serialized form to the given stream.

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 the serialized form of this realizer. The realizer must have been written out before by it's write(ObjectOutputStream) method.

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

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