private void distribute(AddressNodeGroup group) { List<AddressNode> nodes = group.getAddressNodes(); Collections.sort(nodes, addressNodeComparator); Coordinate start = group.getGeometry().getCoordinate(); // center of the building Coordinate center = group.getBuilding().getGeometry().getCentroid().getCoordinate(); double dx; double dy; if (start.equals(center)) { // if the nodes are at the center of the building, use an angle of 45 degrees dx = SQRT2 * DISTANCE; dy = SQRT2 * DISTANCE; } else { double angle = new LineSegment(start, center).angle(); dx = Math.cos(angle) * DISTANCE; dy = Math.sin(angle) * DISTANCE; } double x = group.getGeometry().getX(); double y = group.getGeometry().getY(); // List<Command> cmds = new LinkedList<>(); for (AddressNode node : nodes) { Point point = geoUtil.toPoint(new Coordinate(x, y)); node.setGeometry(point); // Command cmd = node.updateGeometry(point); // if (cmd != null) { // cmds.add(cmd); // } x = x + dx; y = y + dy; } // if (!nodes.isEmpty()) { // final SequenceCommand sequenceCommand = new SequenceCommand( // I18n.tr("Distribute {0} address nodes.", cmds.size()), cmds); // Main.main.undoRedo.add(sequenceCommand); // } }