Community
Participate
Working Groups
Build Identifier: 20100617-1415 In org.eclipse.gmf.runtime.diagram.ui.render.util.DiagramImageUtils.calculateImageRectangle(List<IGraphicalEditPart>, double, Dimension) there is the following code: if (figure instanceof IExpandableFigure) bounds = ((IExpandableFigure) figure).getExtendedBounds(); else bounds = figure.getBounds().getCopy(); translateTo(bounds, figure, printableLayer); For figure beeing a BorderedNodeFigure this goes through the first branch to get the bounds. After getting the bounds, it translates these bounds. During this method, the Rectangle gets modified (especially if the Figure is in a compartment) In the next call to the getClip(IFigure)-Method provided at https://bugs.eclipse.org/bugs/show_bug.cgi?id=319191 this wrong rectangle is returned, resulting in an wrongly clipped and therefore invisible figure. I think there are a few ways to fix this: 1) modify calculateImageRectange to bounds = ((IExpandableFigure)figure).getExtendedBounds().getCopy(); 2) Always return a copy in the getExtendedBounds()-Method of BorderedNodeFigure I don't know what is the proposed semantic of the getExtendedBound()-Method: should it return a modifiable Rectangle or not. Depending on this, Fix 1 or 2 should be prefered. The getBounds()-Method for IFigure specifies that the rectangle can be passed by reference and that callers may not modify this rectangle. The getExtendedBound() Method lacks such a comment. So I propose adding one and to modify calculateImageRectangle (see my Patch according to fix-1) For our rcp-editor, it happens when calling copy on a element in a compartment and afterwards clicking on the compartment. But I think this problem will always occur when calling calculateImageRectange. Reproducible: Always Steps to Reproduce: This problem always happens when adding a BorderedNodeFigure to a compartment and afterwards calling the DiagramImageUtils.calculateImageRectangle-Method. This Method is called e.g. when saving an image of the model or using copy-paste.
Created attachment 175252 [details] Patch according to fix 1 Of cause we should check if there are other methods using getExtendedBounds() and afterwards modifying the returned Rectangle (I did a quick check and it seems the other methods do not modify the rectangle at least for all plugins available in my local eclipse-installation). Furthermore the Javadoc-Comment could somewhat more exactly describe the method-functionality.
Anthony, I'm going to deliver this fix and update the java-doc for IExpandableFigure#getExtendedBounds(). It used to be internal and now public, so a java-doc comment would be useful for clients.
Delivered the contributed patch + Java-doc for IExpandableFigure#getExtendedBounds() for 2.3.1 and 2.4 (maintenance 1.4 and HEAD)