| Summary: | Performance - Figure calls restoreState unnecessarily | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Randy Hudson <hudsonr> |
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED WONTFIX | QA Contact: | |
| Severity: | trivial | ||
| Priority: | P3 | CC: | nyssen |
| Version: | 3.3 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Randy Hudson
There are two occurrences of this kind within Figure#paintClientArea. However, if I remove the second call, in both cases, the circuit figure in the GEF logic example does not render correctly any more. (In reply to comment #1) > There are two occurrences of this kind within Figure#paintClientArea. However, > if I remove the second call, in both cases, the circuit figure in the GEF logic > example does not render correctly any more. This is caused because CircuitFigure uses local coordinates. Within paintClientArea, only the second call clears the translation of the graphics that has been set directly before pushing the state. graphics.translate(getBounds().x + getInsets().left, getBounds().y + getInsets().top); if (!optimizeClip) graphics.clipRect(getClientArea(PRIVATE_RECT)); graphics.pushState(); paintChildren(graphics); graphics.popState(); graphics.restoreState(); If we are thus going to remove the second line in the two cases, we will have to add a restoreState() after the call to painClientArea() within paint as follows:
graphics.pushState();
try {
paintFigure(graphics);
graphics.restoreState();
paintClientArea(graphics);
graphics.restoreState(); // was not here before
paintBorder(graphics);
} finally {
graphics.popState();
}
As such the number of calls to restoreState will be exactly the same. However, I would tend to do so, because the code will become a bit clearer.
But, changing this would be an API change, as the javadoc of paintClientArea currently states that should leave the graphics in its initial state upon returning. Resolving as wontfix because of this. |