Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Problem: FixedConnectionAnchor
Problem: FixedConnectionAnchor [message #225253] Fri, 27 October 2006 13:26
Eclipse UserFriend
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);
}
....

-----------------------------------------------------------
Previous Topic:Editor area and bounds
Next Topic:Create a Label for a Figure
Goto Forum:
  


Current Time: Thu Jan 16 03:23:30 GMT 2025

Powered by FUDForum. Page generated in 0.03321 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top