20 package net.sf.gridarta.gui.map.mapview;
22 import java.awt.Dimension;
23 import java.awt.Point;
24 import java.awt.Rectangle;
25 import java.util.ArrayList;
26 import java.util.Collection;
27 import java.util.List;
29 import javax.swing.JScrollPane;
42 import org.jetbrains.annotations.NotNull;
43 import org.jetbrains.annotations.Nullable;
77 public void mapSizeChanged(@NotNull
final Size2D newSize) {
87 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
97 public void mapFileChanged(@Nullable
final MapFile oldMapFile) {
102 public void modifiedChanged() {
131 final List<MapSquare<G, A, R>> selection =
new ArrayList<>();
132 for (
final Point pos : selectedMapSquares) {
142 final List<G> objects =
new ArrayList<>();
143 for (
final Iterable<G> mapSquare : selectedMapSquares) {
145 objects.add(gameObject.getHead());
156 final int objectSize = objects.size();
157 return objectSize == 0 ? null : objects.get(objectSize == 1 ? 0 :
RandomUtils.
RND.nextInt(objects.size()));
175 if (point.x >= mapSize.
getWidth()) {
177 }
else if (point.x < 0) {
182 }
else if (point.y < 0) {
192 final Dimension extentSize = scrollPane.getViewport().getExtentSize();
193 final Point centerPoint =
new Point(Math.max(0, squareBounds.x + squareBounds.width / 2 - extentSize.width / 2), Math.max(0, squareBounds.y + squareBounds.height / 2 - extentSize.height / 2));
194 scrollPane.getViewport().setViewPosition(centerPoint);