diff options
author | Henrik Rentz-Reichert | 2013-08-08 15:57:33 +0000 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org | 2013-08-08 15:57:33 +0000 |
commit | 2af0dfc2f970f9e87d4a30a0ae4207c418933c41 (patch) | |
tree | f25d6072a245ca96e02c2f7280e6a4daa7e95cd9 | |
parent | 2686717b0f4d07f7936d9ea807dcac3ae7af6062 (diff) | |
parent | 6e504f9ad53cd3f442a96bf4c1fb07f23a7b9c08 (diff) | |
download | org.eclipse.etrice-2af0dfc2f970f9e87d4a30a0ae4207c418933c41.tar.gz org.eclipse.etrice-2af0dfc2f970f9e87d4a30a0ae4207c418933c41.tar.xz org.eclipse.etrice-2af0dfc2f970f9e87d4a30a0ae4207c418933c41.zip |
Merge "[ui.structure] improved initial layout"
-rw-r--r-- | plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/provider/DefaultPositionProvider.java | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/provider/DefaultPositionProvider.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/provider/DefaultPositionProvider.java index 04c555ad1..b1f11a3f1 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/provider/DefaultPositionProvider.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/support/provider/DefaultPositionProvider.java @@ -94,7 +94,7 @@ public class DefaultPositionProvider implements IPositionProvider { int width = parent.inner.getW(); int height = parent.inner.getH(); - int y = ActorContainerRefSupport.MARGIN; + int y = - InterfaceItemSupport.MARGIN + 2*ActorContainerRefSupport.MARGIN; List<ActorContainerRef> refs = new ArrayList<ActorContainerRef>(); List<InterfaceItem> ifItems = new ArrayList<InterfaceItem>(); @@ -112,10 +112,10 @@ public class DefaultPositionProvider implements IPositionProvider { layoutInterfaceItems(ifItems, width, height, -InterfaceItemSupport.MARGIN); - layoutActorRefs(refs, width, height, y); - - y = height - (InterfaceItemSupport.ITEM_SIZE + 2*InterfaceItemSupport.MARGIN); layoutInterfaceItems(intPorts, width, height, y); + + y += InterfaceItemSupport.ITEM_SIZE + 2*ActorContainerRefSupport.MARGIN; + layoutActorRefs(refs, width, height, y); } public DefaultPositionProvider(StructureClass sc) { @@ -124,12 +124,10 @@ public class DefaultPositionProvider implements IPositionProvider { int width = StructureClassSupport.DEFAULT_SIZE_X; int height = StructureClassSupport.DEFAULT_SIZE_Y; - int y = ActorContainerRefSupport.MARGIN; + int y = - InterfaceItemSupport.MARGIN + 2*ActorContainerRefSupport.MARGIN; layoutInterfaceItems(RoomHelpers.getInterfaceItems(sc, true), width, height, -InterfaceItemSupport.MARGIN); - layoutActorRefs(RoomHelpers.getAllActorContainerRefs(sc), width, height, y); - List<InterfaceItem> intPorts = new ArrayList<InterfaceItem>(); if(sc instanceof ActorClass){ ActorClass base = (ActorClass)sc; @@ -138,9 +136,11 @@ public class DefaultPositionProvider implements IPositionProvider { base = base.getBase(); } } - y = height - (InterfaceItemSupport.ITEM_SIZE + 2*InterfaceItemSupport.MARGIN); layoutInterfaceItems(intPorts, width, height, y); + y += InterfaceItemSupport.ITEM_SIZE + 2*ActorContainerRefSupport.MARGIN; + layoutActorRefs(RoomHelpers.getAllActorContainerRefs(sc), width, height, y); + } @Override @@ -237,6 +237,13 @@ public class DefaultPositionProvider implements IPositionProvider { int row = i/ncols; int col = i%ncols; + int nLastRow = actorRefs.size()%ncols; + if(row >= actorRefs.size()/ncols && nLastRow > 0){ + gap = (width-(nLastRow*ActorContainerRefSupport.DEFAULT_SIZE_X))/(nLastRow+1); + delta = gap+ActorContainerRefSupport.DEFAULT_SIZE_X; + x0 = - ActorContainerRefSupport.MARGIN + gap; + } + int x = x0+delta*col; int y = y0+(ActorContainerRefSupport.MARGIN+ActorContainerRefSupport.DEFAULT_SIZE_Y)*row; obj2pos.put(getKey(ar), new Position((double)x/width, (double)y/height)); |