Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t create self-loop edges for edges that are not self-loops #418

Merged
merged 1 commit into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,11 @@ private ISelfLoopPortPositioner getPositioner(final LNode node) {

case FIXED_ORDER:
case FIXED_POS:
case FIXED_RATIO:
return new FixedOrderSelfLoopPortPositioner();

default:
return null;
throw new AssertionError("Unknown port constraint: " + constraint);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void preprocessLabels(final SelfLoopNode slNode, final Direction layoutDi
for (SelfLoopComponent component : slNode.getSelfLoopComponents()) {
// Retrieve all labels attached to edges that belong to this component
List<LLabel> labels = component.getConnectedEdges().stream()
.filter(edge -> edge.getEdge().getSource().getNode().equals(edge.getEdge().getTarget().getNode()))
.filter(edge -> edge.getEdge().isSelfLoop())
.flatMap(edge -> edge.getEdge().getLabels().stream())
.sorted(new Comparator<LLabel>() {
@Override
Expand Down Expand Up @@ -149,7 +149,7 @@ public int compare(final LLabel o1, final LLabel o2) {
* Collect and remove ports that are only self-loop ports.
*/
private void hidePorts(final LNode node) {
List<LPort> selfLoopPorts = new ArrayList<LPort>();
List<LPort> selfLoopPorts = new ArrayList<LPort>(node.getPorts().size());

// check each port if has to be hidden
for (LPort port : node.getPorts()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
public class SelfLoopComponent {

/** The ports of the self loop component. They are all connected by at least one edge. */
private List<SelfLoopPort> ports = new ArrayList<>();
private final List<SelfLoopPort> ports;
/** All center edge labels that occur at the component edges, if any. */
private SelfLoopLabel selfLoopLabel;
/** The components that the self loop component depends on. */
private Map<SelfLoopNodeSide, List<SelfLoopComponent>> dependencyComponents = new HashMap<>();
private final Map<SelfLoopNodeSide, List<SelfLoopComponent>> dependencyComponents = new HashMap<>();
/** Any edges the component depends on. */
private Map<PortSide, List<SelfLoopEdge>> edgeDependencies = new HashMap<>();
private final Map<PortSide, List<SelfLoopEdge>> edgeDependencies = new HashMap<>();


/**
Expand All @@ -46,6 +46,7 @@ public class SelfLoopComponent {
* Ports of the connected self loop component.
*/
public SelfLoopComponent(final List<LPort> ports) {
this.ports = new ArrayList<>(ports.size());
addAllPorts(ports);
calculateConnectedEdges();
}
Expand Down Expand Up @@ -113,7 +114,7 @@ private static void findAllConnectedPorts(final LNode node, final LPort lPort,
/**
* Adds a {@link SelfLoopPort} to the component that represents the given regular port.
*/
public void addPort(final LPort port) {
private void addPort(final LPort port) {
ports.add(new SelfLoopPort(port, this));
}

Expand Down Expand Up @@ -224,9 +225,9 @@ private void calculateConnectedEdges() {
for (SelfLoopPort port : ports) {
for (LEdge edge : port.getLPort().getOutgoingEdges()) {
SelfLoopPort targetPort = findPort(edge.getTarget());
SelfLoopEdge selfLoopEdge = new SelfLoopEdge(this, port, targetPort, edge);
port.getConnectedEdges().add(selfLoopEdge);
if (targetPort != null) {
SelfLoopEdge selfLoopEdge = new SelfLoopEdge(this, port, targetPort, edge);
port.getConnectedEdges().add(selfLoopEdge);
targetPort.getConnectedEdges().add(selfLoopEdge);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public class SelfLoopEdge {
/** The component the self loop belongs to. */
private final SelfLoopComponent component;
/** Other self loops this self loop depends on. */
private Map<PortSide, List<SelfLoopEdge>> dependencyEdges = new HashMap<>();
private final Map<PortSide, List<SelfLoopEdge>> dependencyEdges = new HashMap<>();
/** TODO Document. */
private Map<PortSide, Integer> edgeOrders = new HashMap<>();
private final Map<PortSide, Integer> edgeOrders = new HashMap<>();

/**
* Create a new self loop.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
public class SelfLoopLabel {

/** The list of labels this self loop label consists of. */
private List<LLabel> labels = new ArrayList<>();
private final List<LLabel> labels = new ArrayList<>();
/** The combined height of all labels. */
private double height;
/** The maximum width over all labels. */
private double width;
/** The candidate positions for this label. */
private List<SelfLoopLabelPosition> candidatePositions = new ArrayList<>();
private final List<SelfLoopLabelPosition> candidatePositions = new ArrayList<>();
/** The position chosen for this label. */
private SelfLoopLabelPosition labelPosition;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class SelfLoopNode {
/** The original node this class represents. */
private final LNode node;
/** A map from all four port sides to their respective node side objects. */
private EnumMap<PortSide, SelfLoopNodeSide> nodeSides = new EnumMap<>(PortSide.class);
private final EnumMap<PortSide, SelfLoopNodeSide> nodeSides = new EnumMap<>(PortSide.class);
/** List of self loop components this node has. */
private List<SelfLoopComponent> selfLoopComponents = new ArrayList<>();
private final List<SelfLoopComponent> selfLoopComponents = new ArrayList<>();


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ public class SelfLoopNodeSide {
/** The actual side information. */
private final PortSide side;
/** The ports which are placed on this node side. */
private List<SelfLoopPort> ports = new ArrayList<>();
private final List<SelfLoopPort> ports = new ArrayList<>();
/** The maximum level a port on this side has. */
private int maximumPortLevel;
/** The maximum level a segment on this side has. */
private int maximumSegmentLevel;
/** The maximum offset which has to be considered when calculating the margin of the node. */
private double maximumLabelOffset;
/** The segments which belong to an opposing self loop (space has to be reserved for them). */
private Map<SelfLoopEdge, SelfLoopOpposingSegment> opposingSegments = new HashMap<>();
private final Map<SelfLoopEdge, SelfLoopOpposingSegment> opposingSegments = new HashMap<>();
/** The roots of the component dependency graph. They hold the outermost components of the node side. */
private Set<SelfLoopComponent> componentDependencies = new HashSet<>();
private final Set<SelfLoopComponent> componentDependencies = new HashSet<>();


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public class SelfLoopPort {
/** The level of the edge segment. */
private int maximumLevel = 0;
/** Map about the different level for the different edges connected to this port. */
private Map<LEdge, Integer> edgeToLevelMap = new HashMap<>();
private final Map<LEdge, Integer> edgeToLevelMap = new HashMap<>();
/** The SelfLoopComponent the port belongs to. */
private SelfLoopComponent component;
/** Self loops connected to this port. */
private List<SelfLoopEdge> connectedEdges = new ArrayList<>();
private final List<SelfLoopEdge> connectedEdges = new ArrayList<>();
/** The port is connected to an edge connecting it to another node. */
private boolean isNonLoopPort = false;
/** The original index of the port before using the linear node representation or altering the port order. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static void calculateEdgeDependecies(final List<SelfLoopComponent> compon
List<SelfLoopPort> sidePorts = component.getPortsOfSide(currentSide);

// filter non-loop components
if (component.getPorts().size() > 1) {
if (ports.size() > 1) {
List<SelfLoopEdge> dependencies = calculateEdgeOrder(
ports, sidePorts, new HashSet<SelfLoopEdge>(), currentSide, false);
component.getEdgeDependencies().put(currentSide, dependencies);
Expand Down