Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 313984 - Figure#paintChildren(Graphics) Optimize clip
Summary: Figure#paintChildren(Graphics) Optimize clip
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy Draw2d (show other bugs)
Version: 3.6   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.6.0 (Helios) RC2   Edit
Assignee: Alexander Nyßen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-21 17:34 EDT by Alex Boyko CLA
Modified: 2010-05-25 11:56 EDT (History)
1 user (show)

See Also:


Attachments
patch (1.18 KB, patch)
2010-05-25 11:54 EDT, Alex Boyko CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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