Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326730

Summary: Refresh issues with IGraphicsAlgorithmRenderer
Product: [Modeling] Graphiti Reporter: Romain Raugi <romain.raugi>
Component: CoreAssignee: Project Inbox <graphiti-inbox>
Status: CLOSED WORKSFORME QA Contact:
Severity: major    
Priority: P3 CC: michael.wenz, romain.raugi
Version: 0.7.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
The tutorial modified to add a IGraphcsAlgorithmRenderer
none
Example implementation of an IGraphicsAlgorithmRenderer none

Description Romain Raugi CLA 2010-09-30 23:53:13 EDT
Build Identifier: 20100617-1415

Tested with Graphiti 0.7.0RC1 and RC2.

The synchronization between the undo/redo and what is displayed in the diagram is not consistent when using custom renderers.

Reproducible: Always

Steps to Reproduce:
1. Download the modified attached tutorial.
2. Run an Eclipse with this modified tutorial
3. Create a new tutorial diagram
4. Create an EEnum, it is renderered using a IGraphicsAlgorithmRenderer
5. Move it several times
6. Play with the undo/redo. You will sometimes observe the figure appearing twice, or more general refresh issues.
Comment 1 Romain Raugi CLA 2010-09-30 23:54:58 EDT
Created attachment 180007 [details]
The tutorial modified to add a IGraphcsAlgorithmRenderer
Comment 2 Michael Wenz CLA 2010-10-01 04:07:42 EDT
I was able to reproduce this when more than one of the EEnums are on the screen
Comment 3 Michael Wenz CLA 2010-10-01 04:34:29 EDT
Created attachment 180025 [details]
Example implementation of an IGraphicsAlgorithmRenderer

It seems as if your renderer does not correctly update the diagram. In certain situations old remains stay on the screen.

Attached is a CanFigure which is an example of an implementation of an  IGraphicsAlgorithmRenderer. Using this class as a renderer for the EEnum there are no refresh problems.

Could you have a look into this example to see if that solves this issue? (I'm not the hard-core GEF guy...)
Comment 4 Michael Wenz CLA 2010-10-01 04:36:51 EDT
I forgot to mention that in your renderer factory you should check the ID of the passed graphics algorithm:
if ("EEnum".equals(rendererContext.getPlatformGraphicsAlgorithm().getId())) {
	PictogramElement pe = rendererContext.getGraphicsAlgorithm().getPictogramElement();
	EObject modelObj = (EObject) rendererContext.getMappingProvider().getBusinessObjectForPictogramElement(pe);
	if (EcorePackage.eINSTANCE.getEObject().isInstance(modelObj)) {
		return new MyRenderer(rendererContext);
	}
}
return null;
Comment 5 Romain Raugi CLA 2010-10-01 09:20:27 EDT
Hi Michael,

The cause of the issue in my renderer is the overridden getBounds() method. In a IGraphicsAlgorithmRenderer, As far as I understand, we should not dynamically compute the bounds according to the GraphicsAlgorithm bounds stored in the notational model. Graphiti is responible of setting the bounds of the renderer.

This sample helped me a lot and remove an embarrassing issue.

Thanks,

Romain
Comment 6 Michael Wenz CLA 2010-10-05 07:51:33 EDT
Issue solved by providing a sample implementation for a custom renderer
Comment 7 Michael Wenz CLA 2010-10-07 03:11:50 EDT
No further steps necessary