| Summary: | Clipping Error | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Sven Wende <s.wende> |
| Component: | GEF-Legacy Draw2d | Assignee: | Alexander Nyßen <nyssen> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | nyssen |
| Version: | 3.4 | ||
| Target Milestone: | 3.7.1 (Indigo) M6 | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
Yes, this seems to be the case. Especially as the former implementation (reversion 1.29) was implemented as follows:
public void intersect(Rectangle rect) {
left = Math.max(left, rect.x);
rt = Math.min(rt, rect.right());
top = Math.max(top, rect.y);
botm = Math.min(botm, rect.bottom());
if (rt < left || botm < top) {
rt = left - 1;//Use negative size to ensure ceiling function doesn't add a pixel
botm = top - 1;
}
}
However, I am wondering why left and bottom are handled in the same if clause. Wouldn't it be appropriate to handle them individually? I will investigate...
> However, I am wondering why left and bottom are handled in the same if clause.
> Wouldn't it be appropriate to handle them individually? I will investigate...
Well, I suppose that doesn't matter, as the rectangle is empty anyway in case it is empty "in one direction".
> However, I am wondering why left and bottom are handled in the same if clause.
> Wouldn't it be appropriate to handle them individually? I will investigate...
Well, I suppose that doesn't matter, as the rectangle is empty anyway in case it is empty "in one direction".
(In reply to comment #1) > Yes, this seems to be the case. Especially as the former implementation > (reversion 1.29) was implemented as follows: > > public void intersect(Rectangle rect) { > left = Math.max(left, rect.x); > rt = Math.min(rt, rect.right()); > top = Math.max(top, rect.y); > botm = Math.min(botm, rect.bottom()); > if (rt < left || botm < top) { > rt = left - 1;//Use negative size to ensure ceiling function > doesn't add a pixel > botm = top - 1; > } > } > So actually, it will have to be as follows: public void intersect(int left, int top, final int right, final int bottom) { this.left = Math.max(this.left, left); this.right = Math.min(this.right, right); this.top = Math.max(this.top, top); this.bottom = Math.min(this.bottom, bottom); // use left/top -1 to ensure ceiling function doesn't add a pixel if (this.right < this.left || this.bottom < this.top) { this.right = this.left - 1; this.bottom = this.top - 1; } } Committed changes to cvs HEAD (3.7M6). Resolving as fixed. |
Build ID: N/A Steps To Reproduce: I think there is a bug in class org.eclipse.draw2d.SWTGraphics.RectangleClipping which causes strange drawing behaviour with child figures that clip the drawing area using graphics.clipRect(..). This is the current code: public void intersect(int left, int top, final int right, final int bottom) { this.left = Math.max(this.left, left); this.right = Math.min(this.right, right); this.top = Math.max(this.top, top); this.bottom = Math.min(this.bottom, bottom); if (right < left || bottom < top) { //width and height of -1 to avoid ceiling function from re-adding a pixel. this.right = left - 1; this.bottom = top - 1; } } This is the code that was probably intended and should work: public void intersect(int left, int top, final int right, final int bottom) { this.left = Math.max(this.left, left); this.right = Math.min(this.right, right); this.top = Math.max(this.top, top); this.bottom = Math.min(this.bottom, bottom); if (this.right < left || this.bottom < top) { //width and height of -1 to avoid ceiling function from re-adding a pixel. this.right = left - 1; this.bottom = top - 1; } } More information: