public abstract class GEdge extends GraphObject
Modifier and Type | Class and Description |
---|---|
static class |
GEdge.Direction
used for labeling the connected nodes; i.e., a "from" node
|
GraphObject.Kind, GraphObject.ObjectIDComparator
Modifier and Type | Field and Description |
---|---|
(package private) Point2D.Double |
arrowEndPoint1
one back corner of the arrow.
|
(package private) Point2D.Double |
arrowEndPoint2
another back corner of the arrow.
|
(package private) GeneralPath |
arrowHeadShape
Arrowhead triangle to be filled in when drawing an arrow.
|
(package private) Point2D.Double |
arrowPoint
the "point" of the arrow.
|
EdgeAttributes |
edgeAttributes
used for indicating the node isn't connected
|
GraphObject |
fromObj |
Point2D.Double |
fromPt
remembers its source point as set.
|
(package private) Point2D.Double |
midPoint
remembers its middle point as set.
|
GraphObject |
toObj |
Point2D.Double |
toPt
remembers its destination point as set.
|
backColor, defaultDim, defaultSelectColor, defaultWrapColumns, defaultWrapLabels, displayRect3D, foreColor, highlightColor, history, isSelected, labelFont, myKind, objectID, objectMargin, ownerGraph, TerritorialLimit, textLabel, textLabelLowerLeftPt
Constructor and Description |
---|
GEdge()
Constructs a new GEdge with label "-".
|
GEdge(GraphObject FromOne,
GraphObject ToOne)
Constructs a new GEdge with label "-" going from one object to another.
|
Modifier and Type | Method and Description |
---|---|
void |
abandonObject()
Does everything but the actual removal (de-allocation)
|
static boolean |
areLinked(GNode go1,
GNode go2)
Determines whether the two charger nodes are linked together, by any
GEdge.
|
boolean |
commitToKnowledgeBase(KnowledgeBase kb)
needed for GraphLayout interface
|
void |
detachFromGNodes()
Finds the endpoint nodes of the edge, and removes the edge from each of
their lists
|
void |
drawArrowHead(Graphics2D g,
boolean filled,
boolean printing)
Uses the instance variables arrowPoint, arrowEndPoint1 and arrowEndPoint2
to speed up drawing
|
void |
drawBorder(Graphics2D g,
Color borderColor)
Currently empty, may be used in the future.
|
protected void |
finalize() |
static Point2D.Double |
findClippingPoint(Point2D.Double fromPt,
Point2D.Double toPt,
Shape s)
Assuming that there's a shape at the toPt, find the clipping point on its boundary
along a line from the fromPt to the toPt.
|
static Point2D.Double |
findClippingPointRectangle(Point2D.Double fromPt,
Rectangle2D.Double rect)
Given a point and a rectangle, find that point on the rectangle that lies
on the edge between the given point and the center of the rectangle
|
static Point2D.Double |
findClippingPointShape(Point2D.Double fromPt,
Point2D.Double toPt,
Shape shape)
Finds the clipping point for an arbitrary shape.
|
private float |
getArrowHeadAngle() |
int |
getArrowHeadHeight() |
private float |
getArrowHeadLength() |
int |
getArrowHeadWidth() |
double |
getEdgeThickness() |
float |
getLength() |
protected Shape |
getObjectShapeForClipping(GraphObject go)
Determines the appropriate rectangle to use as object boundaries when
drawing edges
|
Shape |
getShape()
Obtain the Shape object that represents the selectable region of this
object.
|
GEdge.Direction |
howLinked(GNode gn)
Tells which end of the current link (if either) is the given GNode.
|
void |
initializeArrowHead() |
GraphObject |
linkedTo(GNode gn)
Tells whether the given node is linked at all with this GEdge.
|
void |
makeArrowPoints(double howFar)
Convenience method for pre-calculating the arrow points for this edge (if needed).
|
void |
makeArrowPoints(Point2D.Double fromPt,
Point2D.Double toPt,
double howFar)
Sets the variables arrowPoint, arrowEndPoint1 and arrowEndPoint2 to speed
up drawing.
|
void |
placeEdge()
Determines the placement of a GEdge.
|
void |
setArrowHeadHeight(int arrowHeadHeight) |
void |
setArrowHeadWidth(int arrowHeadWidth) |
void |
setColor()
Sets the colors of a GEdge to black.
|
void |
setEdgeThickness(double edgeThickness) |
String |
toString()
Currently empty, may be used in the future.
|
boolean |
unCommitFromKnowledgeBase(KnowledgeBase kb)
Subclasses will implement this method in order to perform whatever
object-specific actions are appropriate for removing this object from the
knowledge base.
|
addHistoryRecord, adjustCustomDisplayRect, draw, findDominantContext, forceMove, forgetObject, getBestFontMetrics, getCenter, getColor, getDepth, getDim, getDisplayRect, getDisplayRect3D, getHistory, getLabelFont, getMinimumContentSize, getObjectLocator, getOutermostGraph, getOwnerFrame, getOwnerGraph, getShapeForDrawing, getTextLabel, getTextLabelSize, getUpperLeft, getWrapColumns, getWrapLabels, isNegated, isNegativelyNested, listToString, listToStringXML, putInCorrectContext, putInCorrectContext, resizeIfNecessary, resizeIfNecessary, selfCleanup, setBackground, setCenter, setCenterOnly, setColor, setDepth, setDim, setDim, setDisplayRect, setDisplayRect, setDisplayRect3D, setForeground, setLabelFont, setNegated, setOwnerGraph, setTextLabel, setTextLabel, setTextLabel, setUpperLeft, setUpperLeft
public GraphObject fromObj
public GraphObject toObj
public EdgeAttributes edgeAttributes
public Point2D.Double fromPt
public Point2D.Double toPt
Point2D.Double midPoint
Point2D.Double arrowPoint
makeArrowPoints(double)
Point2D.Double arrowEndPoint1
makeArrowPoints(double)
Point2D.Double arrowEndPoint2
makeArrowPoints(double)
GeneralPath arrowHeadShape
arrowPoint
,
arrowEndPoint1
,
arrowEndPoint2
public GEdge()
public GEdge(GraphObject FromOne, GraphObject ToOne)
FromOne
- edge starts hereToOne
- edge ends herepublic Shape getShape()
GraphObject
getShape
in class GraphObject
public float getLength()
public void setColor()
setColor
in class GraphObject
private float getArrowHeadLength()
private float getArrowHeadAngle()
public int getArrowHeadWidth()
public void setArrowHeadWidth(int arrowHeadWidth)
public int getArrowHeadHeight()
public void setArrowHeadHeight(int arrowHeadHeight)
public double getEdgeThickness()
public void setEdgeThickness(double edgeThickness)
public void initializeArrowHead()
public void drawBorder(Graphics2D g, Color borderColor)
drawBorder
in class GraphObject
g
- Graphics context on which the object is to be renderedborderColor
- the color to drawpublic String toString()
toString
in class GraphObject
IOManager
public void abandonObject()
abandonObject
in class GraphObject
public void detachFromGNodes()
protected void finalize() throws Throwable
finalize
in class GraphObject
Throwable
public void placeEdge()
GraphObject#displayRect
,
getObjectShapeForClipping(charger.obj.GraphObject)
protected Shape getObjectShapeForClipping(GraphObject go)
go
- The object whose boundary rectangle is sought.public void makeArrowPoints(double howFar)
howFar
- How far from the "from" object to draw the arrowhead. Ranges from 0 to 1.0;public void makeArrowPoints(Point2D.Double fromPt, Point2D.Double toPt, double howFar)
fromPt
- the beginning point of the edgetoPt
- the end point of the edgehowFar
- where the arrow should go where start is 0.0 and end is 1.0makeArrowPoints(double)
,
drawArrowHead(java.awt.Graphics2D, boolean, boolean)
public void drawArrowHead(Graphics2D g, boolean filled, boolean printing)
g
- Graphics context on which to drawfilled
- Whether to fill in the arrow head or notprinting
- Whether we are drawing to print or to display on screen
(not used)makeArrowPoints(double)
public static Point2D.Double findClippingPoint(Point2D.Double fromPt, Point2D.Double toPt, Shape s)
public static Point2D.Double findClippingPointRectangle(Point2D.Double fromPt, Rectangle2D.Double rect)
fromPt
- any point on the canvas; assume it is outside the rectanglerect
- the rectangle we want to intersect -- assume its center point
is the other end of the linepublic static Point2D.Double findClippingPointShape(Point2D.Double fromPt, Point2D.Double toPt, Shape shape)
fromPt
- origin of the linetoPt
- other end of the line (assumed to be inside the shape)shape
- the general shape to be analyzed. If toPt is not inside the
shape, or if fromPt is already inside the shape, strange things will
happen.public static boolean areLinked(GNode go1, GNode go2)
go1
- one nodego2
- another nodepublic GraphObject linkedTo(GNode gn)
gn
- is one end of the linkpublic GEdge.Direction howLinked(GNode gn)
gn
- is a possible end of the linkGEdge.Direction.FROM
,
GEdge.Direction.TO
,
GEdge.Direction.UNLINKED
public boolean commitToKnowledgeBase(KnowledgeBase kb)
commitToKnowledgeBase
in class GraphObject
public boolean unCommitFromKnowledgeBase(KnowledgeBase kb)
GraphObject
unCommitFromKnowledgeBase
in class GraphObject