|Wrong Figure order for PictogramElements [message #1755630]
|Mon, 06 March 2017 11:56
| Thomas Thonhofer
Registered: July 2013
I have a problem with changing the order in which Graphiti Shapes are drawn. I suspect it is a bug in the framework, but maybe its also my mistake. In case there is already a bug entry for this, I am sorry, I couldn't find one.
In my diagram there can be multiple overlapping shapes. I have a feature which should move a shape to the front, so it is completly visible and all overlapping shapes are shown behind. To achieve this I use the sendToFront(Shape shape) method in PeServiceImpl, which simply moves the shape to the end of the list of the diagrams children. This doesn't work the way I want it to, the shape is moved in front of some other shapes, but not completly to the front.
After some debugging I found waht I believe is the reason for this behaviour: After changing the order of the diagrams children, next time the diagrams editpart is refreshed, the order of the editpart children is updated in the method refreshChildren() in the class AbstractEditPart. For all editparts which need to be reordered it calls the method reorderChild(EditPart editpart, int index). This method then removes the draw2d figure and adds a new one using the index of the moved editpart. This works fine if there is an editpart for each figure and vice versa, but with Graphiti, decorators have a figure but no editpart. As I am using decorators for some of my shapes, which are added to the diagram, this means that there are more figures than editparts among the diagrams children, which means that inserting a new figure at the index of the last editpart, does not insert it at the last position. As far as I can tell, this leads to the inconsistent drawing order of my shapes.
I created a workaround where I sort the figures manually. This is an ugly solution and rather unreliable, but so far it is the best I could come up with. Any ideas for a better approach? Is this behaviour a bug or am I missing something?
Powered by FUDForum
. Page generated in 0.02756 seconds