|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.NodeRealizer
public abstract class NodeRealizer
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 NodePort s. |
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 NodePort s 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 NodePort s. |
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 NodePort s 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 |
---|
public static final byte HOTSPOT_NW
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_N
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_NE
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_SW
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_S
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_SE
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_W
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_E
hotSpotHit(double,double)
,
Constant Field Valuespublic static final byte HOTSPOT_NONE
hotSpotHit(double,double)
,
Constant Field Valuesprotected double x
protected double y
protected double width
protected double height
Constructor Detail |
---|
public NodeRealizer()
public NodeRealizer(double x, double y)
x
- X-Position of the center of the nodey
- Y-Position of the center of the nodepublic NodeRealizer(double x, double y, java.lang.String label)
x
- X-Position of the center of the nodey
- Y-Position of the center of the nodelabel
- The label of the nodepublic NodeRealizer(NodeRealizer argNodeRealizer)
argNodeRealizer
- A NodeRealizerMethod Detail |
---|
public NodeRealizer createCopy()
This method simply returns createCopy(this)
.
public abstract NodeRealizer createCopy(NodeRealizer nr)
Subclass realizers should always implement or overwrite this method, to guarantee correct copy behavior of the realizer.
Note: This method must not return null
.
nr
- the prototype realizer whose attributes will be copied.public Node getNode()
null
is returned.
public void setFillColor(java.awt.Color c)
public java.awt.Color getFillColor()
public void setFillColor2(java.awt.Color c)
null
.
public java.awt.Color getFillColor2()
public void setLineColor(java.awt.Color c)
public java.awt.Color getLineColor()
public void setLineType(LineType lt)
public LineType getLineType()
public void setTransparent(boolean b)
public boolean isTransparent()
public void setLabelText(java.lang.String label)
label
- the text of the labelpublic void repaint()
public java.lang.String getLabelText()
public NodeLabel createNodeLabel()
public void setLabel(NodeLabel nl)
public void addLabel(NodeLabel nl)
public void removeLabel(NodeLabel label)
label
- the node label to remove from this realizer,removeLabel(int)
public void removeLabel(int i)
i
-th node label from this realizer.
i
- the index of the node label to remove.
java.lang.IndexOutOfBoundsException
- if i >= labelCount
or
i < 0
.removeLabel(NodeLabel)
public NodeLabel getLabel()
created
,
added
to the realizer, and returned.
public NodeLabel getLabel(int i)
public int labelCount()
public NodePort getPort(int i)
i
-th node port that is associated to this
realizer.
i
- the index of the node port to return.
i
-th node port that is associated to this
realizer.
java.lang.IndexOutOfBoundsException
- if i >= portCount
.public void addPort(NodePort port)
NodePort.bindRealizer(NodeRealizer)
.
port
- the node port to add.public void removePort(NodePort port)
NodePort.remove(NodePort)
to remove a node port
and the edges connected to as well as the node labels associated
with the node port.
port
- the node port to remove.NodePort.remove(NodePort)
,
PortLabelModel.findLabels(NodePort)
,
NodePort.edges()
public void removePort(int i)
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.
i
- the index of the node port to remove.
java.lang.IndexOutOfBoundsException
- if i >= portCount
.NodePort.remove(NodePort)
,
PortLabelModel.findLabels(NodePort)
,
NodePort.edges()
public int portCount()
public double getCenterX()
getX()
public double getCenterY()
getY()
public void setCenter(double x, double y)
setLocation(double, double)
public void setCenterX(double x)
setX(double)
public void setCenterY(double y)
setY(double)
public double getX()
getX
in interface NodeLayout
getCenterX()
public double getY()
getY
in interface NodeLayout
getCenterY()
public void setLocation(double x, double y)
setLocation
in interface NodeLayout
x
- the x-coordinates of the upper left corner.y
- the y-coordinates of the upper left corner.setCenter(double, double)
public void setX(double xp)
setCenterX(double)
public void setY(double yp)
setCenterY(double)
public void moveBy(double dx, double dy)
public double getWidth()
getWidth
in interface NodeLayout
public double getHeight()
getHeight
in interface NodeLayout
public void setFrame(double x, double y, double width, double height)
public void setFrame(java.awt.geom.Rectangle2D frame)
public void setSize(double width, double height)
setSize
in interface NodeLayout
width
- the new width of the nodeheight
- the new height of the nodeprotected void boundsChanged()
protected void labelBoundsChanged(NodeLabel label)
NodeLabel
(position or size)
have changed.
label
- the label whose bounds have changed.public void setWidth(double width)
setSize(double, double)
.
public void setHeight(double height)
setSize(double,double)
.
public void setVisible(boolean visible)
public boolean isVisible()
true
iff this realizer is marked as visible.
Invisible realizers won't paint themselves on a graphics context.
public void setLayer(byte l)
Graph2DView.FG_LAYER
,
Graph2DView.BG_LAYER
public byte getLayer()
Graph2DView.FG_LAYER
,
Graph2DView.BG_LAYER
public void setLayer(byte l, boolean adjacentEdgesAsWell)
true
.
public void setSelected(boolean s)
public boolean isSelected()
public static void setHotSpotColor(java.awt.Color c)
Color.gr
paintHotSpots(Graphics2D)
public static java.awt.Color getHotSpotColor()
setHotSpotColor(Color)
public static void setSloppySelectionColor(java.awt.Color c)
Color.gray
is used.
paintSloppy(Graphics2D)
public static java.awt.Color getSloppySelectionColor()
paintSloppy(Graphics2D)
public AutoBoundsFeature getAutoBoundsFeature()
AutoBoundsFeature
or null,
if no feature is bound to this realizer.public SizeConstraintProvider getSizeConstraintProvider()
SizeConstraintProvider
or null,
if no such provider is bound to this realizer.public MouseInputEditorProvider getMouseInputEditorProvider()
MouseInputEditorProvider
interface.
MouseInputEditorProvider
or null,
if no such provider is bound to this realizer.public java.awt.geom.Rectangle2D.Double getBoundingBox()
public byte hotSpotHit(double hx, double hy)
public boolean findBBIntersection(double ix, double iy, double ox, double oy, java.awt.geom.Point2D result)
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.
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.
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.findIntersection(double, double, double, double, java.awt.geom.Point2D)
public boolean findIntersection(double ix, double iy, double ox, double oy, java.awt.geom.Point2D result)
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.
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.
true
if (ix,iy)
lies inside and
(ox,oy)
lies outside this realizer's visual bounds;
false
otherwise.contains(double, double)
public void calcUnionRect(java.awt.geom.Rectangle2D r, byte layer)
public void calcUnionRect(java.awt.geom.Rectangle2D r)
NodePort
s.
Calls calcUnionRectImpl(java.awt.geom.Rectangle2D)
,
calcUnionRectLabels(java.awt.geom.Rectangle2D)
, and
calcUnionRectPorts(java.awt.geom.Rectangle2D)
.
protected void calcUnionRectImpl(java.awt.geom.Rectangle2D r)
r
- the rectangle to enlarge.protected void calcUnionRectLabels(java.awt.geom.Rectangle2D r)
r
- the rectangle to enlarge.protected void calcUnionRectPorts(java.awt.geom.Rectangle2D r)
NodePort
s associated to this realizer.
r
- the rectangle to enlarge.public boolean intersects(double rx, double ry, double rw, double rh)
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.
true
if the bounding box of this realizer
intersects the specified rectangle; false
otherwise.public boolean contains(double x, double y)
x
- the x-coordinate of the point to check.y
- the y-coordinate of the point to check.
true
if the bounding box of this realizer
contains the specified point; false
otherwise.public boolean isInBox(double xb, double yb, double wb, double hb)
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.
true
if the center of this realizer lies within the
specified rectangle; false
otherwise.public YList getPortCandidates(double gridResolution)
gridResolution
- the distance between two grid points, the origin of the grid is
at (0,0) in world coordinates
YPoint
instances, each specifying an absolute port positionprotected abstract void paintNode(java.awt.Graphics2D g)
public void paintHotSpots(java.awt.Graphics2D g)
public void paintLayer(java.awt.Graphics2D g, byte layer)
paint
method will be invoked.
public void paintLayerSloppy(java.awt.Graphics2D g, byte layer)
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.
public void paintSloppy(java.awt.Graphics2D g)
g
. By default this call draws a
rectangle with this realizer's bounds and colors.
No label will be painted.
public void paint(java.awt.Graphics2D gfx)
public void paintText(java.awt.Graphics2D gfx)
public void paintPorts(java.awt.Graphics2D gfx)
NodePort
s associated to this realizer.
gfx
- the graphics context to paint upon.protected void invalidatePortPositions()
NodePort
s.
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.
public void setEdgesDirty()
public void write(java.io.ObjectOutputStream out) throws java.io.IOException
GraphML format
instead.
java.io.IOException
public void read(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
GraphML format
instead.
write(ObjectOutputStream)
method.
java.io.IOException
java.lang.ClassNotFoundException
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |