[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
|
[news.eclipse.tools.gef] Re: How to draw a line?
|
Hi Ananth,
I'm not sure what part cuase you got stuck. Hope my experience gives you
some help. In the problems I mentioned above, I've solved some of them.
1. The first method I use is to draw a line from a constraint, and drawLine
from the left-top point to right-bottom point. To allow the constraint move
from north-west to east-south, need to override the method in
XYLayoutEditPolicy
which give restriction while dragging the constraint.
protected Object getConstraintFor(ChangeBoundsRequest request,
GraphicalEditPart child)
The problem now I have in this method is : The constraint disappears once
the constraint resizes through size 0. But the line can actually be created.
2. The second way I do is to use a XYAnchor to draw a line. I will send you
a
script privately since I just revised it from other websites and some bugs
inside.
After adding a line, we need to do some feedback effect.
Override some methods in GraphicalNodeEditPolicy such as
showCreationFeedback()
to define your feedback behavior.
If you want to change the XYAnchor Conneciton with:
Overwrites the method in AbstractConnectionEditPart in your lineEditPart
protected void refreshTargetAnchor() {
int width = 5;
if(connection instanceof PolylineConnection){
((PolylineConnection)connection).setLineWidth(width);
}
}
Hope it helps....
Brandon
"Ananth" <ananth@xxxxxxxxxxxxx> ???
news:26044770.1142516032835.JavaMail.root@xxxxxxxxxxxxxxxxx ???...
> HI Brandon,
> Iam also in the same problem of line drawing..
> I was trying this from very longback..
> Iam happy to know that u got a soluction for this line task.Can u plz post
the example which u done.Because it may helpfull for other like me.
> Thanks