import java.util.ArrayList;
import java.util.Collections;
+import java.util.Comparator;
import java.util.List;
import java.util.Map;
}
/**
+ *
+ */
+ public static class PortComparator implements Comparator<BasicPort> {
+ @Override
+ public int compare(BasicPort arg0, BasicPort arg1) {
+ int order_0 = arg0.getOrdering();
+ int order_1 = arg1.getOrdering();
+
+ if (order_0 < order_1) {
+ return -1;
+ } else if (order_0 > order_1) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+ }
+
+ /**
* Dispatch ports on Block's _WEST_ side.
*
* @param block
gridSize = block.getParentDiagram().getGridSize();
}
+ // BasicBlock.sortsort(List<?> children) takes into account different
+ // parameters to order the ports list. We only need to order the ports
+ // given their ordering.
+ Collections.sort(ports, new PortComparator());
+
final mxGeometry blockGeom = block.getGeometry();
assert blockGeom != null;
final int portsSize = ports.size();
final mxGeometry portGeom = port.getGeometry();
double nonVariantPosition = -portGeom.getWidth();
- final int order;
- if (port.getOrdering() <= portsSize) {
- order = port.getOrdering() - 1;
- } else {
- order = i;
- }
+ final int order = i;
double alignedPosition = calculateAlignedPosition(gridSize, segLength, order);
portGeom.setX(nonVariantPosition);
gridSize = block.getParentDiagram().getGridSize();
}
+ // BasicBlock.sortsort(List<?> children) takes into account different
+ // parameters to order the ports list. We only need to order the ports
+ // given their ordering.
+ Collections.sort(ports, new PortComparator());
+
final mxGeometry blockGeom = block.getGeometry();
assert blockGeom != null;
final int portsSize = ports.size();
final mxGeometry portGeom = port.getGeometry();
double nonVariantPosition = -portGeom.getHeight();
- final int order;
- if (port.getOrdering() <= portsSize) {
- order = port.getOrdering() - 1;
- } else {
- order = i;
- }
+ final int order = i;
double alignedPosition = calculateAlignedPosition(gridSize, segLength, order);
portGeom.setX(alignedPosition);
gridSize = block.getParentDiagram().getGridSize();
}
+ // BasicBlock.sortsort(List<?> children) takes into account different
+ // parameters to order the ports list. We only need to order the ports
+ // given their ordering.
+ Collections.sort(ports, new PortComparator());
+
final mxGeometry blockGeom = block.getGeometry();
assert blockGeom != null;
final int portsSize = ports.size();
final mxGeometry portGeom = port.getGeometry();
double nonVariantPosition = blockGeom.getWidth();
- final int order;
- if (port.getOrdering() <= portsSize) {
- order = port.getOrdering() - 1;
- } else {
- order = i;
- }
+ final int order = i;
double alignedPosition = calculateAlignedPosition(gridSize, segLength, order);
portGeom.setX(nonVariantPosition);
gridSize = block.getParentDiagram().getGridSize();
}
+ // BasicBlock.sortsort(List<?> children) takes into account different
+ // parameters to order the ports list. We only need to order the ports
+ // given their ordering.
+ Collections.sort(ports, new PortComparator());
+
final mxGeometry blockGeom = block.getGeometry();
assert blockGeom != null;
final int portsSize = ports.size();
final mxGeometry portGeom = port.getGeometry();
double nonVariantPosition = blockGeom.getHeight();
- final int order;
- if (port.getOrdering() <= portsSize) {
- order = port.getOrdering() - 1;
- } else {
- order = i;
- }
+ final int order = i;
double alignedPosition = calculateAlignedPosition(gridSize, segLength, order);
portGeom.setX(alignedPosition);