diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/.ratings b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/.ratings index ace0e86f887263a665e62d39b97c5964de78e8ed..9be7d2bbfaecf09561e5cf5811c6d7ed847bbc16 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/.ratings +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/.ratings @@ -2,4 +2,4 @@ AutoLayoutMenu.java ef3b897cc2fd99cf9ce201f03cffea036555e3ac GREEN DiagramTapeMeasure.java 72454e6fe5225dab11d3d691baad93aab7a171c0 YELLOW IAutoLayouter.java de1b11d9e202c7e23352ad85684dbf8a3fd17c7d GREEN IAutoLayouterTapeMeasure.java df186e0ba505e0ecda211b1df76cf12f3245b47e YELLOW -KielerAutoLayouter.java 2fe3bf63213245d6900c42be172347f863f2f198 YELLOW +KielerAutoLayouter.java 9feddf66b525bb4f3768ab67452d0e8e17d399df YELLOW diff --git a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/KielerAutoLayouter.java b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/KielerAutoLayouter.java index 2fe3bf63213245d6900c42be172347f863f2f198..9feddf66b525bb4f3768ab67452d0e8e17d399df 100644 --- a/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/KielerAutoLayouter.java +++ b/org.fortiss.tooling.base.ui/src/org/fortiss/tooling/base/ui/layout/auto/KielerAutoLayouter.java @@ -116,11 +116,11 @@ public class KielerAutoLayouter implements IAutoLayouter { /** {@inheritDoc} */ @Override - public void performAutoLayout(IHierarchicElement hierarchicElement) { + public void performAutoLayout(IHierarchicElement element) { boolean avUpdateEnabled = isUpdateEnabled(); setUpdateEnabled(false); - KNode rootNode = createKIELERGraph(hierarchicElement); + KNode rootNode = createKIELERGraph(element); KShapeLayout rootNodeLayout = rootNode.getData(KShapeLayout.class); rootNodeLayout.setProperty(DIRECTION, RIGHT); @@ -132,7 +132,7 @@ public class KielerAutoLayouter implements IAutoLayouter { IKielerProgressMonitor progressMonitor = new BasicProgressMonitor(); layoutProvider.doLayout(rootNode, progressMonitor); - applyLayout(rootNode, hierarchicElement); + applyLayout(rootNode, element); setUpdateEnabled(avUpdateEnabled); } @@ -180,19 +180,19 @@ public class KielerAutoLayouter implements IAutoLayouter { * * @param template * The {@link KNode} that stores the layout. - * @param hierarchicElement + * @param element * The {@link IHierarchicElement} to which the layout should be applied. */ - private void applyLayout(KNode template, IHierarchicElement hierarchicElement) { + private void applyLayout(KNode template, IHierarchicElement element) { ITopLevelElement topLevelElement = - IPersistencyService.getInstance().getTopLevelElementFor(hierarchicElement); + IPersistencyService.getInstance().getTopLevelElementFor(element); topLevelElement.runAsCommand(() -> { - filterBendPoints(hierarchicElement); + filterBendPoints(element); - for(IHierarchicElement element : hierarchicElement.getContainedElements()) { - KNode kNode = modelElementsToKNodes.get(element); + for(IHierarchicElement child : element.getContainedElements()) { + KNode kNode = modelElementsToKNodes.get(child); KShapeLayout kNodeLayout = kNode.getData(KShapeLayout.class); - setNodeLayoutData((ILayoutedModelElement)element, + setNodeLayoutData((ILayoutedModelElement)child, truncateSnap2Grid(kNodeLayout.getXpos()), truncateSnap2Grid(kNodeLayout.getYpos()), truncateSnap2Grid(kNodeLayout.getWidth(), true), @@ -270,13 +270,9 @@ public class KielerAutoLayouter implements IAutoLayouter { } } - /** - * Removes all bend-points in connections contained in the given {@link IHierarchicElement}. - * - * @param hierarchicElement - */ - private void filterBendPoints(IHierarchicElement hierarchicElement) { - for(IConnection connection : hierarchicElement.getConnections()) { + /** Removes all bend-points in connections contained in the given {@link IHierarchicElement}. */ + private void filterBendPoints(IHierarchicElement element) { + for(IConnection connection : element.getConnections()) { for(ILayoutData layoutData : ((ILayoutedModelElement)connection).getLayoutData()) { if(layoutData instanceof Points || layoutData instanceof PointsImpl) { ((Points)layoutData).getPoints().clear(); @@ -311,13 +307,13 @@ public class KielerAutoLayouter implements IAutoLayouter { * Creates a KIELER {@link KNode} graph with the same structure as the given * {@link IHierarchicElement}. * - * @param hierarchicElement + * @param element * The {@link IHierarchicElement} for which the {@link KNode} graph should be created * * @return A {@link KNode} graph with the same structure as the graph contained in the * {@link IHierarchicElement}. */ - private KNode createKIELERGraph(IHierarchicElement hierarchicElement) { + private KNode createKIELERGraph(IHierarchicElement element) { KNode rootNode = createInitializedNode(); @@ -327,14 +323,14 @@ public class KielerAutoLayouter implements IAutoLayouter { connectionsToKEdges = new BasicEMap<IConnection, KEdge>(); undirectedConnectorsToKPorts = new BasicEMap<IConnector, KPort>(); - EditPartViewer viewer = getDiagramEditPartViewer(hierarchicElement); + EditPartViewer viewer = getDiagramEditPartViewer(element); GC gc = viewer != null ? new GC(viewer.getControl()) : null; IAutoLayouterTapeMeasure tapeMeasure = new DiagramTapeMeasure(viewer, gc); // Create nodes - for(IHierarchicElement currentChild : hierarchicElement.getContainedElements()) { + for(IHierarchicElement child : element.getContainedElements()) { - if(!(currentChild instanceof ILayoutedModelElement)) { + if(!(child instanceof ILayoutedModelElement)) { continue; } KNode kNode = createInitializedNode(); @@ -343,7 +339,7 @@ public class KielerAutoLayouter implements IAutoLayouter { EList<IConnector> inputConnectors = new BasicEList<IConnector>(); EList<IConnector> outputConnectors = new BasicEList<IConnector>(); EList<IConnector> undirectedConnectors = new BasicEList<IConnector>(); - for(IConnector connector : currentChild.getConnectors()) { + for(IConnector connector : child.getConnectors()) { if(connector instanceof EntryConnectorBase) { inputConnectors.add(connector); } else if(connector instanceof ExitConnectorBase) { @@ -355,12 +351,12 @@ public class KielerAutoLayouter implements IAutoLayouter { } // Adjust size of node to number of connectors and label size - int width = tapeMeasure.getElementWidth(currentChild); + int width = tapeMeasure.getElementWidth(child); kNodeLayout.setWidth(truncateSnap2Grid(width, true)); - int height = tapeMeasure.getElementHeight(currentChild); + int height = tapeMeasure.getElementHeight(child); kNodeLayout.setHeight(truncateSnap2Grid(height, true)); kNode.setParent(rootNode); - modelElementsToKNodes.put(currentChild, kNode); + modelElementsToKNodes.put(child, kNode); for(IConnector connector : outputConnectors) { KPort k = createKPortFromIConnector(connector, kNode, outboundConnectorsToKPorts); @@ -377,7 +373,7 @@ public class KielerAutoLayouter implements IAutoLayouter { globalInboundConnectorsToKPorts = new BasicEMap<IConnector, KPort>(); globalOutboundConnectorsToKPorts = new BasicEMap<IConnector, KPort>(); - for(IConnector connector : hierarchicElement.getConnectors()) { + for(IConnector connector : element.getConnectors()) { KNode kNodeVirtual = createInitializedNode(); KShapeLayout kNodeVirtualLayout = kNodeVirtual.getData(KShapeLayout.class); kNodeVirtualLayout.setWidth(tapeMeasure.getConnectorWidth(connector));