Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » Zooming Rectangles
Zooming Rectangles [message #54827] Tue, 14 January 2003 11:43 Go to next message
Eclipse UserFriend
Originally posted by: g.wagenknecht.intershop.de

Hi!

When drawing a figure with #paintFigure with:

g.fillRectangle(r);
g.drawRectangle(r);

and then zooming the rectangle gets detached from the background. Don't know
why. But when using polygons and polylines this doesn't happen.

PointList pl = new PointList();
pl.addPoint(r.getBottomLeft());
pl.addPoint(r.getTopLeft());
pl.addPoint(r.getTopRight());
g.fillPolygon(pl);

pl = new PointList();
pl.addPoint(r.getBottomLeft());
pl.addPoint(r.getTopRight());
pl.addPoint(r.getBottomRight());
g.fillPolygon(pl);

pl = new PointList();
pl.addPoint(r.getBottomLeft());
pl.addPoint(r.getTopLeft());
pl.addPoint(r.getTopRight());
pl.addPoint(r.getBottomRight());
pl.addPoint(r.getBottomLeft());
g.drawPolyline(pl);

Is this by design or an implementation issue? Should I continue to use
polygones or rectangles?

Cu, Gunnar
Re: Zooming Rectangles [message #54854 is a reply to message #54827] Tue, 14 January 2003 12:37 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: g.wagenknecht.intershop.de

"Gunnar Wagenknecht" <g.wagenknecht@intershop.de> schrieb im Newsbeitrag
news:b00s7m$1p5$1@rogue.oti.com...
> Hi!
>
> When drawing a figure with #paintFigure with:

Same happens when painting ovals.

graphics.fillOval(center.x-3, center.y-1, 5, 3);
graphics.drawOval(center.x-3, center.y-1, 5, 3);

It seems that Graphics#fillOval is scaled different from Graphics#drawOval.
How can I paint my figures correctly?

Cu, Gunnar
Re: Zooming Rectangles [message #54908 is a reply to message #54854] Tue, 14 January 2003 15:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: noone.ibm.com

You are right, the way that Rectangles and polygons are drawn and filled is
inconsistent. This is done for a variety of reasons, and we haven't
completely decided on what the best approach is. (See Randy's post titled:
"Need help with ZOOM implementation" from 1/2/2002).

The reason that your rectangles and ovals are being clipped is due to the
way that draw and fill are currently implemented. To zoom a filled rectangle
or oval successfully, you must fill the rectangle and then subtract 1 from
the width and height of the rectangle, and then draw it.
Such as:
Rectangle rect = new Rectangle(0,0,100,100);
g.setBackgroundColor(ColorConstants.red);

g.fillRectangle(rect);

rect.height--;

rect.width--;

g.drawRectangle(rect);


> Hi!
>
> When drawing a figure with #paintFigure with:
>
> g.fillRectangle(r);
> g.drawRectangle(r);
>
> and then zooming the rectangle gets detached from the background. Don't
know
> why. But when using polygons and polylines this doesn't happen.
>
> PointList pl = new PointList();
> pl.addPoint(r.getBottomLeft());
> pl.addPoint(r.getTopLeft());
> pl.addPoint(r.getTopRight());
> g.fillPolygon(pl);
>
> pl = new PointList();
> pl.addPoint(r.getBottomLeft());
> pl.addPoint(r.getTopRight());
> pl.addPoint(r.getBottomRight());
> g.fillPolygon(pl);
>
> pl = new PointList();
> pl.addPoint(r.getBottomLeft());
> pl.addPoint(r.getTopLeft());
> pl.addPoint(r.getTopRight());
> pl.addPoint(r.getBottomRight());
> pl.addPoint(r.getBottomLeft());
> g.drawPolyline(pl);
>
> Is this by design or an implementation issue? Should I continue to use
> polygones or rectangles?
>
> Cu, Gunnar
>
>
"Gunnar Wagenknecht" <g.wagenknecht@intershop.de> wrote in message
news:b00vbl$415$1@rogue.oti.com...
>
> "Gunnar Wagenknecht" <g.wagenknecht@intershop.de> schrieb im Newsbeitrag
> news:b00s7m$1p5$1@rogue.oti.com...
> > Hi!
> >
> > When drawing a figure with #paintFigure with:
>
> Same happens when painting ovals.
>
> graphics.fillOval(center.x-3, center.y-1, 5, 3);
> graphics.drawOval(center.x-3, center.y-1, 5, 3);
>
> It seems that Graphics#fillOval is scaled different from
Graphics#drawOval.
> How can I paint my figures correctly?
>
> Cu, Gunnar
>
>
Re: Zooming Rectangles [message #58748 is a reply to message #54854] Tue, 28 January 2003 20:17 Go to previous message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

gunnar,
when you make those two calls for Rectangles, the top and left edges are
overlapping. The left edge of the drawRect(r) *overlaps* the fillRect(r).
However, the right edge of the drawRect(r) is *touching* the right edge (not
overlapping) of the fillRect(r). You can see this better using XOR for the
drawRect. Painting in the OS is inclusive (right and bottom edge) when
drawing, but exclusive for filling.

So, since the right and bottom edges are next to the filled region, you can
think of this as two lines that are next to each other. When you zoom in,
there is a gap. The solution is to use drawRect(r.getResized(-1, -1)),
which results in the rectangle exactly overlapping the fill region.

If you create a Figure and set it to be opaque with a LineBorder, you will
get exactly the right calls to draw/fill.

"Gunnar Wagenknecht" <g.wagenknecht@intershop.de> wrote in message
news:b00vbl$415$1@rogue.oti.com...
>
> "Gunnar Wagenknecht" <g.wagenknecht@intershop.de> schrieb im Newsbeitrag
> news:b00s7m$1p5$1@rogue.oti.com...
> > Hi!
> >
> > When drawing a figure with #paintFigure with:
>
> Same happens when painting ovals.
>
> graphics.fillOval(center.x-3, center.y-1, 5, 3);
> graphics.drawOval(center.x-3, center.y-1, 5, 3);
>
> It seems that Graphics#fillOval is scaled different from
Graphics#drawOval.
> How can I paint my figures correctly?
>
> Cu, Gunnar
>
>
Previous Topic:Updating figures from other threads
Next Topic:edit part figures
Goto Forum:
  


Current Time: Mon Dec 30 17:17:52 GMT 2024

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

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

Back to the top