Bug 345179 - [diagram] Support auto layout action
Summary: [diagram] Support auto layout action
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Shenxue Zhou CLA
QA Contact:
URL:
Whiteboard:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2011-05-09 14:18 EDT by Konstantin Komissarchik CLA
Modified: 2021-11-19 09:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2011-05-09 14:18:19 EDT
When gets beyond a few nodes and connections, it would be very helpful to provide a way for the user to invoke one-time auto-layout. After auto-layout, the user should be able to resume manually positioning nodes and connections.
Comment 1 Greg Amerson CLA 2011-05-18 23:02:33 EDT
It would be nice if there was an API for adopters to be able to call auto-layout on a subset of nodes instead of doing all nodes on the diagram.
Comment 2 Greg Amerson CLA 2011-05-18 23:03:12 EDT
For context of comment#2 see bug#345199#c6
Comment 3 Shenxue Zhou CLA 2011-05-19 11:18:47 EDT
That's an interesting approach to auto layout. The problem I see here is if the subset of nodes all overlap each other, then they'd only occupy a small area of the diagram canvas. The auto layout algorithm either calculates the bounding box of the region its nodes are supposed to occupy by doing a union on all the nodes or would allow caller to specify that. The former approach would not do a good job if all the nodes are overlapping. In the latter approach, if you pass the diagram canvas region to the layout algorithm, then ultimately the subset of the nodes that are involved in the auto layout may intersect with the nodes that didn't participate in the auto layout.

I don't see a good possibility to do auto layout on subset of nodes...
Comment 4 Shenxue Zhou CLA 2011-08-26 18:31:21 EDT
Added two more diagram page actions: auto layout horizontally and auto layout vertically. It applies Draw2D's directed graph layout algorithm. 

When a sapphire diagram editor is opened, if it can't find diagram layout file, it'll attempt to apply horizontal layout algorithm.
Comment 5 Konstantin Komissarchik CLA 2011-08-27 22:00:15 EDT
Rather than two separate actions, I'd like to see a single "Sapphire.Diagram.Layout" action with two action handlers for vertical and horizontal layouts. This will also make it easier to add other layouts (whether in the framework or by adopters.

The auto-layout operation that happens when geomentry data is not found can be defined as using the first active layout handler. That should be sufficiently flexible since action handler order is controllable in the definition.
Comment 6 Shenxue Zhou CLA 2011-08-29 13:21:20 EDT
Fixed as suggested.
Comment 7 Konstantin Komissarchik CLA 2011-08-29 16:54:19 EDT
Two issues:

1. Terminology. "Auto layout" suggests a persistent toggle that places the editor into a mode where layout is automatically controlled, which is not what we are doing here. Let's replace "auto layout" with just "layout". Also, the handlers should be labeled just "horizontally" and "vertically" instead of repeating the "layout" verb.

2. Layout of connection labels. When using horizontal layout, the start of the label is placed at the center of the connection which isn't optimal. When the connection is running exactly horizontally, the center of the label should be placed at the midpoint of the connection. The easiest way to repro this is to create A -> B -> C diagram in map sample and don't fill anything in for connection labels.
Comment 8 Shenxue Zhou CLA 2011-09-01 19:05:02 EDT
The action label has been addressed. The connection label placement is tracked by https://bugs.eclipse.org/bugs/show_bug.cgi?id=356535
Comment 9 Konstantin Komissarchik CLA 2011-09-20 15:10:56 EDT
Looks good. Verified. Closing.