20 package net.sf.gridarta.actions;
23 import java.io.IOException;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27 import java.util.regex.Matcher;
41 import org.jetbrains.annotations.NotNull;
42 import org.jetbrains.annotations.Nullable;
86 if (mapModel.getMapFile() ==
null) {
91 final List<MapControl<G, A, R>> mapControls =
new ArrayList<>(tilePaths.length);
109 if (mapControl !=
null) {
126 for (@Nullable
final String tilePath : tilePaths) {
128 if (tilePath !=
null && !tilePath.isEmpty()) {
131 }
catch (
final IOException ex) {
137 mapControls.add(mapControl);
149 if (mapControl !=
null) {
151 if (mapControl.getMapModel().isModified()) {
154 }
catch (
final IOException e) {
155 final MapFile mapFile = mapControl.getMapModel().getMapFile();
156 assert mapFile !=
null;
169 boolean repeatFlag =
true;
172 for (
int i = 0; i < mapControls.size(); i++) {
174 if (mapControl !=
null) {
177 for (
final MapLink mapLink : mapLinks) {
178 final Direction direction = mapLink.getMapDirection();
179 if (mapControls.get(direction.ordinal()) ==
null) {
181 if (!tilePath.isEmpty()) {
185 }
catch (
final IOException ex) {
205 final Size2D mapSize = mapModel.getMapArchObject().getMapSize();
207 if (mapControl !=
null) {
211 if (!mapSize.
equals(otherMapSize)) {
214 for (
int ii = 0; ii < 2; ii++) {
230 for (
int i = 0; i < tilePaths.length; i++) {
232 if (mapControl !=
null) {
235 final String canonicalMapPath1 = mapModel.getMapFile().getFile().getPath();
236 final String link1 =
getTilePath(canonicalMapPath1, canonicalMapPath2, mapsDirectory);
238 tilePaths[i] = link1;
240 final String link2 =
getTilePath(canonicalMapPath2, canonicalMapPath1, mapsDirectory);
267 final MapFile mapFile = mapModel.getMapFile();
268 if (mapFile ==
null) {
287 final CharSequence mapDirectory;
289 mapDirectory = mapsDirectory.getCanonicalPath();
290 }
catch (
final IOException e) {
293 final String first = base.substring(mapDirectory.length(), pos).trim();
294 final String second = link.substring(mapDirectory.length(), pos2).trim();
296 final String sep = Matcher.quoteReplacement(File.separator);
299 if (first.isEmpty()) {
300 return link.substring(mapDirectory.length()).trim().replaceAll(sep,
"/");
303 if (first.compareTo(second) == 0) {
304 return link.substring(pos2 + 1).trim().replaceAll(sep,
"/");
307 if (second.startsWith(first)) {
308 return link.substring(pos + 1).trim().replaceAll(sep,
"/");
311 return link.substring(mapDirectory.length()).trim().replaceAll(sep,
"/");
321 return Math.max(base.lastIndexOf(File.separator), base.lastIndexOf(
'/'));