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

Bug 313984

Summary: Figure#paintChildren(Graphics) Optimize clip
Product: [Tools] GEF Reporter: Alex Boyko <aboyko>
Component: GEF-Legacy Draw2dAssignee: Alexander Nyßen <nyssen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: ahunter.eclipse
Version: 3.6   
Target Milestone: 3.6.0 (Helios) RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
patch none

Description Alex Boyko CLA 2010-05-21 17:34:17 EDT
The optimize clip feature messes up border items in GMF. Wonder if we can just return figure bounds instead without intersecting them again with the parent's client area. Parent's client area under normal circumstances should be the parent's client area anyway.
Alexander, would you be ok removing the optimize clip case in Figure#paintChildren(Graphics)? It just wasn't there initially in the Figure#paintChildren(Graphics), hence not having it there is potentially less risky.
Comment 1 Alexander Nyßen CLA 2010-05-21 19:27:25 EDT
Yes. I think this should be ok, as paintClientArea() already sets a respective clipping rectangle on the graphics before passing it into paintChildren() this would not have to be done here again. I also agree that it would make it safer to not run into any further regressions, as the code would then pretty much be the same as prior to 3.6 in case no clipping strategy is set. 

I would then propose to change it into the following:

protected void paintChildren(Graphics graphics) {
		for (int i = 0; i < children.size(); i++) {
			IFigure child = (IFigure) children.get(i);
			if (child.isVisible()) {
				// determine clipping areas for child
				Rectangle[] clipping = null;
				if (clippingStrategy != null) {
					clipping = clippingStrategy.getClip(child);
				} else {
					// default clipping behavior is to clip at bounds
					clipping = new Rectangle[] { child.getBounds() };
				}
				// child may now paint inside the clipping areas
				for (int j = 0; j < clipping.length; j++) {
					if (clipping[j].intersects(graphics
							.getClip(Rectangle.SINGLETON))) {
						graphics.clipRect(clipping[j]);
						child.paint(graphics);
						graphics.restoreState();
					}
				}
			}
		}
	}
Comment 2 Alex Boyko CLA 2010-05-21 19:57:28 EDT
Great! Thank you, Alexander - the proposed fix looks good to me!
Comment 3 Alexander Nyßen CLA 2010-05-22 08:35:16 EDT
Anthony, are we good to go for RC2 with this?
Comment 4 Anthony Hunter CLA 2010-05-25 11:26:51 EDT
Alex or Alexander, Can you create a patch for this and commit to CVS? I can then run RC2 today.
Comment 5 Alex Boyko CLA 2010-05-25 11:38:22 EDT
I'll do it
Comment 6 Alex Boyko CLA 2010-05-25 11:54:51 EDT
Created attachment 169849 [details]
patch

The patch we agreed on
Comment 7 Alex Boyko CLA 2010-05-25 11:56:03 EDT
Delivered for 3.6 RC2