Home » Eclipse Projects » GEF » [Draw2D] Jagged lines
[Draw2D] Jagged lines [message #79842] |
Sat, 17 May 2003 13:43  |
Eclipse User |
|
|
|
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 #79930 is a reply to message #79916] |
Sun, 18 May 2003 20:02   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #79986 is a reply to message #79930] |
Mon, 19 May 2003 09:20   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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
|
|
|
Goto Forum:
Current Time: Tue Jul 22 14:45:11 EDT 2025
Powered by FUDForum. Page generated in 0.04465 seconds
|