Commit e5f46018 authored by Simon Barner's avatar Simon Barner
Browse files

YELLOW

(use static imports)
refs 2983
parent 3b81e299
......@@ -17,6 +17,7 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.layout.auto;
import static java.util.Collections.emptyList;
import static org.fortiss.tooling.base.layout.LayoutKeyConstants.CONNECTOR_ANGLE;
import static org.fortiss.tooling.base.utils.AngleUtils.getAngle;
import static org.fortiss.tooling.kernel.utils.EcoreUtils.pickInstanceOf;
......@@ -45,7 +46,7 @@ import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
* @author barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 76FF1ADFC034DE69815575B04BA534F0
* @ConQAT.Rating YELLOW Hash: 2D666157F7CB8A373233FD508F93F90C
*/
public class AutoLayoutMenu implements IContextMenuContributor {
......@@ -113,8 +114,7 @@ public class AutoLayoutMenu implements IContextMenuContributor {
// Check if model is empty
if(pickInstanceOf(ILayoutedModelElement.class, element.getContainedElements()).isEmpty()) {
// TODO (FH): use import static
return Collections.emptyList();
return emptyList();
}
// Enable automatic layouter only for diagrams without rounded edges, which is the case if
......@@ -122,13 +122,11 @@ public class AutoLayoutMenu implements IContextMenuContributor {
// particular also if the model does not contain any connectors, or none of the connectors
// is connected to a connection).
if(hasConnectedConnectorWithAngle(element)) {
// TODO (FH): use import static
return Collections.emptyList();
return emptyList();
}
for(IHierarchicElement childElement : element.getContainedElements()) {
if(hasConnectedConnectorWithAngle(childElement)) {
// TODO (FH): use import static
return Collections.emptyList();
return emptyList();
}
}
......
......@@ -17,10 +17,25 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.layout.auto;
import static de.cau.cs.kieler.kiml.options.Direction.RIGHT;
import static de.cau.cs.kieler.kiml.options.LayoutOptions.DIRECTION;
import static de.cau.cs.kieler.kiml.options.LayoutOptions.INTERACTIVE;
import static de.cau.cs.kieler.kiml.options.LayoutOptions.PORT_SIDE;
import static de.cau.cs.kieler.kiml.util.KimlUtil.createInitializedEdge;
import static de.cau.cs.kieler.kiml.util.KimlUtil.createInitializedNode;
import static de.cau.cs.kieler.kiml.util.KimlUtil.createInitializedPort;
import static de.cau.cs.kieler.klay.layered.properties.InteractiveReferencePoint.TOP_LEFT;
import static de.cau.cs.kieler.klay.layered.properties.Properties.FEEDBACK_EDGES;
import static de.cau.cs.kieler.klay.layered.properties.Properties.INTERACTIVE_REFERENCE_POINT;
import static java.lang.Math.max;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_CONNECTOR_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_GRID_SIZE;
import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT;
import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.isUpdateEnabled;
import static org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase.setUpdateEnabled;
import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.addBendPointToConnection;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.getNodeSize;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeLayoutData;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodePosition;
import static org.fortiss.tooling.base.utils.LayoutDataUtils.setStickyConnectorLayoutData;
......@@ -41,9 +56,6 @@ import org.fortiss.tooling.base.model.layout.ILayoutData;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.Points;
import org.fortiss.tooling.base.model.layout.impl.PointsImpl;
import org.fortiss.tooling.base.ui.annotation.view.AnnotationViewPartBase;
import org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils;
import org.fortiss.tooling.base.utils.LayoutDataUtils;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
......@@ -56,13 +68,8 @@ import de.cau.cs.kieler.kiml.AbstractLayoutProvider;
import de.cau.cs.kieler.kiml.klayoutdata.KEdgeLayout;
import de.cau.cs.kieler.kiml.klayoutdata.KPoint;
import de.cau.cs.kieler.kiml.klayoutdata.KShapeLayout;
import de.cau.cs.kieler.kiml.options.Direction;
import de.cau.cs.kieler.kiml.options.LayoutOptions;
import de.cau.cs.kieler.kiml.options.PortSide;
import de.cau.cs.kieler.kiml.util.KimlUtil;
import de.cau.cs.kieler.klay.layered.LayeredLayoutProvider;
import de.cau.cs.kieler.klay.layered.properties.InteractiveReferencePoint;
import de.cau.cs.kieler.klay.layered.properties.Properties;
/**
* <p>
......@@ -82,7 +89,7 @@ import de.cau.cs.kieler.klay.layered.properties.Properties;
* @author offtermatt, barner
* @author $Author$
* @version $Rev$
* @ConQAT.Rating YELLOW Hash: 36F683174E3AD8ADC2DDDC27D7C75183
* @ConQAT.Rating YELLOW Hash: F9D59F75EB9D0D8D46B8404AE357CB33
*/
// TODO (FH): use import static
public class KielerAutoLayouter implements IAutoLayouter {
......@@ -112,16 +119,15 @@ public class KielerAutoLayouter implements IAutoLayouter {
@Override
public void performAutoLayout(IHierarchicElement hierarchicElement) {
boolean avUpdateEnabled = AnnotationViewPartBase.isUpdateEnabled();
AnnotationViewPartBase.setUpdateEnabled(false);
boolean avUpdateEnabled = isUpdateEnabled();
setUpdateEnabled(false);
KNode rootNode = createKIELERGraph(hierarchicElement);
KShapeLayout rootNodeLayout = rootNode.getData(KShapeLayout.class);
rootNodeLayout.setProperty(LayoutOptions.DIRECTION, Direction.RIGHT);
rootNodeLayout.setProperty(LayoutOptions.INTERACTIVE, true);
rootNodeLayout.setProperty(Properties.FEEDBACK_EDGES, true);
rootNodeLayout.setProperty(Properties.INTERACTIVE_REFERENCE_POINT,
InteractiveReferencePoint.TOP_LEFT);
rootNodeLayout.setProperty(DIRECTION, RIGHT);
rootNodeLayout.setProperty(INTERACTIVE, true);
rootNodeLayout.setProperty(FEEDBACK_EDGES, true);
rootNodeLayout.setProperty(INTERACTIVE_REFERENCE_POINT, TOP_LEFT);
AbstractLayoutProvider layoutProvider = new LayeredLayoutProvider();
IKielerProgressMonitor progressMonitor = new BasicProgressMonitor();
......@@ -129,7 +135,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
applyLayout(rootNode, hierarchicElement);
AnnotationViewPartBase.setUpdateEnabled(avUpdateEnabled);
setUpdateEnabled(avUpdateEnabled);
}
/**
......@@ -187,7 +193,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
for(IHierarchicElement element : hierarchicElement.getContainedElements()) {
KNode kNode = modelElementsToKNodes.get(element);
KShapeLayout kNodeLayout = kNode.getData(KShapeLayout.class);
LayoutDataUtils.setNodeLayoutData((ILayoutedModelElement)element,
setNodeLayoutData((ILayoutedModelElement)element,
truncateSnap2Grid(kNodeLayout.getXpos()),
truncateSnap2Grid(kNodeLayout.getYpos()),
truncateSnap2Grid(kNodeLayout.getWidth(), true),
......@@ -199,7 +205,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
IConnection connection = entry.getKey();
KEdgeLayout kEdgeLayout = kEdge.getData(KEdgeLayout.class);
for(KPoint kPoint : kEdgeLayout.getBendPoints()) {
LayoutDataUIUtils.addBendPointToConnection((ILayoutedModelElement)connection,
addBendPointToConnection((ILayoutedModelElement)connection,
truncateSnap2Grid(kPoint.getX()), truncateSnap2Grid(kPoint.getY()));
}
}
......@@ -243,7 +249,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
KPort kPort = entry.getValue();
IConnector connector = entry.getKey();
KShapeLayout kLayout = kPort.getData(KShapeLayout.class);
PortSide side = kLayout.getProperty(LayoutOptions.PORT_SIDE);
PortSide side = kLayout.getProperty(PORT_SIDE);
EOrientation orientation = null;
switch(side) {
case NORTH:
......@@ -292,7 +298,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
*/
private KNode createKIELERGraph(IHierarchicElement hierarchicElement) {
KNode rootNode = KimlUtil.createInitializedNode();
KNode rootNode = createInitializedNode();
modelElementsToKNodes = new BasicEMap<IHierarchicElement, KNode>();
outboundConnectorsToKPorts = new BasicEMap<IConnector, KPort>();
......@@ -307,7 +313,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
continue;
}
KNode kNode = KimlUtil.createInitializedNode();
KNode kNode = createInitializedNode();
KShapeLayout kNodeLayout = kNode.getData(KShapeLayout.class);
......@@ -328,10 +334,10 @@ public class KielerAutoLayouter implements IAutoLayouter {
// Adjust size of node to number of connectors
Dimension dimension = getNodeSize((ILayoutedModelElement)currentChild);
int numConnectors = Math.max(inputConnectors.size(), outputConnectors.size());
kNodeLayout.setHeight(Math.max((1 + 2 * numConnectors) * DEFAULT_CONNECTOR_SIZE,
int numConnectors = max(inputConnectors.size(), outputConnectors.size());
kNodeLayout.setHeight(max((1 + 2 * numConnectors) * DEFAULT_CONNECTOR_SIZE,
truncateSnap2Grid(dimension.getHeight(), true)));
kNodeLayout.setWidth(Math.max(DEFAULT_SHAPE_MINIMUM_HEIGHT,
kNodeLayout.setWidth(max(DEFAULT_SHAPE_MINIMUM_HEIGHT,
truncateSnap2Grid(dimension.getWidth(), true)));
kNode.setParent(rootNode);
......@@ -352,13 +358,13 @@ public class KielerAutoLayouter implements IAutoLayouter {
globalOutboundConnectorsToKPorts = new BasicEMap<IConnector, KPort>();
for(IConnector connector : hierarchicElement.getConnectors()) {
KNode kNodeVirtual = KimlUtil.createInitializedNode();
KNode kNodeVirtual = createInitializedNode();
KShapeLayout kNodeVirtualLayout = kNodeVirtual.getData(KShapeLayout.class);
kNodeVirtualLayout.setHeight(DEFAULT_CONNECTOR_SIZE);
kNodeVirtualLayout.setWidth(2 * DEFAULT_CONNECTOR_SIZE);
kNodeVirtual.setParent(rootNode);
KPort kPort = KimlUtil.createInitializedPort();
KPort kPort = createInitializedPort();
kPort.setNode(kNodeVirtual);
if(connector instanceof ExitConnectorBase) {
globalOutboundConnectorsToKPorts.put(connector, kPort);
......@@ -371,7 +377,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
// Create edges
for(Entry<IConnector, KPort> entry : outboundConnectorsToKPorts) {
for(IConnection connection : entry.getKey().getOutgoing()) {
KEdge kEdge = KimlUtil.createInitializedEdge();
KEdge kEdge = createInitializedEdge();
KPort kSourcePort = entry.getValue();
kEdge.setSource(kSourcePort.getNode());
......@@ -409,7 +415,7 @@ public class KielerAutoLayouter implements IAutoLayouter {
*/
private KPort createKPortFromIConnector(IConnector connector, KNode kNode,
EMap<IConnector, KPort> connectorsToKPorts) {
KPort kPort = KimlUtil.createInitializedPort();
KPort kPort = createInitializedPort();
kPort.setNode(kNode);
KShapeLayout kPortLayout = kPort.getData(KShapeLayout.class);
kPortLayout.setHeight(DEFAULT_CONNECTOR_SIZE);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment