Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| http://www.jpicedt.org
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## jpicedt.graphic.model
Class PicNodeConnection

    java.lang.Object
      jpicedt.graphic.model.AbstractElement
          jpicedt.graphic.model.PicNodeConnection

All Implemented Interfaces:
  Element, PicObjectConstants

public class PicNodeConnection
extends AbstractElement

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`

Fields inherited from interface jpicedt.graphic.model.PicObjectConstants
`ARROW_GLOBAL_SCALE_LENGTH, ARROW_GLOBAL_SCALE_WIDTH, ARROW_INSET_SCALE, ARROW_LENGTH_SCALE, ARROW_WIDTH_LINEWIDTH_SCALE, ARROW_WIDTH_MINIMUM_MM, BRACKET_LENGTH_SCALE, CROSSHATCH, CROSSHATCH_FILLED, DASH_OPAQUE, DASH_TRANSPARENT, DASH1, DASH2, DASH3, DASHED, DIMEN, DOT_SEP, DOT_SEP1, DOT_SEP2, DOT_SEP3, DOTTED, DOUBLE_COLOR, DOUBLE_LINE, DOUBLE_SEP, FILL_COLOR, FILL_STYLE, HATCH_ANGLE, HATCH_COLOR, HATCH_SEP, HATCH_WIDTH, HLINES, HLINES_FILLED, INNER, LEFT_ARROW, LINE_COLOR, LINE_STYLE, LINE_WIDTH, MIDDLE, NONE, OUTER, OVER_STRIKE, OVER_STRIKE_COLOR, OVER_STRIKE_WIDTH, POLYDOTS_ANGLE, POLYDOTS_CIRCLE, POLYDOTS_DISK, POLYDOTS_PENTAGON, POLYDOTS_PENTAGON_FILLED, POLYDOTS_PLUS, POLYDOTS_SCALE_H, POLYDOTS_SCALE_V, POLYDOTS_SIZE_LINEWIDTH_SCALE, POLYDOTS_SIZE_MINIMUM_MM, POLYDOTS_SQUARE, POLYDOTS_SQUARE_FILLED, POLYDOTS_STYLE, POLYDOTS_SUPERIMPOSE, POLYDOTS_TRIANGLE, POLYDOTS_TRIANGLE_FILLED, PS_POINT, PST_CUSTOM, RBRACKET_LENGTH_SCALE, RIGHT_ARROW, SHADOW, SHADOW_ANGLE, SHADOW_COLOR, SHADOW_SIZE, SOLID, TBAR_WIDTH_LINEWIDTH_SCALE, TBAR_WIDTH_MINIMUM_MM, TEXT_BOX_CIRCLE, TEXT_BOX_NO_FRAME, TEXT_BOX_OVAL, TEXT_BOX_RECTANGLE, TEXT_FRAME, TEXT_HALIGN_CENTER, TEXT_HALIGN_LEFT, TEXT_HALIGN_RIGHT, TEXT_HOR_ALIGN, TEXT_ROTATION, TEXT_VALIGN_BASELINE, TEXT_VALIGN_BOTTOM, TEXT_VALIGN_CENTER, TEXT_VALIGN_TOP, TEXT_VERT_ALIGN, VLINES, VLINES_FILLED`

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

### EDGE_NCLINE

    public static final String EDGE_NCLINE

See Also:
  Constant Field Values

### EDGE_NCCURVE

    public static final String EDGE_NCCURVE

See Also:
  Constant Field Values

### changeLock

    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. 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

  - this first raises the changeLock semaphor,
  - then calls translate() on every node: this in turn make nodes forward a DrawingEvent to their connection (= this PicNodeConnection), yet this event is trapped here, hence not propagated upward ; note however that nodes update their own view whatever the value of the changeLock semaphor ;
  - then lower the changeLock semaphor, and fire a change-update event (which in turn will propagate the event upward along the tree).
  - Notice that, as opposed to BranchElement (and as a consequence of each node having possibly more than one connection), translating (or rotating or whatsoever) this edge and its two nodes as a single block also results in OTHER edges being affected... There, however, the changeLock semaphor will be down, and these PicNodeConnection's will update their state properly.

Constructor Detail

### PicNodeConnection

    public PicNodeConnection(DefaultLeafElement _nodeA,
                             DefaultLeafElement _nodeB,
                             String _edgeType,
                             PicAttributeSet set)

### PicNodeConnection

    public PicNodeConnection(PicNodeConnection src)

Method Detail

### clone

    public Object clone()

  Description copied from class: `AbstractElement`
  Returns a clone of this Element

  Specified by:
    `clone` in interface `Element`
  Specified by:
    `clone` in class `AbstractElement`

### getName

    public String getName()

  Description copied from interface: `Element`
  Return a non-localised string representing this element's name. This may be used by a UI to display some information related to this element, or by a localizer to fetch a i18n'd string.

### fetchEdgeShape

    public Shape fetchEdgeShape()

  Returns a Shape that holds the geometry of the connection. May be used, for instance, by the associated view.

### getEndPointA

    public PicPoint getEndPointA(PicPoint pt)

  Returns the coordinates of the edge's end-point at node A

### getEndPointB

    public PicPoint getEndPointB(PicPoint pt)

  Returns the coordinates of the edge's end-point at node B

### getTangentA

    public PicVector getTangentA(PicVector v)

  Return the tangent to the node connection at node A. Useful for instance to compute the direction of the first arrow.

  Returns:
    a unit-length vector

### getTangentB

    public PicVector getTangentB(PicVector v)

  Return the tangent to the node connection at node B. Useful for instance to compute the direction of the second arrow.

  Returns:
    a unit-length vector

### getNodeA

    public DefaultLeafElement getNodeA()

  Returns the first node.

  Returns:
    null if nodeA not set yet

### getNodeB

    public DefaultLeafElement getNodeB()

  Returns the second node.

  Returns:
    null if nodeB not set yet

### getNodeIndex

    public 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.

### setNodeA

    public void setNodeA(DefaultLeafElement o)

  Sets the first node.

### setNodeB

    public void setNodeB(DefaultLeafElement o)

  Sets the second node.

### getPoint

    public PicPoint getPoint(int index,
                             PicPoint src)

  Description copied from interface: `Element`
  Return the user-controlled point having the given index. The general contract is to return an IMMUTABLE instance of PicPoint, so that the only way to alter the geometry of this element is by calling the `setPoint` method.

  Parameters:
    `index` - the point index, should be greater or equal to the value returned by `getFirstPointIndex`, and lower or equal to `getLastPointIndex`.
  Returns:
    the point indexed by `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.

### getPointX

    public double getPointX(int index)

  Description copied from interface: `Element`
  Same as `getPoint()`, yet return the x-coordinate only.

  Parameters:
    `index` - the point index, should be greater or equal to the value returned by `getFirstPointIndex`, and lower or equal to `getLastPointIndex`.
  Returns:
    the X-coord of the point indexed by `index`.

### getPointY

    public double getPointY(int index)

  Description copied from interface: `Element`
  Same as `getPoint()`, yet return the y-coordinate only.

  Parameters:
    `index` - the point index, should be greater or equal to the value returned by `getFirstPointIndex`, and lower or equal to `getLastPointIndex`.
  Returns:
    the Y-coord of the point indexed by `index`.

### getFirstPointIndex

    public int getFirstPointIndex()

  Description copied from interface: `Element`
  Return the index of the first user-controlled point that can be retrieved by getPoint()

### getLastPointIndex

    public int getLastPointIndex()

  Description copied from interface: `Element`
  Return the index of the last user-controlled point that can be retrieved by getPoint()

### setPoint

    public void setPoint(int index,
                         PicPoint pt)

  Description copied from interface: `Element`
  Set the user-controlled point indexed by "index" to the given value. This should be a convenience call to setPoint(index,pt,null), i.e. using no particular geometrical constraint.

### setPoint

    public void setPoint(int index,
                         PicPoint pt,
                         EditPointConstraint constraint)

  Description copied from interface: `Element`
  Set the user-controlled point indexed by "index" to the given value, using the specified geometrical constraint. Constraints depend on the particular concrete implementation, and may involve restricting movement along a particular direction, moving several points at once to preserve parallelism,...

  Parameters:
    `constraint` - a geometry constraint, or null if no particular constraint is being imposed (aka default).

### getBoundingBox

    public Rectangle2D getBoundingBox(Rectangle2D r)

  Returns the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of the \\begin{picture} command.

  Returns:
    the bounding box (i.e. the surrounding rectangle) in double precision Used e.g. to determine the arguments of the \\begin{picture} command. If r is null, allocate a new rectangle and returns it. Otherwise the source rectangle is modified and returned for convenience. [todo:reynal] this really need to be improved : this method would probably better be moved to the attached view, since the latter knows exactly what the TRUE bounding box is.

### getAllowsChildren

    public boolean getAllowsChildren()

  Description copied from interface: `Element`
  Returns true if the receiver allows children.

### forwardChangedUpdate

    public 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. See DefaultLeafElement.fireChangedUpdate() for more details. This gives a chance to the receiver to update its layout, then to propagate the change-event upward.

  Parameters:
    `eventType` - the event type
    `node` - the node that sent the change-event.

### translate

    public void translate(double dx,
                          double dy)

  Translate both nodes and connections by the given vector

  Parameters:
    `dx` - The X coordinate of translation vector
    `dy` - The Y coordinate of translation vector
  Since:
    jPicEdt 1.4pre5

### scale

    public 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.

### rotate

    public void rotate(PicPoint ptOrg,
                       double angle)

  Rotate this Element by the given angle along the given point

  Parameters:
    `angle` - rotation angle in radians

### shear

    public void shear(PicPoint ptOrg,
                      double shx,
                      double shy)

  Shear this Element by the given params wrt to the given origin

### toString

    public String toString()

  Description copied from class: `AbstractElement`
  Returns a String representation of the attribute set for this AbstractElement

  Overrides:
    `toString` in class `AbstractElement`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| http://www.jpicedt.org
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Submit a bug : syd@jpicedt.org