| Summary: | ScaledGraphics should not nest another ScaledGraphics | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Chris Lee <eclipse> |
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | nyssen |
| Version: | 3.2 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
That's an interesting idea and I think it involves a few more checks on the state of the ScaledGraphics that is passed in. We would have to create a static factory method instead of changing the behavior of the existing constructor. Of course, clients could always check if a Graphics is a ScaledGraphics already, and avoid constructing the new one. That's our current workaround, except it involves doing this any place where a ScaledGraphics would be constructed - quite a bit cumbersome. If you are doing that test more than once, just create a utility that does it for you:
public static ScaledGraphics ScaledGraphicsFactory.create(Graphics g) {
...
}
As Draw2d is only maintained and there is a documented workaround for this (clients can make sure to not pass in a ScaledGraphics to the ScaledGraphics constructor, resolving this as WONTFIX. |
The problem is when we have a scaled layer containing (eventually) another scaled layer. The first one applies a scale of 15, the next one applies a scale of 1/15. When drawing almost anything, this dual transform renders things like..well..crap. Rather than maintaining a nesting of ScaledGraphics within another ScaledGraphics, it should use the Graphics inside the passed in ScaledGraphics (normally an SWTGraphics), and just initialize its scale to the passed in scale. I think something like this would solve the problem: public ScaledGraphics (Graphics g) { if (g instanceof ScaledGraphics) { sG = (ScaledGraphics)g; graphics = sG.graphics; setScale (sG.zoom); localFont = sG.localFont; localLineWidth = sG.localLineWidth; } else { graphics = g; localFont = g.getFont (); localLineWidth = g.getLineWidth (); } }