|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjpicedt.graphic.model.AbstractElement
jpicedt.graphic.model.PicNodeConnection
public class PicNodeConnection
This class represents a connection between two DefaultLeafElement's. It directly inherits from AbstractElement because BranchElement (after thinking it over carefully) is not the most appropriate choice in many respects: - first, the connection is a sort of branch-element, yet its geometry is directly implemented here (as a GeneralPath) rather than in a separate class, so this is quite different from BranchElement, where the whole geometry is delegated to children. - second, the relationship b/w this class and the two DefaultLeafElement's is definitely not a parent/child one, seeing that a node may be linked to more than one connection (which is forbidden in a parent/child relation as in BranchElement) - third, (child-)nodes need to hold a reference to the many (parent) node-connections, so that the connection geometry can keep up with any change made to the geometry of the children. This is the idea behind the improvement of the fireChangedUpdate() method in DefaultLeafElement (april'05) whereby, in addition to standard child-parent event dispatching, change events are also dispatched to every appropriate connection, if any, irrespective of the nature of the (real) parent (e.g., Drawing.RootElement or PicGroup). In particular, this means that one DefaultLeafElement may belong to a given group A, while the other DefaultLeafElement may belong to another group B, and at the same time both DefaultLeafElement's may share the same connection (now, this also implies that a PicNodeConnection may have "dangling" bonds if we cut/delete one of the groups [pending] the view might get confused ?).
Field Summary | |
---|---|
protected boolean |
changeLock
a semaphor that signals a change of state is underway in this PicNodeConnection and it shouldn't process events coming from its node before the change is completed (hence this is used inside forwardChangedUpdate() );
set it to true each time you start modifying nodes AND edge simulatneously and you don't want
events to be forwarded to the root of the hierarchy before everything is completed (e.g. |
static String |
EDGE_NCCURVE
|
static String |
EDGE_NCLINE
|
Fields inherited from class jpicedt.graphic.model.AbstractElement |
---|
attributeSet, parent, view |
Constructor Summary | |
---|---|
PicNodeConnection(DefaultLeafElement _nodeA,
DefaultLeafElement _nodeB,
String _edgeType,
PicAttributeSet set)
|
|
PicNodeConnection(PicNodeConnection src)
|
Method Summary | |
---|---|
Object |
clone()
Returns a clone of this Element |
Shape |
fetchEdgeShape()
Returns a Shape that holds the geometry of the connection. |
void |
forwardChangedUpdate(Element node,
DrawingEvent.EventType eventType)
Called by a child-node (=a DefaultLeafElement) to inform this connection of some change that occured to one of its nodes. |
boolean |
getAllowsChildren()
Returns true if the receiver allows children. |
Rectangle2D |
getBoundingBox(Rectangle2D r)
Returns the bounding box (i.e. |
PicPoint |
getEndPointA(PicPoint pt)
Returns the coordinates of the edge's end-point at node A |
PicPoint |
getEndPointB(PicPoint pt)
Returns the coordinates of the edge's end-point at node B |
int |
getFirstPointIndex()
Return the index of the first user-controlled point that can be retrieved by getPoint() |
int |
getLastPointIndex()
Return the index of the last user-controlled point that can be retrieved by getPoint() |
String |
getName()
Return a non-localised string representing this element's name. |
DefaultLeafElement |
getNodeA()
Returns the first node. |
DefaultLeafElement |
getNodeB()
Returns the second node. |
int |
getNodeIndex(DefaultLeafElement o)
Returns the index (0 or 1) of the given node, or -1 if the given node is not connected to this edge. |
PicPoint |
getPoint(int index,
PicPoint src)
Return the user-controlled point having the given index. |
double |
getPointX(int index)
Same as getPoint() , yet return the x-coordinate only. |
double |
getPointY(int index)
Same as getPoint() , yet return the y-coordinate only. |
PicVector |
getTangentA(PicVector v)
Return the tangent to the node connection at node A. |
PicVector |
getTangentB(PicVector v)
Return the tangent to the node connection at node B. |
void |
rotate(PicPoint ptOrg,
double angle)
Rotate this Element by the given angle along the given point |
void |
scale(double ptOrgX,
double ptOrgY,
double sx,
double sy)
Scale children by (sx,sy) using (ptOrgX,ptOrgY) as origin ; sx and sy can be negative. |
void |
setNodeA(DefaultLeafElement o)
Sets the first node. |
void |
setNodeB(DefaultLeafElement o)
Sets the second node. |
void |
setPoint(int index,
PicPoint pt)
Set the user-controlled point indexed by "index" to the given value. |
void |
setPoint(int index,
PicPoint pt,
EditPointConstraint constraint)
Set the user-controlled point indexed by "index" to the given value, using the specified geometrical constraint. |
void |
shear(PicPoint ptOrg,
double shx,
double shy)
Shear this Element by the given params wrt to the given origin |
String |
toString()
Returns a String representation of the attribute set for this AbstractElement |
void |
translate(double dx,
double dy)
Translate both nodes and connections by the given vector |
Methods inherited from class jpicedt.graphic.model.AbstractElement |
---|
anchorPointsIterator, fireChangedUpdate, getAttribute, getAttributeSet, getDrawing, getParent, getView, removeView, scale, setAttribute, setAttributeSet, setParent, setViewFromFactory |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String EDGE_NCLINE
public static final String EDGE_NCCURVE
protected boolean changeLock
forwardChangedUpdate()
);
set it to true each time you start modifying nodes AND edge simulatneously and you don't want
events to be forwarded to the root of the hierarchy before everything is completed (e.g. to
get rid of side-effects, or to reduce the burden for the repaint manager).
Example of use : whenever we call translate()
on this PicNodeConnection
Constructor Detail |
---|
public PicNodeConnection(DefaultLeafElement _nodeA, DefaultLeafElement _nodeB, String _edgeType, PicAttributeSet set)
public PicNodeConnection(PicNodeConnection src)
Method Detail |
---|
public Object clone()
AbstractElement
clone
in interface Element
clone
in class AbstractElement
public String getName()
Element
public Shape fetchEdgeShape()
public PicPoint getEndPointA(PicPoint pt)
public PicPoint getEndPointB(PicPoint pt)
public PicVector getTangentA(PicVector v)
public PicVector getTangentB(PicVector v)
public DefaultLeafElement getNodeA()
public DefaultLeafElement getNodeB()
public int getNodeIndex(DefaultLeafElement o)
public void setNodeA(DefaultLeafElement o)
public void setNodeB(DefaultLeafElement o)
public PicPoint getPoint(int index, PicPoint src)
Element
setPoint
method.
index
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
index
;
if src
is null, concrete implementation of this method should
allocate a new PicPoint and return it,
otherwise directly modify src
and return it as well for convenience.public double getPointX(int index)
Element
getPoint()
, yet return the x-coordinate only.
index
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
index
.public double getPointY(int index)
Element
getPoint()
, yet return the y-coordinate only.
index
- the point index, should be greater or equal to the value returned by
getFirstPointIndex
, and lower or equal to getLastPointIndex
.
index
.public int getFirstPointIndex()
Element
public int getLastPointIndex()
Element
public void setPoint(int index, PicPoint pt)
Element
public void setPoint(int index, PicPoint pt, EditPointConstraint constraint)
Element
constraint
- a geometry constraint, or null if no particular constraint is being imposed (aka default).public Rectangle2D getBoundingBox(Rectangle2D r)
public boolean getAllowsChildren()
Element
public void forwardChangedUpdate(Element node, DrawingEvent.EventType eventType)
eventType
- the event typenode
- the node that sent the change-event.public void translate(double dx, double dy)
dx
- The X coordinate of translation vectordy
- The Y coordinate of translation vectorpublic void scale(double ptOrgX, double ptOrgY, double sx, double sy)
public void rotate(PicPoint ptOrg, double angle)
angle
- rotation angle in radianspublic void shear(PicPoint ptOrg, double shx, double shy)
public String toString()
AbstractElement
toString
in class AbstractElement
|
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |