/** * Adds all target ports and than all source ports of the components of given {@link LoopSide} * of this component-holder to the current position of the {@link ListIterator}. The source * ports will be added in reversed order. * * @param loopSide The components of this {@link LoopSide} will be added. * @param itr The {@link ListIterator} to add the ports into. */ public void addAllPorts( final LoopSide loopSide, final ListIterator<LPort> itr, final boolean sourceFirst) { final List<LPort> secondPart = Lists.newArrayList(); PortSide secondPartSide = null; if (sourceFirst) { for (final ConnectedSelfLoopComponent component : LISTS_OF_COMPONENTS.get(loopSide)) { for (final LPort port : component.getSourceLoopPorts()) { itr.add(port); setSideOfPort(port, loopSide.getSourceSide()); } secondPart.addAll(component.getTargetLoopPorts()); secondPartSide = loopSide.getTargetSide(); } } else { for (final ConnectedSelfLoopComponent component : LISTS_OF_COMPONENTS.get(loopSide)) { for (final LPort port : component.getTargetLoopPorts()) { itr.add(port); setSideOfPort(port, loopSide.getTargetSide()); } secondPart.addAll(component.getSourceLoopPorts()); secondPartSide = loopSide.getSourceSide(); } } Collections.reverse(secondPart); setSideOfPorts(secondPart, secondPartSide); for (final LPort port : secondPart) { itr.add(port); } }
/** * Adds all ports of given {@link LoopSide} of this component-holder to the current position of * the {@link ListIterator}. The ports are placed, so that source and target ports of an edge * are placed next to each other. The target port of an edge will be places before the source * port of an edge. * * @param loopSide The components of this {@link LoopSide} will be added. * @param itr The {@link ListIterator} to add the ports into. */ public void addInlineTargetsFirst(final LoopSide loopSide, final ListIterator<LPort> itr) { final List<LPort> firstPart = Lists.newArrayList(); final List<LPort> secondPart = Lists.newArrayList(); final Iterator<ConnectedSelfLoopComponent> compItr = LISTS_OF_COMPONENTS.get(loopSide).iterator(); while (compItr.hasNext()) { ConnectedSelfLoopComponent component = compItr.next(); firstPart.addAll(0, component.getSourceLoopPorts()); firstPart.addAll(0, component.getTargetLoopPortsReversed()); if (compItr.hasNext()) { component = compItr.next(); secondPart.addAll(component.getTargetLoopPortsReversed()); secondPart.addAll(component.getSourceLoopPorts()); } } setSideOfPorts(firstPart, loopSide.getTargetSide()); setSideOfPorts(secondPart, loopSide.getSourceSide()); for (final LPort port : firstPart) { itr.add(port); } for (final LPort port : secondPart) { itr.add(port); } }
/** * Adds all target ports of the components of given {@link LoopSide} of this component-holder to * the current position of the {@link ListIterator}. * * @param loopSide The components of this {@link LoopSide} will be added. * @param itr The {@link ListIterator} to add the ports into. */ public void addTargetPorts(final LoopSide loopSide, final ListIterator<LPort> itr) { final PortSide portSide = loopSide.getTargetSide(); for (final ConnectedSelfLoopComponent component : LISTS_OF_COMPONENTS.get(loopSide)) { for (final LPort port : component.getTargetLoopPorts()) { itr.add(port); setSideOfPort(port, portSide); } } }