Problem: FixedConnectionAnchor [message #225253] |
Fri, 27 October 2006 13:26 |
Eclipse User |
|
|
|
Originally posted by: mounafeki.yahoo.fr
hi,
I would like to connect my Figure from certain points. So I took the
Logic example as sample.
My Figure (GleisSegment) inherid the class "NodeFigure" (like in the Logic
Example).
I defined the input and output points in the constructor (A and B).
In the class FigureEditPart I inserted the methods
getSourceConnectionAnchor(ConnectionEditPart connEditPart) and
ConnectionAnchor getSourceConnectionAnchor(Request request).
As test I provided a connection from the point A. This is drawn correctly.
Now if I would like to draw another connection from B. as result were two
connections from B drawn ( the old connection is deleted and drawn again
from B).
I need your Help. Please.
How can I solve the problem?
Thanks.
----------------------- GleisSegmentFigure ---------------------------
.....
private Point mousePoint = new Point(0,0);
/*Constructor
*/
public GleisSegmentFigure()
{
this.addMouseMotionListener(new MouseMotionListener.Stub(){
public void mouseMoved(MouseEvent me) {
mousePoint.x= me.x; mousePoint.y= me.y;
}});
//inpouts
FixedConnectionAnchor c;
c = new FixedConnectionAnchor(this);
c.offsetH = 1;
c.offsetV = 25;
connectionAnchors.put("A_input", c);
inputConnectionAnchors.addElement(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 50;
c.offsetV = 25;
connectionAnchors.put("B_input", c);
inputConnectionAnchors.addElement(c);
//outputs
c = new FixedConnectionAnchor(this);
c.offsetH = 1;
c.offsetV = 25;
connectionAnchors.put("A_output", c);
outputConnectionAnchors.addElement(c);
c = new FixedConnectionAnchor(this);
c.offsetH = 50;
c.offsetV = 25;
connectionAnchors.put("B_output", c);
outputConnectionAnchors.addElement(c);
}
.......
----------------------------- GleisSegmentEditPart ---------------------
......
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart
connEditPart) {
Point pt = ((GleisSegmentFigure)getFigure()).getMousePoint(); // define
MousePosition
FixedConnectionAnchor
c=(FixedConnectionAnchor)((NodeFigure)getFigure()).getSource ConnectionAnchorAt(pt);
String port = ((NodeFigure)getFigure()).getConnectionAnchorName(c);
FixedConnectionAnchor result =
(FixedConnectionAnchor)((NodeFigure)getFigure()).getConnecti onAnchor(port);
return result ;
}
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
Point pt = new Point(((DropRequest)request).getLocation());
return ((NodeFigure)getFigure()).getSourceConnectionAnchorAt(pt);
}
....
-----------------------------------------------------------
|
|
|
Powered by
FUDForum. Page generated in 0.03321 seconds