How to draw a line? [message #210771] |
Mon, 06 March 2006 05:59 |
Eclipse User |
|
|
|
Originally posted by: brandonchen.realtek.com.tw
I want to draw a line. Here are the problems I met.
1. The line supposed to be no connections to any other figures. So it seems
that I should not try connection editpart, anchors...
2. The line should have no constraint on it. What am I suppoed to do if the
constraint returns null?
3. If the line has a constraint on it, I can draw the line from left-top to
right-bottom. However, drawing the line from its constraint has some
problems. If I want to drag a line from (left-top/right-bottom) to
(left-bottom / right-top), I would not be able to do so. The constraint is
restricted to draw once the constraint area is zero.
Please give some ideas about how to draw a line. What policy, editpart and
class I shoudl use? Appreciated for any reply. Thanks
Brandon
|
|
|
|
Re: How to draw a line? [message #211115 is a reply to message #210859] |
Wed, 08 March 2006 09:21 |
Eclipse User |
|
|
|
Originally posted by: brandonchen.realtek.com.tw
Appreciated for reply. Yes, I want to create a line simply in space.
And the user can drag from the head and end point of the line to change
the length and direction.
I just implemented the idea you gave and it worked well. And there are some
other new questions now.
1. Is it possible to change the line width for XYAnchor connection?
2. When I use Chopbox(figure), the feedback works well. But when
I use XYAnchor(Point) instead, there is no feedback of the line after
choosing the
source point. Should I override some function such as
showTargetConnectionFeedback()
to enable the feedback??
3. Is it possible to move the line with whole shape? Right now I have to
move head and end
point seperately to move the line. I can not move the whole line.
Thanks..
Brandon
Do you mean that I still need to create two nodes as the head and end point
of the line? And I should add source and target
----- Original Message -----
From: "Steven Shaw" <steveshaw@ca.ibm.com>
Newsgroups: eclipse.tools.gef
Sent: Monday, March 06, 2006 11:28 PM
Subject: Re: How to draw a line?
> The issue is that you want to create a line seemingly "in space" on your
> diagram?
>
> In fact, this can be done but the ends would still be "attached". The
> anchor could be an XYAnchor and you would be "attaching" to your
> DiagramEditPart...You'd have to implement something similar to what
> NodeFigure has done to retrieve an anchor in the figure for the
> DiagramEditPart.
>
> -Steve
>
> "Brandon" <brandonchen@realtek.com.tw> wrote in message
> news:dugj47$njm$1@eclipse.org...
> > I want to draw a line. Here are the problems I met.
> >
> > 1. The line supposed to be no connections to any other figures. So it
> seems
> > that I should not try connection editpart, anchors...
> > 2. The line should have no constraint on it. What am I suppoed to do if
> the
> > constraint returns null?
> > 3. If the line has a constraint on it, I can draw the line from
left-top
> to
> > right-bottom. However, drawing the line from its constraint has some
> > problems. If I want to drag a line from (left-top/right-bottom) to
> > (left-bottom / right-top), I would not be able to do so. The constraint
is
> > restricted to draw once the constraint area is zero.
> >
> > Please give some ideas about how to draw a line. What policy, editpart
and
> > class I shoudl use? Appreciated for any reply. Thanks
> >
> >
> > Brandon
> >
> >
>
>
|
|
|
Re: How to draw a line? [message #211920 is a reply to message #211115] |
Thu, 16 March 2006 13:33 |
Eclipse User |
|
|
|
Originally posted by: ananth.exorindia.com
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
|
|
|
Re: How to draw a line? [message #212019 is a reply to message #211920] |
Fri, 17 March 2006 07:58 |
Eclipse User |
|
|
|
Originally posted by: brandonchen.realtek.com.tw
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@exorindia.com> ???
news:26044770.1142516032835.JavaMail.root@cp1.javalobby.org ???...
> 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
|
|
|
Powered by
FUDForum. Page generated in 0.03588 seconds