Redraw artifacts for JGoGridView embedded in SWT

I’m reusing a drag-and-drop “process builder” component built from JGo, in a new SWT application. This component has a palette with predefined polygon shapes, and a canvas that those shapes can be dragged onto, and then connected via arrows. I’m embedding the JGO component via the SWT_AWT bridge, in a Panel object. I’m using JDK 1.6.

Each polygon has a text label. When I move a polygon around on the canvas, I see redraw artifacts from the previous locations for the text label.

Has anybody else seen this? Any solutions? I’ve tried the code from the Albireo project, but when I used their Composite class I lost drag-and-drop capability.


Redraw artifacts are typically the result of the bounding rectangle of the JGoObject not be calculated correctly. If a piece of your text label is not contained within the bounding rectangle, that could cause the behavior you describe.

I'm assuming your code works correctly when you run in a native Swing environment, but that somehow when running via the SWT_AWT bridge, you're seeing the artifacts. I'm not sure how or why the bridge causes this behavior, but a workaround might be to override getBoundingRect() in your node class to return a slightly larger bounding rectangle.

Thanks for the help! Yes, the code works correctly in a native Swing environment. I’ve tried enlarging the bounding rectangle, but that doesn’t seem to help.

I’m seeing the following message show up in the Eclipse console just after the embedded Swing component loads:

“Cannot measure text until a JGoView exists and is part of a visible window”

Correction: your suggested fix does appear to work. It wasn’t showing up due to some legacy code that initialized the bounding rectangle size.