Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 176984

Summary: Rendering Problems
Product: [Tools] GEF Reporter: Manuel Selva <manuel.selva>
Component: GEF-Legacy Draw2dAssignee: gef-inbox <gef-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3    
Version: 3.2.1   
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:
Attachments:
Description Flags
Sample to reproduce the bug
none
Sample class reproducing the bug with an extended rectangle figure none

Description Manuel Selva CLA 2007-03-12 09:46:52 EDT
Build ID: M20060629-1905

Steps To Reproduce:
1. Run the attached sample as SWT application
2. Move the scrollbar thumb close to the end
3. Scroll using the left and right arrow buttons and you can see the problem


More information:
Comment 1 Manuel Selva CLA 2007-03-12 09:47:51 EDT
Created attachment 60549 [details]
Sample to reproduce the bug
Comment 2 Randy Hudson CLA 2007-03-12 10:12:45 EDT
Figures that large are not supported. The OS can not paint such large rectangles, so you're seeing overflow errors.
Comment 3 Manuel Selva CLA 2007-03-12 10:37:09 EDT
(In reply to comment #2)
> Figures that large are not supported. The OS can not paint such large
> rectangles, so you're seeing overflow errors.
> 

Does it mean that SWT doesn't support it  and does it mean that i can't have a root figure (a Panel) with a background color and an XYLayoutManager exceding a given size ?
Comment 4 Randy Hudson CLA 2007-03-12 11:12:15 EDT
It means that if you want to fill a rectangle, don't fill one that is larger than the clipping area that is being painted.  So, you'll need a special rectangle figure that doesn't paint so far outside the Graphics.getClip().

Instead of:
graphics.fillRectangle(getBounds());
do:
Rectangle rect = getBounds().getCopy();
rect.clip(graphics.getClip());
graphics.fillRectangle(rect);

Or maybe you could extend SWTGraphics to do the clipping in general?
Comment 5 Manuel Selva CLA 2007-03-12 11:44:47 EDT
Thanks for your answer,


I tried the following overriding of RectangleFigure

public void fillShape(Graphics g) {

    	

        Rectangle rect = g.getClip(new Rectangle());

        rect.intersect(getBounds());

        g.fillRectangle(rect);

}

but still have rendering problems



Comment 6 Manuel Selva CLA 2007-03-13 03:50:04 EDT
Created attachment 60649 [details]
Sample class reproducing the bug with an extended rectangle figure

In this sample the method fill shape of rectangle is overrided to only fill the intersection between the figure bounds and the graphics clipping.

Using this solution doesn't work since there is always rendering problems when scrolling to the right with the thumb and then coming back to the left with the left arrow of the scroll bar.

Is my fill method wrong or is there any problem inside draw2d graphics or inside  figureCanvas.scrollToX ?

Thnaks

Manuel Selva
Comment 7 Manuel Selva CLA 2007-03-13 08:04:56 EDT
(In reply to comment #2)
> Figures that large are not supported. The OS can not paint such large
> rectangles, so you're seeing overflow errors.
> 

Where is exactly the limitation of "large figure" ?
Comment 8 Randy Hudson CLA 2007-03-13 10:08:58 EDT
The limitation I'm guessing is in GDI.  I think that it combines two 16-bit integers into one 32-bit argument, but I'm just speculating.  That would mean, anything larger than 32,000 (unsigned) or 16,000 (signed) wouldn't draw properly.

And, this is different on each OS. SWT gives you the platform limitations, it doesn't circumvent them. Nor does draw2d.

The snippet you've created is helpful, but it would help more if you set the viewport to the location that is failing, so that no manual interaction is required to debug the issue.

FYI, I am no longer employed to work on GEF, but I attempt to contribute in my "personal" time (e.g., instead of playing foosball :-), or as my new job occasionally requires.
Comment 9 Randy Hudson CLA 2007-03-13 10:09:32 EDT
Manual, could you create a FAQ entry on this for GEF?
Comment 10 Randy Hudson CLA 2007-03-13 10:09:59 EDT
I meant "Manuel"
Comment 11 Manuel Selva CLA 2007-03-13 10:32:04 EDT
(In reply to comment #9)
> Manual, could you create a FAQ entry on this for GEF?
> 
Thanks for your quick answer Randy (instead of playing football).

Yes i'll create an entry in the GEF FAQ. But still have one question: my Snippet is useful ? Useful to see the limitation but not to know how to workaround it ... and i need to find a workaround! Does the workaround consisting in paint the intersection between my rectangle and the graphics clipping solve the problem on your computer ? It doesn't solve it on my .. when is scroll using the left arrow i got a lot of "vertical lines" not painted at all in my figure. It seems that Draw2D scrolling and Draw2D SWTGraphics have some strange behavior. For example replacing canvas.redraw(expose) by canvas.redraw() in the scrollToX method of FigureCanvas class fix this bug (I know that is not THE solution but may be can help to understand what happened).

Manuel
Comment 12 Manuel Selva CLA 2007-03-16 06:06:58 EDT
Hi all,

After some research i am always wondering how to solve this bug. The solution consisting in only draw the "visible part of the rectangle" (intersection with clipping) doesn't work. It seems that there is a lot of 16 or 32 bit limitations inside SWT and as a consequence inside draw2d. For example in my sample application (see last attachement) the 16/32 bits limitations is avoided for the gc.fillRectangle graphical call but this limitation must remain somewhere in the apps since the rendering is bad. May be this come from Transform transform field inside SWTGraphics class ... ? I am right ?

I really appreciate a work around for this but it seems to be impossible to have   a draw2d application which root figure's bounds exceed a certain XX size. Has anybody encountered the same problem ??

Thanks

Manuel
Comment 13 Pratik Shah CLA 2007-03-16 13:21:39 EDT
Yes, on the newsgroup, there have been a couple of other cases of people running into rendering problems for very large diagrams.

You can create an SWT-only snippet and ask on the SWT newsgroup if you want to pursue this further.  But like Randy suggested, you might be hitting the platform limitations here.
Comment 14 Manuel Selva CLA 2007-03-21 11:10:27 EDT
Several month ago i posted a bug concerning large figure rendering problems. After several discussions SWT team (Steve Northover) told that there is a 16 bit limitations for graphical calls on X plateform. OK. But this time the bug i am having is also visible on Windows and can't be reproduced only using SWT. 
Have you got any idea to reproduce it using only SWT and before this, have you reproduce it on your platform ?

Thanks

Manuel Selva

Comment 15 Manuel Selva CLA 2007-03-23 04:03:34 EDT
(In reply to comment #9)
> Manual, could you create a FAQ entry on this for GEF?
> 

Entry created in GEF FAQ.