Home » Modeling » Graphiti » Collapse Feature: how to hide an element?
| | | |
Re: Collapse Feature: how to hide an element? [message #766942 is a reply to message #763167] |
Fri, 16 December 2011 17:45 |
Matteo Miraz Messages: 38 Registered: March 2011 |
Member |
|
|
Michael,
thanks for the reference to the bug. However, it seems to me that there is too little progress, and (as you suggested) I have to figure out another way to solve the problem.
I see two main possibilities:
1. (your way) delete the inner elements and save their location in the parent.
In this case, I have to save a lot of information, including the connectors, their bend points, and all the details of the inner elements. Additionally, if the inner element contains other elements (i.e., there are 2 level of nesting), I also have to save details of these elements. I fear that this way is really complex and bug-prone.
2. (buschcobolt's way) move the inner elements out of the visible area.
In this case, I simply need to move all the inner elements so that are outside the visible are, hence they are not visible from and selectable by the user. Additionally, I also have to hide all connections (this is easy, since connections have a visible property).
I'm following the second path, and I'm implementing the collapse as layout feature. This allows me also to solve the case of elements nested at several levels, because I only need to collapse them by invoking the feature recursively (indeed, this is only required to hide inner connectors).
Given your experience with graphiti, I'd like to ask for an additional comment... Is it a really bad way?
[Updated on: Fri, 16 December 2011 17:46] Report message to a moderator
|
|
| |
Re: Collapse Feature: how to hide an element? [message #767963 is a reply to message #767957] |
Mon, 19 December 2011 09:41 |
Matteo Miraz Messages: 38 Registered: March 2011 |
Member |
|
|
Hi,
I've done it, and it works! There is only an issue I'll discuss later in this post.
Here is how I did it. The container element has a property which pinpoints the current state (expanded / collapsed). According to this property, the layout behaves differently. My collapse feature just toggle the status and issues a layout of the element (using the standard feature calling).
If the element is expanded, it verifies if the right graphic elements are shown (i.e., the is a rectangle associated with the container shape, and the first 2 children of the elements are shapes for the line and the text, as shown in the standard graphiti tutorial).
If the element is collapsed, it verifies if the right graphic elements are shown (in my case, it is suffice to remove the rectangle, replace the line with an image, and move all the elements in the right position). When I collapse the container element:
(1) I store the current width and height, so I can correctly expand the element;
(2) I move all the contained shapes to the right and to the bottom, so I'm sure that I'm sure they are outside the collapsed container's bounds
(3) I hide all connectors (they have a visibility property).
I have to say that everything works really smoothly, but there is only an issue with selection. I have to say that I have some views to provide the user with a list of all model elements. If a user selects it, graphiti highlights the corresponding graphical element(s). However, it might happens that the user selects an hidden element: in this case, graphiti draws the selection highlights around an empty space (i.e., the location where the hidden element really is). However, I'm going to work on the selection behavior so to filter out those elements that are not visible.
Hope this helps...
|
|
| | |
Goto Forum:
Current Time: Thu Mar 28 15:05:52 GMT 2024
Powered by FUDForum. Page generated in 0.04430 seconds
|