Skip to main content



      Home
Home » Eclipse Projects » GEF » [Draw2D] Jagged lines
[Draw2D] Jagged lines [message #79842] Sat, 17 May 2003 13:43 Go to next message
Eclipse UserFriend
Originally posted by: jpl.remotejava.com

Hello,

The first thing that strikes me after playing with the draw2d demo (#3)
on Linux is that the connection lines appear "jagged" when you drag nodes
around. A closer inspection (with Gimp's magnifying glass) reveals that the
lines are drawn with some overlap, i.e. there are such pixels that have
more
than two neighbors. It is easy to correct by hand (just erase some pixels
to make it look good), so I am not talking about the lack of antialiasing
here.

My question is, why is it so - is it a problem with GTK 2.2.1 or is the
pixelwise line rendering algorithm implemented in draw2d? Should I enter
a request for enhancement and if so, where?

Best regards -
Jan Ploski
Re: [Draw2D] Jagged lines [message #79871 is a reply to message #79842] Sat, 17 May 2003 14:48 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

This is the way GTK paint lines. It is not specific to draw2d. Maybe SWT
is using an API or setting that causes this?

"Jan Ploski" <jpl@remotejava.com> wrote in message
news:ba5sb5$bmu$1@rogue.oti.com...
> Hello,
>
> The first thing that strikes me after playing with the draw2d demo (#3)
> on Linux is that the connection lines appear "jagged" when you drag nodes
> around. A closer inspection (with Gimp's magnifying glass) reveals that
the
> lines are drawn with some overlap, i.e. there are such pixels that have
> more
> than two neighbors. It is easy to correct by hand (just erase some pixels
> to make it look good), so I am not talking about the lack of antialiasing
> here.
>
> My question is, why is it so - is it a problem with GTK 2.2.1 or is the
> pixelwise line rendering algorithm implemented in draw2d? Should I enter
> a request for enhancement and if so, where?
>
> Best regards -
> Jan Ploski
>
Re: [Draw2D] Jagged lines [message #79886 is a reply to message #79871] Sat, 17 May 2003 15:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jpl.remotejava.com

Randy Hudson wrote:

> This is the way GTK paint lines. It is not specific to draw2d. Maybe SWT
> is using an API or setting that causes this?

Hello Randy,

I just wrote a test in which I do the following in a Canvas:

for (int y = 200; y < 300; y += 7)
gc.drawLine(100, 100, 200, y);

All those lines look nice, with no "thicker" segments that appear in
draw2d.

Any clues?

Best regards -
Jan Ploski
Re: [Draw2D] Jagged lines [message #79916 is a reply to message #79886] Sun, 18 May 2003 14:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

Draw2d is double buffered, so you'll have to create a GC on an Image, paint
the line there, and then paint that Image to the canvas to do an equal
comparison.

"Jan Ploski" <jpl@remotejava.com> wrote in message
news:ba636i$esd$1@rogue.oti.com...
> Randy Hudson wrote:
>
> > This is the way GTK paint lines. It is not specific to draw2d. Maybe
SWT
> > is using an API or setting that causes this?
>
> Hello Randy,
>
> I just wrote a test in which I do the following in a Canvas:
>
> for (int y = 200; y < 300; y += 7)
> gc.drawLine(100, 100, 200, y);
>
> All those lines look nice, with no "thicker" segments that appear in
> draw2d.
>
> Any clues?
>
> Best regards -
> Jan Ploski
>
Re: [Draw2D] Jagged lines [message #79930 is a reply to message #79916] Sun, 18 May 2003 20:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jpl.remotejava.com

Randy Hudson wrote:

> Draw2d is double buffered, so you'll have to create a GC on an Image, paint
> the line there, and then paint that Image to the canvas to do an equal
> comparison.

Ok, this is my whole paint method now:

private void paint(PaintEvent event)
{
Display display = getDisplay();
Image img = new Image(display, getSize().x, getSize().y);
GC imgGC = new GC(img);
GC gc = event.gc;

Rectangle rect = getClientArea();
imgGC.setBackground(WHITE);
imgGC.setForeground(WHITE);
imgGC.fillRectangle(rect);
imgGC.setForeground(BLACK);
for (int y = 200; y < 300; y += 7)
imgGC.drawLine(100, 100, 200, y);

gc.drawImage(img, 0, 0);
imgGC.dispose();
img.dispose();
}

...the lines are still drawn nicely, not so in draw2d.
Is there anything else to try or should I enter a bug report?

-JPL
Re: [Draw2D] Jagged lines [message #79944 is a reply to message #79930] Sun, 18 May 2003 21:22 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

There's still one more difference ;-). In draw2d, we don't use the GC from
the PaintEvent, so create your own GC in the paint callback. See the change
below.

Can you also post a picture of the problem?

"Jan Ploski" <jpl@remotejava.com> wrote in message
news:ba96uh$4v9$1@rogue.oti.com...
> Randy Hudson wrote:
>
> > Draw2d is double buffered, so you'll have to create a GC on an Image,
paint
> > the line there, and then paint that Image to the canvas to do an equal
> > comparison.
>
> Ok, this is my whole paint method now:
>
> private void paint(PaintEvent event)
> {
> Display display = getDisplay();
> Image img = new Image(display, getSize().x, getSize().y);
> GC imgGC = new GC(img);
> GC gc = event.gc;

change to:
GC gc = new GC((Control)event.widget);
>
> Rectangle rect = getClientArea();
> imgGC.setBackground(WHITE);
> imgGC.setForeground(WHITE);
> imgGC.fillRectangle(rect);
> imgGC.setForeground(BLACK);
> for (int y = 200; y < 300; y += 7)
> imgGC.drawLine(100, 100, 200, y);
>
> gc.drawImage(img, 0, 0);
> imgGC.dispose();
> img.dispose();
> }
>
> ..the lines are still drawn nicely, not so in draw2d.
> Is there anything else to try or should I enter a bug report?
>
> -JPL
>
Re: [Draw2D] Jagged lines [message #79972 is a reply to message #79944] Mon, 19 May 2003 03:30 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jpl.remotejava.com

Randy Hudson wrote:

> There's still one more difference ;-). In draw2d, we don't use the GC from
> the PaintEvent, so create your own GC in the paint callback. See the change
> below.

> > GC gc = event.gc;
> change to:
> GC gc = new GC((Control)event.widget);

Done - no visible effect, though.

> Can you also post a picture of the problem?

Ok, this is how the draw2d app looks after start (nice so far because
xdist==ydist):

http://remotejava.dyndns.org/draw2d/draw2d_init.png

Now I have moved the second rectangle a bit (it becomes ugly):

http://remotejava.dyndns.org/draw2d/draw2d_ugly1.png
http://remotejava.dyndns.org/draw2d/draw2d_ugly2.png

Here is what my GTK drawing test looks like (no jagged lines):

http://remotejava.dyndns.org/draw2d/gtktest.png

Best regards -
Jan Ploski
Re: [Draw2D] Jagged lines [message #79986 is a reply to message #79930] Mon, 19 May 2003 09:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: none.us.ibm.com

I apologize, there is yet another difference. See below. I'm at home now
and do not have GTK available.

"Jan Ploski" <jpl@remotejava.com> wrote in message
news:ba96uh$4v9$1@rogue.oti.com...
> Randy Hudson wrote:
>
> > Draw2d is double buffered, so you'll have to create a GC on an Image,
paint
> > the line there, and then paint that Image to the canvas to do an equal
> > comparison.
>
> Ok, this is my whole paint method now:
>
> private void paint(PaintEvent event)
> {
> Display display = getDisplay();
> Image img = new Image(display, getSize().x, getSize().y);
> GC imgGC = new GC(img);
> GC gc = event.gc;
>
> Rectangle rect = getClientArea();
> imgGC.setBackground(WHITE);
> imgGC.setForeground(WHITE);
> imgGC.fillRectangle(rect);
> imgGC.setForeground(BLACK);
> for (int y = 200; y < 300; y += 7)
> imgGC.drawLine(100, 100, 200, y);
changeto--> imgGC.drawPolyline(new int[] {100, 100, 200, y});
>
> gc.drawImage(img, 0, 0);
> imgGC.dispose();
> img.dispose();
> }
>
> ..the lines are still drawn nicely, not so in draw2d.
> Is there anything else to try or should I enter a bug report?
>
> -JPL
>
Re: [Draw2D] Jagged lines [message #80029 is a reply to message #79986] Mon, 19 May 2003 10:43 Go to previous message
Eclipse UserFriend
Originally posted by: jpl.remotejava.com

Randy Hudson wrote:

> I apologize, there is yet another difference. See below. I'm at home now
> and do not have GTK available.

> > imgGC.drawLine(100, 100, 200, y);
> changeto--> imgGC.drawPolyline(new int[] {100, 100, 200, y});

Randy,

Nothing changed in the output with this modification.

-JPL
Previous Topic:Copy & Paste to Windows clipboard
Next Topic:moving an editpart
Goto Forum:
  


Current Time: Tue Jul 22 14:45:11 EDT 2025

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

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

Back to the top