diff options
author | Henrik Rentz-Reichert | 2011-03-09 10:34:54 +0000 |
---|---|---|
committer | Henrik Rentz-Reichert | 2011-03-09 10:34:54 +0000 |
commit | bf875b42cfb26e1dd2fee4b1d037c963fe3d6c02 (patch) | |
tree | da2838ab9f8c85fa5f091615f57e3377d9a80de4 /plugins/org.eclipse.etrice.ui.structure | |
parent | b22023e46fa6bc505cb526f0d827c942171f1137 (diff) | |
download | org.eclipse.etrice-bf875b42cfb26e1dd2fee4b1d037c963fe3d6c02.tar.gz org.eclipse.etrice-bf875b42cfb26e1dd2fee4b1d037c963fe3d6c02.tar.xz org.eclipse.etrice-bf875b42cfb26e1dd2fee4b1d037c963fe3d6c02.zip |
ui.structure: further improved initial placement of actor refs
Diffstat (limited to 'plugins/org.eclipse.etrice.ui.structure')
-rw-r--r-- | plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java index 74a802316..b643bf96f 100644 --- a/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java +++ b/plugins/org.eclipse.etrice.ui.structure/src/org/eclipse/etrice/ui/structure/commands/PopulateDiagramCommand.java @@ -170,15 +170,22 @@ public class PopulateDiagramCommand extends RecordingCommand { protected void addRefItems(EList<? extends ActorContainerRef> actorRefs,
ContainerShape acShape, int width,
IFeatureProvider featureProvider, final HashMap<String, Anchor> port2anchor) {
- int maxPerRow = width/ActorContainerRefSupport.DEFAULT_SIZE_X;
- int gap = (width-(maxPerRow*ActorContainerRefSupport.DEFAULT_SIZE_X))/(maxPerRow+1);
+ int ncols = width/ActorContainerRefSupport.DEFAULT_SIZE_X;
+ int nrows = actorRefs.size()/ncols;
+ int gap = (width-(ncols*ActorContainerRefSupport.DEFAULT_SIZE_X))/(ncols+1);
int delta = gap+ActorContainerRefSupport.DEFAULT_SIZE_X;
int x0 = gap+ActorContainerRefSupport.DEFAULT_SIZE_X/2;
int y0 = ActorContainerRefSupport.DEFAULT_SIZE_Y*3/2;
int i = 0;
for (ActorContainerRef ar : actorRefs) {
- int row = i/maxPerRow;
- int col = i%maxPerRow;
+ int row = i/ncols;
+ int col = i%ncols;
+ if (row>=nrows) {
+ int nc = actorRefs.size()%ncols;
+ gap = (width-(nc*ActorContainerRefSupport.DEFAULT_SIZE_X))/(nc+1);
+ delta = gap+ActorContainerRefSupport.DEFAULT_SIZE_X;
+ x0 = gap+ActorContainerRefSupport.DEFAULT_SIZE_X/2;
+ }
int x = x0+delta*col;
int y = y0+(ActorContainerRefSupport.MARGIN+ActorContainerRefSupport.DEFAULT_SIZE_Y)*row;
addRefItem(ar, acShape, x+StructureClassSupport.MARGIN, y+StructureClassSupport.MARGIN, featureProvider, port2anchor);
|