Commit 58c0c3c8 authored by Manuel Schrick's avatar Manuel Schrick
Browse files

CodeCleanup: PortCoordinatesHandler

parent 2b4f0611
......@@ -19,10 +19,8 @@ public class PortCoordinatesHandler implements DrawingConstants {
public static void assignPortCoordinates(RoutesLayoutState layoutState) {
List<Route> routes = layoutState.routes;
int tableWidth = RoutesUtils.getTableWidth(routes);
for (int routeIndex = 0; routeIndex < routes.size(); routeIndex++) {
Route route = routes.get(routeIndex);
routes.forEach(route -> {
List<Node> nodes = route.getNodes();
for (int nodeIndex = 0; nodeIndex < nodes.size() - 1; nodeIndex++) {
......@@ -32,57 +30,9 @@ public class PortCoordinatesHandler implements DrawingConstants {
continue;
}
Node next = route.getSuccessor(node);
if (next != null && !next.isTemporary) {
PortSymbol sourceOutputPort = route.getNodeOutputPort(node);
PortSymbol targetInputPort = route.getNodeInputPort(next);
Pair<Node, Node> nodePair = new Pair<>(node, next);
if (layoutState.busses.containsKey(nodePair) || layoutState.backConnectors.containsKey(nodePair) || layoutState.splitConnectors.containsKey(nodePair)) {
continue;
}
int sourceNodeColumnIndex = route.columnIndexOf(node);
int targetNodeColumnIndex = route.columnIndexOf(next);
if (sourceOutputPort == null || targetInputPort == null) {
System.out.println("\nconnection: " + node.compName + " -> " + next.compName + "\n" + route.toIdString());
if (sourceOutputPort == null) {
System.out.println(" source port is null");
}
if (targetInputPort == null) {
System.out.println(" target port is null");
}
if (layoutState.backConnectors.containsKey(nodePair)) {
System.out.println(" has backConnector");
}
if (layoutState.busses.containsKey(nodePair)) {
System.out.println(" has bus");
}
route.printInputPorts();
route.printOutputPorts();
}
if (node.compName.equals(NAME_ROOT_IN)) {
assignCoordinatesToEnclosingInputPort(routeIndex, sourceOutputPort, routes);
} else {
assignCoordinatesToInternalOutputPort(sourceNodeColumnIndex, routeIndex, sourceOutputPort, routes);
}
if (next.compName.equals(NAME_ROOT_OUT)) {
assignCoordinatesToEnclosingOutgoingPort(routeIndex, tableWidth, targetInputPort, routes);
} else {
assignCoordinatesToInternalInputPort(targetNodeColumnIndex, routeIndex, targetInputPort, routes);
}
}
assignPortCoordinatesAt(route, node, layoutState);
}
}
});
List<Pair<Node, Node>> assignedBusesAndBackConnectors = new ArrayList<>();
......@@ -100,6 +50,38 @@ public class PortCoordinatesHandler implements DrawingConstants {
}
}
private static void assignPortCoordinatesAt(Route route, Node node, RoutesLayoutState layoutState) {
Node next = route.getSuccessor(node);
int tableWidth = RoutesUtils.getTableWidth(layoutState.routes);
int routeIndex = layoutState.routes.indexOf(route);
if (next != null && !next.isTemporary) {
PortSymbol sourceOutputPort = route.getNodeOutputPort(node);
PortSymbol targetInputPort = route.getNodeInputPort(next);
Pair<Node, Node> nodePair = new Pair<>(node, next);
if (layoutState.busses.containsKey(nodePair) || layoutState.backConnectors.containsKey(nodePair) || layoutState.splitConnectors.containsKey(nodePair)) {
return;
}
int sourceNodeColumnIndex = route.columnIndexOf(node);
int targetNodeColumnIndex = route.columnIndexOf(next);
if (node.compName.equals(NAME_ROOT_IN)) {
assignCoordinatesToEnclosingInputPort(routeIndex, sourceOutputPort, layoutState.routes);
} else {
assignCoordinatesToInternalOutputPort(sourceNodeColumnIndex, routeIndex, sourceOutputPort, layoutState.routes);
}
if (next.compName.equals(NAME_ROOT_OUT)) {
assignCoordinatesToEnclosingOutgoingPort(routeIndex, tableWidth, targetInputPort, layoutState.routes);
} else {
assignCoordinatesToInternalInputPort(targetNodeColumnIndex, routeIndex, targetInputPort, layoutState.routes);
}
}
}
private static void assignBusPortCoordinates(Bus bus, BackConnector backConnector, RoutesLayoutState layoutState) {
List<Route> routes = layoutState.routes;
List<PortSymbol> sourceOutputPorts = bus.getSourceOutputPorts();
......
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