Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » How to draw a Polyline across Figure
How to draw a Polyline across Figure [message #64533] Wed, 12 February 2003 14:51 Go to next message
Dinesh Varadharajan is currently offline Dinesh VaradharajanFriend
Messages: 26
Registered: July 2009
Junior Member
Hi,
I need to draw a line across a figure. I used polyline but I was not able to
find the location of the figure in the clientarea. I need to draw a sort of
table inside the figure where in the user can drop other figures.

Any inputs.
Thanks in advance,
Dinesh
Re: How to draw a Polyline across Figure [message #64580 is a reply to message #64533] Wed, 12 February 2003 15:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Client area is the region in which children figures are placed. If you are
painting the actual parent figure itself, you should use it's bounds,
cropped by its insets. Most of the time these two Rectangle will be the
same, but if your figure uses local coordinates, they are different.

protected void paintFigure(Graphics g) {
Rectangle r = getBounds().getCropped(getInsets());
//Draw a plus sign inside the figure.
g.drawLine(r.getLeft(), r.getRight());
g.drawLine(r.getTop(), r.getBottom());
}

"Dinesh Varadharajan" <dvaradharajan@selectica.com> wrote in message
news:b2dldl$t94$1@rogue.oti.com...
> Hi,
> I need to draw a line across a figure. I used polyline but I was not able
to
> find the location of the figure in the clientarea. I need to draw a sort
of
> table inside the figure where in the user can drop other figures.
>
> Any inputs.
> Thanks in advance,
> Dinesh
>
>
Re: How to draw a Polyline across Figure [message #64603 is a reply to message #64580] Thu, 13 February 2003 04:15 Go to previous messageGo to next message
Dinesh Varadharajan is currently offline Dinesh VaradharajanFriend
Messages: 26
Registered: July 2009
Junior Member
Randy,
Thanks for the reply. I am drawing the line inside Figure. It doesnt have a
method drawline.

My code is
IFigure fig = new Figure();

fig.setOpaque(true);

fig.setBackgroundColor(ColorConstants.lightGray);

fig.setLayoutManager(new FreeformLayout());

Polyline line=new Polyline(); //This is the line I like to draw inside the
figure

line.setParent(fig);


Rectangle r = fig.getBounds().getCropped(fig.getInsets());


line.setEndpoints(r.getLeft(),r.getRight());

line.setForegroundColor(ColorConstants.black);

line.setLineWidth(200);

line.setFill(true);

line.setLayoutManager(new FreeformLayout());

Thanks,
Dinesh

"Randy Hudson" <none@us.ibm.com> wrote in message
news:b2dogr$11a$1@rogue.oti.com...
> Client area is the region in which children figures are placed. If you
are
> painting the actual parent figure itself, you should use it's bounds,
> cropped by its insets. Most of the time these two Rectangle will be the
> same, but if your figure uses local coordinates, they are different.
>
> protected void paintFigure(Graphics g) {
> Rectangle r = getBounds().getCropped(getInsets());
> //Draw a plus sign inside the figure.
> g.drawLine(r.getLeft(), r.getRight());
> g.drawLine(r.getTop(), r.getBottom());
> }
>
> "Dinesh Varadharajan" <dvaradharajan@selectica.com> wrote in message
> news:b2dldl$t94$1@rogue.oti.com...
> > Hi,
> > I need to draw a line across a figure. I used polyline but I was not
able
> to
> > find the location of the figure in the clientarea. I need to draw a sort
> of
> > table inside the figure where in the user can drop other figures.
> >
> > Any inputs.
> > Thanks in advance,
> > Dinesh
> >
> >
>
>
Working well >> Howto draw a Polyline across Figure [message #64625 is a reply to message #64603] Thu, 13 February 2003 05:24 Go to previous message
Dinesh Varadharajan is currently offline Dinesh VaradharajanFriend
Messages: 26
Registered: July 2009
Junior Member
Randy,

I got it working now. I override the figure class and now it is working.

Thanks,
Dinesh
"Dinesh Varadharajan" <dvaradharajan@selectica.com> wrote in message
news:b2f4gc$15d$1@rogue.oti.com...
> Randy,
> Thanks for the reply. I am drawing the line inside Figure. It doesnt have
a
> method drawline.
>
> My code is
> IFigure fig = new Figure();
>
> fig.setOpaque(true);
>
> fig.setBackgroundColor(ColorConstants.lightGray);
>
> fig.setLayoutManager(new FreeformLayout());
>
> Polyline line=new Polyline(); //This is the line I like to draw inside
the
> figure
>
> line.setParent(fig);
>
>
> Rectangle r = fig.getBounds().getCropped(fig.getInsets());
>
>
> line.setEndpoints(r.getLeft(),r.getRight());
>
> line.setForegroundColor(ColorConstants.black);
>
> line.setLineWidth(200);
>
> line.setFill(true);
>
> line.setLayoutManager(new FreeformLayout());
>
> Thanks,
> Dinesh
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:b2dogr$11a$1@rogue.oti.com...
> > Client area is the region in which children figures are placed. If you
> are
> > painting the actual parent figure itself, you should use it's bounds,
> > cropped by its insets. Most of the time these two Rectangle will be the
> > same, but if your figure uses local coordinates, they are different.
> >
> > protected void paintFigure(Graphics g) {
> > Rectangle r = getBounds().getCropped(getInsets());
> > //Draw a plus sign inside the figure.
> > g.drawLine(r.getLeft(), r.getRight());
> > g.drawLine(r.getTop(), r.getBottom());
> > }
> >
> > "Dinesh Varadharajan" <dvaradharajan@selectica.com> wrote in message
> > news:b2dldl$t94$1@rogue.oti.com...
> > > Hi,
> > > I need to draw a line across a figure. I used polyline but I was not
> able
> > to
> > > find the location of the figure in the clientarea. I need to draw a
sort
> > of
> > > table inside the figure where in the user can drop other figures.
> > >
> > > Any inputs.
> > > Thanks in advance,
> > > Dinesh
> > >
> > >
> >
> >
>
>
Previous Topic:Image handles and draw2d exception
Next Topic:Plugin classloader dilemma
Goto Forum:
  


Current Time: Thu Dec 26 12:48:59 GMT 2024

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

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

Back to the top