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

Bug 345199

Summary: [diagram] Default placement of new diagram nodes can overlap existing ones
Product: z_Archived Reporter: Greg Amerson <gregory.amerson>
Component: SapphireAssignee: Shenxue Zhou <shenxue.zhou>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: konstantin
Version: unspecifiedKeywords: usability
Target Milestone: ---   
Hardware: PC   
OS: All   
Whiteboard:

Description Greg Amerson CLA 2011-05-09 16:21:02 EDT
If you have several nodes in a editor and you switch to the diagram page for the first time all of the nodes will be stacked on top of each other.  you have to select and drag each one of them into another area of the diagram.  This is more confusing later if you leave one of the nodes in the default postion and then later add a new element/node and switch to diagram page it will once again overlap another node in the default position and it is confusing because you may think the new node wasn't added.
Comment 1 Konstantin Komissarchik CLA 2011-05-09 16:31:06 EDT
An offset stacking could be used instead. That will at least differentiate the nodes for now. Once we incorporate auto-layout algorithms, those can play a part in this scenario as well.
Comment 2 Shenxue Zhou CLA 2011-05-09 16:55:38 EDT
I thought I placed the nodes added through form editor (or source editor) apart by adding 100 pixels horizontally. I'll double check that.
Comment 3 Greg Amerson CLA 2011-05-12 13:57:14 EDT
So when you are in a masterDetail page adding more nodes those are added correctly 100 pixels apart.  However, here is a better description of how I saw the overlap.

Open new sapphire editor, add several new nodes in masterDetail page, switch to diagram page, you will see the correct 100pixel spacing.
Close sapphire editor, open same file in plain text editor, add several new node/elements.
Reopen sapphire editor and switch to grapphical diagram and you will notice that all new elements are added at the same location and will overlap one-another.
Comment 4 Greg Amerson CLA 2011-05-17 21:13:07 EDT
Update, now it seems that if you add multiple new nodes via source page (or external editor) when they are placed on the diagram only the first one may overlap, the rest will be properly spaced, however it doesn't seem to respect existing nodes.  Here is a new test sequence:

* Switch to source page
* add 3 new nodes that will be rendered on diagram page
* switch back to diagram you will see the 3 nodes spaced next to one another
* switch back to source page and add 3 new nodes again
* switch back and see that the 3 new nodes will overlap exactly the first 3 nodes that were added.

I'm wondering if the new node default position should take into account existing nodes on the diagram and make sure that new nodes don't overlap existing nodes, in the same way that you can't drop a node when moving it on-top of an existing node (you get the no-drop cursor).
Comment 5 Shenxue Zhou CLA 2011-05-18 11:38:10 EDT
It's non-trivial effort to make sure the new node position doesn't overlap with existing nodes. If user tends to add many new nodes through the form editor or the source editor and comes to the diagram page once in a while, it probably means the user is interested only in the overview of the model (rather than the exact placement of each node), then he/she can apply auto layout.

We do plan to support auto layout actions. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=345179
Comment 6 Greg Amerson CLA 2011-05-18 23:02:00 EDT
Sure that makes sense.  I guess adopters could on switch to diagram page detect if new nodes have been added and perhaps auto-layout the new nodes automatically once those actions are available.  So perhaps I should ask if auto-layout actions will be able to operate on a sub-set of nodes, that would be very handy in this case.

If adopters are able to auto-layout any new nodes programatically then I believe this bug could be marked wont fix.
Comment 7 Shenxue Zhou CLA 2011-06-02 12:50:08 EDT
Will address auto layout in https://bugs.eclipse.org/bugs/show_bug.cgi?id=345179
Comment 8 Konstantin Komissarchik CLA 2011-06-03 12:22:18 EDT
I'd like to see this improved regardless of availability of auto-layout action. The solution doesn't have to be terribly complicated. The only requirement from my perspective is to not place new nodes directly on top of other nodes. The user should be able to see all nodes, but there is no requirement here that the placement must be ideal or not partly overlap existing nodes.
Comment 9 Shenxue Zhou CLA 2011-06-03 12:32:15 EDT
I could not duplicate the behavior described by Greg. If new nodes are added through form editor or text editor, new nodes added to the diagram are not placed on top of each other. They are added 100 pixel apart horizontally.
Comment 10 Konstantin Komissarchik CLA 2011-06-03 13:06:39 EDT
So Greg's steps in Comment #4 do not repro for you you?
Comment 11 Shenxue Zhou CLA 2011-06-03 13:13:02 EDT
(In reply to comment #10)
> So Greg's steps in Comment #4 do not repro for you you?

No It didn't repro for me.
Comment 12 Konstantin Komissarchik CLA 2011-06-03 13:16:48 EDT
Changing the resolution accordingly. Greg, if you are still seeing cases where new nodes are placed directly on top of another node, please re-open and we will need to dig deeper.
Comment 13 Greg Amerson CLA 2011-06-03 13:31:53 EDT
Thanks for looking again.  New nodes are not placed on top of each other, its that new nodes can and will overlap existing nodes.

Here is the simplest case:

1. create a diagram with one node
2. save and close the editor
3. open the editor switch to source
4. add a new node in source
5. switch to diagram

Notice that the new node overlaps exactly on top of the one existing node.  And in my case I was typing in names that were very similar, e.g. Foo1 and Foo2, and I thought to myself "where is the new node?".

Shenxue mentioned that it may be prohibitively difficult to make sure that new nodes don't exactly overlap existing nodes.
Comment 14 Shenxue Zhou CLA 2011-06-03 13:38:57 EDT
(In reply to comment #13)
> Thanks for looking again.  New nodes are not placed on top of each other, its
> that new nodes can and will overlap existing nodes.
> 
> Here is the simplest case:
> 
> 1. create a diagram with one node
> 2. save and close the editor
> 3. open the editor switch to source
> 4. add a new node in source
> 5. switch to diagram
> 
> Notice that the new node overlaps exactly on top of the one existing node.  And
> in my case I was typing in names that were very similar, e.g. Foo1 and Foo2,
> and I thought to myself "where is the new node?".
> 
> Shenxue mentioned that it may be prohibitively difficult to make sure that new
> nodes don't exactly overlap existing nodes.

Right if you don't close the editor, and add new nodes in source/form pages and switch between diagram pages and source/form pages, new nodes won't be placed on top of each other. However, if you close the editor and open it again, the new node will be placed at the same default location.

I think it's going to be quite involved and complex and arguably not worth the effort to find a new node position that won't overlap with the existing new nodes. If user keeps adding new nodes via form/source pages, the user is better off doing an auto layout.
Comment 15 Konstantin Komissarchik CLA 2011-06-03 13:41:14 EDT
I'd like to see the following logic implemented:

for each new node
{
    start with some fixed location

    while proposed position is within let's say 5 pixels 
    of another node's left _or_ top border
    {
        add fixed offset to proposed position on both axis
    }
}

This shouldn't take more than an hour of work to implement and test...
Comment 16 Konstantin Komissarchik CLA 2011-06-03 13:42:02 EDT
Re-opening based on the discussion.
Comment 17 Konstantin Komissarchik CLA 2011-06-08 17:56:01 EDT
Need to defer this.
Comment 18 Shenxue Zhou CLA 2011-09-19 19:22:12 EDT
Implemented what's suggested in Comment 15
Comment 19 Greg Amerson CLA 2011-09-19 21:40:10 EDT
Verified with build # 518
Comment 20 Shenxue Zhou CLA 2011-09-20 11:37:37 EDT
Closing based on Greg's verification.