20 package net.sf.gridarta.gui.misc;
22 import java.awt.Point;
23 import java.awt.Rectangle;
24 import java.util.Collection;
25 import java.util.LinkedList;
26 import java.util.List;
38 import org.jetbrains.annotations.NotNull;
39 import org.jetbrains.annotations.Nullable;
159 final Point pos =
new Point();
250 throw new IllegalArgumentException(
"unsupported direction: " + dir);
271 private void shift(
final Point pos,
final int len) {
272 final Point prevPos =
new Point(pos.x +
dx, pos.y +
dy);
273 final Point startPos =
new Point();
276 assert !startSelection;
277 boolean isStart =
true;
278 final Collection<G> startGameObjects =
new LinkedList<>();
279 final List<GameObject<G, A, R>> gameObjectsToDelete =
new LinkedList<>();
280 final Collection<G> gameObjectsToInsert =
new LinkedList<>();
281 for (
int i = 0; i < len; i++) {
286 gameObjectsToInsert.clear();
290 startPos.setLocation(prevPos);
292 assert startGameObjects.isEmpty();
295 startGameObjects.add(gameObject);
296 gameObjectsToDelete.add(gameObject);
303 gameObjectsToInsert.add(gameObject);
304 gameObjectsToDelete.add(gameObject);
313 gameObjectsToInsert.addAll(startGameObjects);
314 startGameObjects.clear();
320 while (!gameObjectsToDelete.isEmpty()) {
321 gameObjectsToDelete.remove(0).remove();
324 prevPos.setLocation(pos);
332 assert startGameObjects.isEmpty();
343 private void insertAllAndClear(@NotNull
final Collection<G> gameObjects, @NotNull
final Point point) {
344 for (
final G gameObject : gameObjects) {