Gridarta Editor
MainActions.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.mainactions;
21 
22 import java.awt.Point;
23 import java.awt.Rectangle;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.IdentityHashMap;
27 import java.util.List;
28 import java.util.Map;
29 import java.util.Set;
30 import javax.swing.Action;
31 import javax.swing.JFrame;
64 import net.sf.gridarta.utils.Size2D;
65 import net.sf.japi.swing.action.ActionMethod;
66 import org.jetbrains.annotations.NotNull;
67 import org.jetbrains.annotations.Nullable;
68 
73 public class MainActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction, MapViewManagerListener<G, A, R> {
74 
78  @NotNull
80 
84  @NotNull
86 
90  @NotNull
91  private final JFrame parent;
92 
96  @NotNull
98 
102  @NotNull
104 
108  @NotNull
110 
114  @NotNull
116 
120  @Nullable
121  private Action aClear;
122 
126  @Nullable
127  private Action aCut;
128 
132  @Nullable
133  private Action aCopy;
134 
138  @Nullable
139  private Action aShiftNorth;
140 
144  @Nullable
145  private Action aShiftNorthEast;
146 
150  @Nullable
151  private Action aShiftEast;
152 
156  @Nullable
157  private Action aShiftSouthEast;
158 
162  @Nullable
163  private Action aShiftSouth;
164 
168  @Nullable
169  private Action aShiftSouthWest;
170 
174  @Nullable
175  private Action aShiftWest;
176 
180  @Nullable
181  private Action aShiftNorthWest;
182 
186  @Nullable
187  private Action aPaste;
188 
192  @Nullable
193  private Action aPasteTiled;
194 
198  @Nullable
199  private Action aFind;
200 
204  @Nullable
205  private Action aFindNext;
206 
210  @Nullable
211  private Action aFindPrev;
212 
216  @Nullable
217  private Action aReplace;
218 
222  @Nullable
223  private Action aFillAuto;
224 
228  @Nullable
229  private Action aFillAbove;
230 
234  @Nullable
235  private Action aFillBelow;
236 
240  @Nullable
241  private Action aRandFillAuto;
242 
246  @Nullable
247  private Action aRandFillAbove;
248 
252  @Nullable
253  private Action aRandFillBelow;
254 
258  @Nullable
259  private Action aFloodFill;
260 
264  @Nullable
265  private Action aMassChange;
266 
270  @Nullable
271  private Action aSelectAll;
272 
276  @Nullable
277  private Action aInvertSelection;
278 
282  @Nullable
283  private Action aExpandEmptySelection;
284 
288  @Nullable
289  private Action aTileStretchingSet;
290 
294  @Nullable
295  private Action aTileStretchingClear;
296 
300  @Nullable
301  private Action aTileStretchingIncrease;
302 
306  @Nullable
307  private Action aTileStretchingDecrease;
308 
312  @NotNull
314 
318  @NotNull
320 
324  @NotNull
326 
330  @Nullable
332 
336  @Nullable
338 
342  @NotNull
344 
345  @Override
346  public void mapGridChanged(@NotNull final MapGridEvent e) {
347  refreshMenus(); // selection state may have changed
348  }
349 
350  @Override
351  public void mapGridResized(@NotNull final MapGridEvent e) {
352  // ignore
353  }
354 
355  };
356 
369  public MainActions(@NotNull final FindDialogManager<G, A, R> findDialogManager, @NotNull final ReplaceDialogManager<G, A, R> replaceDialogManager, @NotNull final JFrame parent, @NotNull final MapViewSettings mapViewSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) {
370  this.findDialogManager = findDialogManager;
371  this.replaceDialogManager = replaceDialogManager;
372  this.parent = parent;
373  this.mapViewSettings = mapViewSettings;
374  this.copyBuffer = copyBuffer;
375  this.objectChooser = objectChooser;
376  this.insertionModeSet = insertionModeSet;
377 
378  mapManager.addMapManagerListener(newMapManagerListener());
379  currentMapControl = mapManager.getCurrentMap();
380 
381  archetypeSet.addArchetypeSetListener(this::refreshMenus);
383  }
384 
390  @NotNull
392  return new MapManagerListener<G, A, R>() {
393 
394  @Override
395  public void currentMapChanged(@Nullable final MapControl<G, A, R> mapControl) {
396  currentMapControl = mapControl;
397  refreshMenus();
398  }
399 
400  @Override
401  public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) {
402  // ignore: a current map changed event will be generated
403  }
404 
405  @Override
406  public void mapClosing(@NotNull final MapControl<G, A, R> mapControl) {
407  // ignore: a current map changed event will be generated
408  }
409 
410  @Override
411  public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) {
412  // ignore: a current map changed event will be generated
413  }
414 
415  };
416  }
417 
423  @NotNull
425  return new MapModelListener<G, A, R>() {
426 
427  @Override
428  public void mapSizeChanged(@NotNull final Size2D newSize) {
429  // ignore
430  }
431 
432  @Override
433  public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) {
434  refreshMenus();
435  }
436 
437  @Override
438  public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) {
439  // ignore
440  }
441 
442  @Override
443  public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) {
444  // ignore
445  }
446 
447  @Override
448  public void mapFileChanged(@Nullable final MapFile oldMapFile) {
449  // ignore
450  }
451 
452  @Override
453  public void modifiedChanged() {
454  // ignore
455  }
456 
457  };
458  }
459 
463  private void refreshMenus() {
464  if (aClear != null) {
465  aClear.setEnabled(doClear(false));
466  }
467  if (aCut != null) {
468  aCut.setEnabled(doCut(false));
469  }
470  if (aCopy != null) {
471  aCopy.setEnabled(doCopy(false));
472  }
473  if (aPaste != null) {
474  aPaste.setEnabled(doPaste(false));
475  }
476  if (aPasteTiled != null) {
477  aPasteTiled.setEnabled(doPasteTiled(false));
478  }
479  if (aShiftNorth != null) {
480  aShiftNorth.setEnabled(doShift(false, Direction.NORTH));
481  }
482  if (aShiftNorthEast != null) {
483  aShiftNorthEast.setEnabled(doShift(false, Direction.NORTH_EAST));
484  }
485  if (aShiftEast != null) {
486  aShiftEast.setEnabled(doShift(false, Direction.EAST));
487  }
488  if (aShiftSouthEast != null) {
489  aShiftSouthEast.setEnabled(doShift(false, Direction.SOUTH_EAST));
490  }
491  if (aShiftSouth != null) {
492  aShiftSouth.setEnabled(doShift(false, Direction.SOUTH));
493  }
494  if (aShiftSouthWest != null) {
495  aShiftSouthWest.setEnabled(doShift(false, Direction.SOUTH_WEST));
496  }
497  if (aShiftWest != null) {
498  aShiftWest.setEnabled(doShift(false, Direction.WEST));
499  }
500  if (aShiftNorthWest != null) {
501  aShiftNorthWest.setEnabled(doShift(false, Direction.NORTH_WEST));
502  }
503  if (aFind != null) {
504  aFind.setEnabled(doFind(false));
505  }
506  if (aFindNext != null) {
507  aFindNext.setEnabled(doFindNext(false));
508  }
509  if (aFindPrev != null) {
510  aFindPrev.setEnabled(doFindPrev(false));
511  }
512  if (aReplace != null) {
513  aReplace.setEnabled(doReplace(false));
514  }
515  if (aFillAuto != null) {
516  aFillAuto.setEnabled(doFillAuto(false));
517  }
518  if (aFillAbove != null) {
519  aFillAbove.setEnabled(doFillAbove(false));
520  }
521  if (aFillBelow != null) {
522  aFillBelow.setEnabled(doFillBelow(false));
523  }
524  if (aRandFillAuto != null) {
525  aRandFillAuto.setEnabled(doRandFillAuto(false));
526  }
527  if (aRandFillAbove != null) {
528  aRandFillAbove.setEnabled(doRandFillAbove(false));
529  }
530  if (aRandFillBelow != null) {
531  aRandFillBelow.setEnabled(doRandFillBelow(false));
532  }
533  if (aFloodFill != null) {
534  aFloodFill.setEnabled(doFloodFill(false));
535  }
536  if (aMassChange != null) {
537  aMassChange.setEnabled(doMassChange(false));
538  }
539  if (aSelectAll != null) {
540  aSelectAll.setEnabled(doSelectAll(false));
541  }
542  if (aInvertSelection != null) {
543  aInvertSelection.setEnabled(doInvertSelection(false));
544  }
545  if (aExpandEmptySelection != null) {
547  }
548  if (aTileStretchingSet != null) {
550  }
551  if (aTileStretchingClear != null) {
552  aTileStretchingClear.setEnabled(doTileStretchingChange(false, 0, true));
553  }
554  if (aTileStretchingIncrease != null) {
555  aTileStretchingIncrease.setEnabled(doTileStretchingChange(false, 1, false));
556  }
557  if (aTileStretchingDecrease != null) {
558  aTileStretchingDecrease.setEnabled(doTileStretchingChange(false, -1, false));
559  }
560  }
561 
565  @ActionMethod
566  public void clear() {
567  doClear(true);
568  }
569 
573  @ActionMethod
574  public void cut() {
575  doCut(true);
576  }
577 
581  @ActionMethod
582  public void copy() {
583  doCopy(true);
584  }
585 
589  @ActionMethod
590  public void paste() {
591  doPaste(true);
592  }
593 
597  @ActionMethod
598  public void pasteTiled() {
599  doPasteTiled(true);
600  }
601 
605  @ActionMethod
606  public void shiftNorth() {
607  doShift(true, Direction.NORTH);
608  }
609 
613  @ActionMethod
614  public void shiftNorthEast() {
616  }
617 
621  @ActionMethod
622  public void shiftEast() {
623  doShift(true, Direction.EAST);
624  }
625 
629  @ActionMethod
630  public void shiftSouthEast() {
632  }
633 
637  @ActionMethod
638  public void shiftSouth() {
639  doShift(true, Direction.SOUTH);
640  }
641 
645  @ActionMethod
646  public void shiftSouthWest() {
648  }
649 
653  @ActionMethod
654  public void shiftWest() {
655  doShift(true, Direction.WEST);
656  }
657 
661  @ActionMethod
662  public void shiftNorthWest() {
664  }
665 
669  @ActionMethod
670  public void find() {
671  doFind(true);
672  }
673 
677  @ActionMethod
678  public void findNext() {
679  doFindNext(true);
680  }
681 
685  @ActionMethod
686  public void findPrev() {
687  doFindPrev(true);
688  }
689 
693  @ActionMethod
694  public void replace() {
695  doReplace(true);
696  }
697 
701  @ActionMethod
702  public void fillAuto() {
703  doFillAuto(true);
704  }
705 
709  @ActionMethod
710  public void fillAbove() {
711  doFillAbove(true);
712  }
713 
717  @ActionMethod
718  public void fillBelow() {
719  doFillBelow(true);
720  }
721 
725  @ActionMethod
726  public void randFillAuto() {
727  doRandFillAuto(true);
728  }
729 
733  @ActionMethod
734  public void randFillAbove() {
735  doRandFillAbove(true);
736  }
737 
741  @ActionMethod
742  public void randFillBelow() {
743  doRandFillBelow(true);
744  }
745 
749  @ActionMethod
750  public void floodFill() {
751  doFloodFill(true);
752  }
753 
757  @ActionMethod
758  public void massChange() {
759  doMassChange(true);
760  }
761 
765  @ActionMethod
766  public void selectAll() {
767  doSelectAll(true);
768  }
769 
773  @ActionMethod
774  public void invertSelection() {
775  doInvertSelection(true);
776  }
777 
782  @ActionMethod
783  public void expandEmptySelection() {
785  }
786 
791  @ActionMethod
792  public void tileStretchingSet() {
794  }
795 
800  @ActionMethod
801  public void tileStretchingClear() {
802  doTileStretchingChange(true, 0, true);
803  }
804 
809  @ActionMethod
810  public void tileStretchingIncrease() {
811  doTileStretchingChange(true, 1, false);
812  }
813 
818  @ActionMethod
819  public void tileStretchingDecrease() {
820  doTileStretchingChange(true, -1, false);
821  }
822 
827  @Nullable
829  return currentMapView != null && currentMapView.getMapGrid().getSelectedRec() != null ? currentMapView : null;
830  }
831 
837  private boolean doFind(final boolean performAction) {
838  final MapView<G, A, R> mapView = currentMapView;
839  if (mapView == null) {
840  return false;
841  }
842 
843  if (performAction) {
844  findDialogManager.showDialog(mapView);
845  }
846 
847  return true;
848  }
849 
855  private boolean doFindNext(final boolean performAction) {
856  final MapView<G, A, R> mapView = currentMapView;
857  return mapView != null && findDialogManager.findNext(mapView, performAction);
858  }
859 
865  private boolean doFindPrev(final boolean performAction) {
866  final MapView<G, A, R> mapView = currentMapView;
867  return mapView != null && findDialogManager.findPrev(mapView, performAction);
868  }
869 
875  private boolean doReplace(final boolean performAction) {
876  final MapView<G, A, R> mapView = currentMapView;
877  if (mapView == null) {
878  return false;
879  }
880 
881  if (performAction) {
883  }
884 
885  return true;
886  }
887 
893  private boolean doClear(final boolean performAction) {
894  final MapView<G, A, R> mapView = currentMapView;
895  if (mapView == null) {
896  return false;
897  }
898 
899  final Rectangle selectedRec = mapView.getMapGrid().getSelectedRec();
900  if (selectedRec == null) {
901  return false;
902  }
903 
904  if (performAction) {
905  copyBuffer.clear(mapView, selectedRec);
906  }
907 
908  return true;
909  }
910 
916  private boolean doCut(final boolean performAction) {
917  final MapView<G, A, R> mapView = currentMapView;
918  if (mapView == null) {
919  return false;
920  }
921 
922  final Rectangle selectedRec = mapView.getMapGrid().getSelectedRec();
923  if (selectedRec == null) {
924  return false;
925  }
926 
927  if (performAction) {
928  copyBuffer.cut(mapView, selectedRec);
929  }
930 
931  return true;
932  }
933 
939  private boolean doCopy(final boolean performAction) {
940  final MapView<G, A, R> mapView = currentMapView;
941  if (mapView == null) {
942  return false;
943  }
944 
945  final Rectangle selectedRec = mapView.getMapGrid().getSelectedRec();
946  if (selectedRec == null) {
947  return false;
948  }
949 
950  if (performAction) {
951  copyBuffer.copy(mapView, selectedRec);
952  }
953 
954  return true;
955  }
956 
962  private boolean doPaste(final boolean performAction) {
963  final MapView<G, A, R> mapView = currentMapView;
964  if (mapView == null) {
965  return false;
966  }
967 
968  final Point startLocation = mapView.getMapCursor().getLocation();
969  if (copyBuffer.isEmpty()) {
970  return false;
971  }
972 
973  if (performAction) {
974  copyBuffer.paste(mapView, startLocation);
975  }
976 
977  return true;
978  }
979 
985  private boolean doPasteTiled(final boolean performAction) {
986  final MapView<G, A, R> mapView = currentMapView;
987  if (mapView == null) {
988  return false;
989  }
990 
991  if (copyBuffer.isEmpty()) {
992  return false;
993  }
994 
995  final List<MapSquare<G, A, R>> selectedSquares = mapView.getSelectedSquares();
996  if (selectedSquares.isEmpty()) {
997  return false;
998  }
999 
1000  final MapGrid mapGrid = mapView.getMapGrid();
1001  final Rectangle selectedRec = mapGrid.getSelectedRec();
1002  if (selectedRec == null) {
1003  return false;
1004  }
1005 
1006  if (performAction) {
1007  final Point cursorLocation = mapView.getMapCursor().getLocation();
1008  copyBuffer.pasteTiled(mapView, selectedSquares, cursorLocation);
1009  }
1010 
1011  return true;
1012  }
1013 
1020  private boolean doShift(final boolean performAction, @NotNull final Direction direction) {
1021  final MapControl<G, A, R> mapControl = currentMapControl;
1022  if (mapControl == null) {
1023  return false;
1024  }
1025 
1026  final MapView<G, A, R> mapView = currentMapView;
1027  if (mapView == null) {
1028  return false;
1029  }
1030 
1031  final ShiftProcessor<G, A, R> shiftProcessor = new ShiftProcessor<>(mapViewSettings, mapView, mapControl.getMapModel(), insertionModeSet);
1032  if (!shiftProcessor.canShift(direction)) {
1033  return false;
1034  }
1035 
1036  if (performAction) {
1037  shiftProcessor.shift(direction);
1038  }
1039 
1040  return true;
1041  }
1042 
1048  private boolean doFillAuto(final boolean performAction) {
1049  final MapView<G, A, R> mapView = getSelection();
1050  if (mapView == null) {
1051  return false;
1052  }
1053 
1054  if (performAction) {
1056  }
1057 
1058  return true;
1059  }
1060 
1066  private boolean doFillAbove(final boolean performAction) {
1067  final MapView<G, A, R> mapView = getSelection();
1068  if (mapView == null) {
1069  return false;
1070  }
1071 
1072  if (performAction) {
1074  }
1075 
1076  return true;
1077  }
1078 
1084  private boolean doFillBelow(final boolean performAction) {
1085  final MapView<G, A, R> mapView = getSelection();
1086  if (mapView == null) {
1087  return false;
1088  }
1089 
1090  if (performAction) {
1092  }
1093 
1094  return true;
1095  }
1096 
1102  private boolean doRandFillAuto(final boolean performAction) {
1103  final MapView<G, A, R> mapView = getSelection();
1104  if (mapView == null) {
1105  return false;
1106  }
1107 
1108  if (performAction) {
1110  }
1111 
1112  return true;
1113  }
1114 
1120  private boolean doRandFillAbove(final boolean performAction) {
1121  final MapView<G, A, R> mapView = getSelection();
1122  if (mapView == null) {
1123  return false;
1124  }
1125 
1126  if (performAction) {
1128  }
1129 
1130  return true;
1131  }
1132 
1138  private boolean doRandFillBelow(final boolean performAction) {
1139  final MapView<G, A, R> mapView = getSelection();
1140  if (mapView == null) {
1141  return false;
1142  }
1143 
1144  if (performAction) {
1146  }
1147 
1148  return true;
1149  }
1150 
1156  private boolean doFloodFill(final boolean performAction) {
1157  final MapView<G, A, R> mapView = currentMapView;
1158  if (mapView == null) {
1159  return false;
1160  }
1161 
1162  final Point mapCursorLocation = mapView.getMapCursor().getLocation();
1163  if (performAction) {
1165  }
1166 
1167  return true;
1168  }
1169 
1175  private boolean doMassChange(final boolean performAction) {
1176  final MapView<G, A, R> mapView = getSelection();
1177  if (mapView == null) {
1178  return false;
1179  }
1180 
1181  if (performAction) {
1183  return false;
1184  }
1185 
1186  final String[] archNames = massChangeDialog.getArchNames();
1187  final String[] names = massChangeDialog.getNames();
1188  final Integer[] layers = massChangeDialog.getLayers();
1189  final Integer[] subLayers = massChangeDialog.getSubLayers();
1190  final String changes = massChangeDialog.getChanges();
1191 
1192  final Collection<MatchCriteria<G, A, R>> matchCriteriaArch = new ArrayList<>(archNames.length);
1193  for (final String archName : archNames) {
1194  matchCriteriaArch.add(new ArchetypeNameMatchCriteria<>(archName));
1195  }
1196 
1197  final Collection<MatchCriteria<G, A, R>> matchCriteriaName = new ArrayList<>(names.length);
1198  for (final String name : names) {
1199  matchCriteriaName.add(new ObjectNameMatchCriteria<>(name));
1200  }
1201 
1202  final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel();
1203 
1204  mapModel.beginTransaction("Mass change"); // TODO; I18N/L10N
1205  try {
1206  for (final MapSquare<G, A, R> mapSquare : mapView.getSelectedSquares()) {
1207  for (final GameObject<G, A, R> gameObject : mapSquare) {
1208  boolean doModify = false;
1209 
1210  if (matchCriteriaArch.isEmpty() && matchCriteriaName.isEmpty()) {
1211  doModify = true;
1212  }
1213 
1214  for (final MatchCriteria<G, A, R> matchCriteria : matchCriteriaArch) {
1215  if (matchCriteria.matches(gameObject.getHead())) {
1216  doModify = true;
1217  break;
1218  }
1219  }
1220 
1221  for (final MatchCriteria<G, A, R> matchCriteria : matchCriteriaName) {
1222  if (!matchCriteria.matches(gameObject.getHead())) {
1223  doModify = true;
1224  break;
1225  }
1226  }
1227 
1228  if (!doModify) {
1229  continue;
1230  }
1231 
1232  gameObject.applyMassChange(layers, subLayers, changes);
1233  }
1234  }
1235  } finally {
1236  mapModel.endTransaction();
1237  }
1238  }
1239 
1240  return true;
1241  }
1242 
1248  private boolean doSelectAll(final boolean performAction) {
1249  if (currentMapView == null) {
1250  return false;
1251  }
1252 
1253  if (performAction) {
1255  }
1256 
1257  return true;
1258  }
1259 
1265  private boolean doInvertSelection(final boolean performAction) {
1266  if (currentMapView == null) {
1267  return false;
1268  }
1269 
1270  if (performAction) {
1272  }
1273 
1274  return true;
1275  }
1276 
1282  private boolean doExpandEmptySelection(final boolean performAction) {
1283  final MapView<G, A, R> mapView = getSelection();
1284  if (mapView == null) {
1285  return false;
1286  }
1287 
1288  boolean foundEmptySelectedSquare = false;
1289  final List<MapSquare<G, A, R>> selectedSquares = mapView.getSelectedSquares();
1290  for (final MapSquare<G, A, R> selectedSquare : selectedSquares) {
1291  if (selectedSquare.isEmpty()) {
1292  foundEmptySelectedSquare = true;
1293  break;
1294  }
1295  }
1296  if (!foundEmptySelectedSquare) {
1297  return false;
1298  }
1299 
1300  if (performAction) {
1301  final Map<MapSquare<G, A, R>, Void> newSelection = new IdentityHashMap<>();
1302  Map<MapSquare<G, A, R>, Void> todo = new IdentityHashMap<>();
1303  for (final MapSquare<G, A, R> mapSquare : selectedSquares) {
1304  todo.put(mapSquare, null);
1305  newSelection.put(mapSquare, null);
1306  }
1307  final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel();
1308  final MapArchObject<A> mapArchObject = mapModel.getMapArchObject();
1309  final Point point = new Point();
1310  while (!todo.isEmpty()) {
1311  final Map<MapSquare<G, A, R>, Void> tmp = new IdentityHashMap<>();
1312  for (final MapSquare<G, A, R> mapSquare : todo.keySet()) {
1313  for (int dy = -1; dy <= 1; dy++) {
1314  for (int dx = -1; dx <= 1; dx++) {
1315  if (dx != 0 || dy != 0) {
1316  mapSquare.getMapLocation(point, dx, dy);
1317  if (mapArchObject.isPointValid(point)) {
1318  final MapSquare<G, A, R> newMapSquare = mapModel.getMapSquare(point);
1319  if (newMapSquare.isEmpty() && !newSelection.containsKey(newMapSquare)) {
1320  tmp.put(newMapSquare, null);
1321  newSelection.put(newMapSquare, null);
1322  }
1323  }
1324  }
1325  }
1326  }
1327  }
1328  todo = tmp;
1329  }
1330  final MapGrid mapGrid = mapView.getMapGrid();
1331  mapGrid.beginTransaction();
1332  try {
1333  mapGrid.unSelect();
1334  for (final MapSquare<G, A, R> mapSquare : newSelection.keySet()) {
1335  mapSquare.getMapLocation(point);
1336  mapGrid.select(point, SelectionMode.ADD);
1337  }
1338  } finally {
1339  mapGrid.endTransaction();
1340  }
1341  }
1342 
1343  return true;
1344  }
1345 
1351  private boolean doTileStretchingChangeSet(final boolean performAction) {
1352  final MapView<G, A, R> mapView = getSelection();
1353  if (mapView == null) {
1354  return false;
1355  }
1356 
1357  if (performAction) {
1359  return false;
1360  }
1361 
1362  final int heightValue = tileStretchingDialog.getHeightValue();
1363  final Integer[] subLayers = tileStretchingDialog.getSubLayers();
1364  final boolean isAbsolute = tileStretchingDialog.isTileStretchingAbsolute();
1365  tileStretching(mapView, heightValue, isAbsolute, subLayers);
1366  }
1367 
1368  return true;
1369  }
1370 
1378  private boolean doTileStretchingChange(final boolean performAction, final int heightValue, final boolean isAbsolute) {
1379  final MapView<G, A, R> mapView = getSelection();
1380  if (mapView == null) {
1381  return false;
1382  }
1383 
1384  if (performAction) {
1385  tileStretching(mapView, heightValue, isAbsolute, null);
1386  }
1387 
1388  return true;
1389  }
1390 
1396  private void fill(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode insertionMode) {
1397  FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getSelectedSquares(), insertionMode, objectChooser.getSelections(), -1, false);
1398  }
1399 
1405  private void fillRandom(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode insertionMode) {
1407  return;
1408  }
1409 
1410  final int fillDensity = randomFillDialog.getFillDensity();
1411  final boolean noAdjacent = randomFillDialog.isRandomFillSkipAdjacentSquares();
1412  FillUtils.fill(mapView.getMapControl().getMapModel(), mapView.getSelectedSquares(), insertionMode, objectChooser.getSelections(), fillDensity, noAdjacent);
1413  }
1414 
1423  private void tileStretching(@NotNull final MapView<G, A, R> mapView, final int heightValue, final boolean isAbsolute, @NotNull final Integer @Nullable [] subLayers) {
1424  final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel();
1425 
1426  mapModel.beginTransaction("Tile stretching"); // TODO; I18N/L10N
1427  try {
1428  for (final MapSquare<G, A, R> mapSquare : mapView.getSelectedSquares()) {
1429  for (final GameObject<G, A, R> gameObject : mapSquare) {
1430  gameObject.updateTileStretch(heightValue, isAbsolute, subLayers);
1431  }
1432  }
1433  } finally {
1434  mapModel.endTransaction();
1435  }
1436  }
1437 
1438  @Override
1439  public void setAction(@NotNull final Action action, @NotNull final String name) {
1440  switch (name) {
1441  case "clear":
1442  aClear = action;
1443  break;
1444 
1445  case "cut":
1446  aCut = action;
1447  break;
1448 
1449  case "copy":
1450  aCopy = action;
1451  break;
1452 
1453  case "paste":
1454  aPaste = action;
1455  break;
1456 
1457  case "pasteTiled":
1458  aPasteTiled = action;
1459  break;
1460 
1461  case "shiftNorth":
1462  aShiftNorth = action;
1463  break;
1464 
1465  case "shiftNorthEast":
1466  aShiftNorthEast = action;
1467  break;
1468 
1469  case "shiftEast":
1470  aShiftEast = action;
1471  break;
1472 
1473  case "shiftSouthEast":
1474  aShiftSouthEast = action;
1475  break;
1476 
1477  case "shiftSouth":
1478  aShiftSouth = action;
1479  break;
1480 
1481  case "shiftSouthWest":
1482  aShiftSouthWest = action;
1483  break;
1484 
1485  case "shiftWest":
1486  aShiftWest = action;
1487  break;
1488 
1489  case "shiftNorthWest":
1490  aShiftNorthWest = action;
1491  break;
1492 
1493  case "find":
1494  aFind = action;
1495  break;
1496 
1497  case "findNext":
1498  aFindNext = action;
1499  break;
1500 
1501  case "findPrev":
1502  aFindPrev = action;
1503  break;
1504 
1505  case "replace":
1506  aReplace = action;
1507  break;
1508 
1509  case "fillAuto":
1510  aFillAuto = action;
1511  break;
1512 
1513  case "fillAbove":
1514  aFillAbove = action;
1515  break;
1516 
1517  case "fillBelow":
1518  aFillBelow = action;
1519  break;
1520 
1521  case "randFillAuto":
1522  aRandFillAuto = action;
1523  break;
1524 
1525  case "randFillAbove":
1526  aRandFillAbove = action;
1527  break;
1528 
1529  case "randFillBelow":
1530  aRandFillBelow = action;
1531  break;
1532 
1533  case "floodFill":
1534  aFloodFill = action;
1535  break;
1536 
1537  case "massChange":
1538  aMassChange = action;
1539  break;
1540 
1541  case "selectAll":
1542  aSelectAll = action;
1543  break;
1544 
1545  case "invertSelection":
1546  aInvertSelection = action;
1547  break;
1548 
1549  case "expandEmptySelection":
1550  aExpandEmptySelection = action;
1551  break;
1552 
1553  case "tileStretchingSet":
1554  aTileStretchingSet = action;
1555  break;
1556 
1557  case "tileStretchingClear":
1558  aTileStretchingClear = action;
1559  break;
1560 
1561  case "tileStretchingIncrease":
1562  aTileStretchingIncrease = action;
1563  break;
1564 
1565  case "tileStretchingDecrease":
1566  aTileStretchingDecrease = action;
1567  break;
1568 
1569  default:
1570  throw new IllegalArgumentException("unsupported action name: " + name);
1571  }
1572  refreshMenus();
1573  }
1574 
1575  @Override
1576  public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) {
1577  currentMapView = mapView;
1578  refreshMenus();
1579  }
1580 
1581  @Override
1582  public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) {
1583  mapView.getMapGrid().addMapGridListener(mapGridListener);
1584  }
1585 
1586  @Override
1587  public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) {
1588  mapView.getMapGrid().removeMapGridListener(mapGridListener);
1589  }
1590 
1591 }
net.sf.gridarta.model.mapmodel.InsertionModeSet.getTopmostInsertionMode
InsertionMode getTopmostInsertionMode()
Returns the "topmost" insertion mode.
Definition: InsertionModeSet.java:98
net.sf.gridarta.mainactions.MainActions.doFindNext
boolean doFindNext(final boolean performAction)
Executes the "find next" action.
Definition: MainActions.java:855
net.sf.gridarta.model.direction.Direction
A direction.
Definition: Direction.java:28
name
name
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:2
net.sf.gridarta.model.mapmanager
Definition: AbstractMapManager.java:20
net.sf.gridarta.model.mapmodel.MapModel
A MapModel reflects the data of a map.
Definition: MapModel.java:75
net.sf.gridarta.mainactions.MainActions.doFind
boolean doFind(final boolean performAction)
Executes the "find" action.
Definition: MainActions.java:837
net.sf.gridarta.mainactions.MainActions.refreshMenus
void refreshMenus()
Enables/disables menu entries based on the current state.
Definition: MainActions.java:463
net.sf.gridarta.gui.panel
net.sf.gridarta.model.mapgrid.MapGrid.endTransaction
void endTransaction()
Ends a transaction.
Definition: MapGrid.java:776
net.sf.gridarta.gui.map.mapview.MapView.getMapGrid
MapGrid getMapGrid()
Returns the MapGrid of this view.
net.sf.gridarta.mainactions.MainActions.doFillAbove
boolean doFillAbove(final boolean performAction)
Executes the "fill above" action.
Definition: MainActions.java:1066
net.sf.gridarta.model.mapmodel.MapModel.getMapArchObject
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
net.sf.gridarta.mainactions.MainActions.aPasteTiled
Action aPasteTiled
Action called for "paste tiled".
Definition: MainActions.java:193
net.sf.gridarta.model.mapmodel.InsertionModeSet
A set of InsertionModes.
Definition: InsertionModeSet.java:33
net.sf.gridarta.model.mapmanager.MapManager
A MapManager manages all opened maps.
Definition: MapManager.java:37
net.sf.gridarta.model.mapgrid.MapGrid.invertSelection
void invertSelection()
Inverts all selected squares.
Definition: MapGrid.java:605
net.sf.gridarta.gui.copybuffer.CopyBuffer.isEmpty
boolean isEmpty()
Returns whether this copy buffer contains any game objects.
Definition: CopyBuffer.java:271
net.sf.gridarta.gui.copybuffer
Definition: CopyBuffer.java:20
net.sf.gridarta.mainactions.MainActions.insertionModeSet
final InsertionModeSet< G, A, R > insertionModeSet
The InsertionModeSet to use.
Definition: MainActions.java:115
net.sf.gridarta.mainactions.MainActions.newMapManagerListener
MapManagerListener< G, A, R > newMapManagerListener()
Creates a new MapManagerListener that refreshes the actions when the current map changes.
Definition: MainActions.java:391
net.sf.gridarta.model.select.MatchCriteria
Criteria for game object matchers.
Definition: MatchCriteria.java:31
net.sf.gridarta.mainactions.MainActions.fillAbove
void fillAbove()
"Fill above" was selected from the Edit menu.
Definition: MainActions.java:710
net.sf.gridarta.gui.map.mapview.MapView.getMapControl
MapControl< G, A, R > getMapControl()
Return the controller of this view.
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.mainactions.MainActions.mapViewSettings
final MapViewSettings mapViewSettings
The map view settings instance.
Definition: MainActions.java:97
net.sf.gridarta.mainactions.MainActions.doClear
boolean doClear(final boolean performAction)
Executes the "clear" action.
Definition: MainActions.java:893
net.sf.gridarta.mainactions.MainActions.paste
void paste()
"Paste" was selected from the Edit menu.
Definition: MainActions.java:590
net.sf.gridarta.mainactions.MainActions.tileStretching
void tileStretching(@NotNull final MapView< G, A, R > mapView, final int heightValue, final boolean isAbsolute, @NotNull final Integer @Nullable[] subLayers)
Performs one of the "tile stretching" actions.
Definition: MainActions.java:1423
net.sf.gridarta.model.mapmodel.MapSquare
A single Map Square.
Definition: MapSquare.java:45
net.sf.gridarta.model.mapmodel.MapModel.endTransaction
void endTransaction()
End a transaction.
net.sf.gridarta.mainactions.MainActions.massChange
void massChange()
"Mass change" was selected from the Edit menu.
Definition: MainActions.java:758
net.sf.gridarta.mainactions.RandomFillDialog
Displays a dialog asking for parameters for the "random fill" function.
Definition: RandomFillDialog.java:51
net.sf.gridarta.mainactions.TileStretchingDialog.showTileStretchingDialog
boolean showTileStretchingDialog(@NotNull final Component parent)
Displays the tile stretching dialog.
Definition: TileStretchingDialog.java:205
net.sf.gridarta.gui.misc
Definition: About.java:20
net.sf.gridarta.mainactions.MainActions.findNext
void findNext()
"Find next" was selected from the Edit menu.
Definition: MainActions.java:678
net.sf.gridarta.model.mapviewsettings
Definition: AbstractMapViewSettings.java:20
net.sf.gridarta.model.direction.Direction.SOUTH
SOUTH
South.
Definition: Direction.java:43
net.sf.gridarta.mainactions.MainActions.aCopy
Action aCopy
Action called for "copy".
Definition: MainActions.java:133
net.sf.gridarta.model.maparchobject.MapArchObject.isPointValid
boolean isPointValid(@Nullable Point pos)
Checks whether the given coordinate is within map bounds.
net.sf.gridarta.mainactions.MainActions.find
void find()
"Find" was selected from the Edit menu.
Definition: MainActions.java:670
net.sf.gridarta.mainactions.MainActions.shiftSouthWest
void shiftSouthWest()
"Shift South West" was selected from the Edit menu.
Definition: MainActions.java:646
net.sf.gridarta.mainactions.MainActions.aShiftNorth
Action aShiftNorth
Action called for "shift north".
Definition: MainActions.java:139
net.sf.gridarta.mainactions.MainActions.activeMapViewChanged
void activeMapViewChanged(@Nullable final MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.
Definition: MainActions.java:1576
net.sf.gridarta.mainactions.MainActions.doExpandEmptySelection
boolean doExpandEmptySelection(final boolean performAction)
Executes the "expand empty selection" action.
Definition: MainActions.java:1282
net.sf
net.sf.gridarta.model.mapmodel.MapModel.beginTransaction
void beginTransaction(@NotNull String name)
Starts a new transaction.
net.sf.gridarta.model.mapmanager.MapManagerListener
Interface for listeners listening to MapManager changes.
Definition: MapManagerListener.java:42
net.sf.gridarta.model.select.ArchetypeNameMatchCriteria
A MatchCriteria that matches by archetype name.
Definition: ArchetypeNameMatchCriteria.java:33
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.gui.dialog.replace.ReplaceDialogManager
Creates and displays the replace dialog.
Definition: ReplaceDialogManager.java:40
net.sf.gridarta.gui.map.mapview.MapViewManagerListener
Interface for listeners interested in events related to {} instances.
Definition: MapViewManagerListener.java:33
net.sf.gridarta.mainactions.MainActions.fillAuto
void fillAuto()
"Fill" was selected from the Edit menu.
Definition: MainActions.java:702
net.sf.gridarta.gui.dialog.find.FindDialogManager.findPrev
boolean findPrev(@NotNull final MapView< G, A, R > mapView, final boolean performAction)
Executes the "find next" action.
Definition: FindDialogManager.java:117
net.sf.gridarta.model.direction.Direction.SOUTH_WEST
SOUTH_WEST
South west.
Definition: Direction.java:63
net.sf.gridarta.mainactions.MainActions.aFillBelow
Action aFillBelow
Action called for "fill below".
Definition: MainActions.java:235
net.sf.gridarta.model.mapgrid.MapGrid.getSelectedRec
Rectangle getSelectedRec()
Returns the smallest rectangle containing selection.
Definition: MapGrid.java:514
net.sf.gridarta.mainactions.MainActions.doRandFillAuto
boolean doRandFillAuto(final boolean performAction)
Executes the "rand fill auto" action.
Definition: MainActions.java:1102
net.sf.gridarta.mainactions.MainActions.aFindNext
Action aFindNext
Action called for "find next".
Definition: MainActions.java:205
net.sf.gridarta.gui.dialog.find.FindDialogManager.findNext
boolean findNext(@NotNull final MapView< G, A, R > mapView, final boolean performAction)
Executes the "find next" action.
Definition: FindDialogManager.java:107
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.mapviewsettings.MapViewSettings
Container for settings that affect the rendering of maps.
Definition: MapViewSettings.java:30
net.sf.gridarta.model.select
Definition: ArchetypeNameMatchCriteria.java:20
net.sf.gridarta.mainactions.MassChangeDialog.getSubLayers
Integer[] getSubLayers()
Returns the sub-layers to affect.
Definition: MassChangeDialog.java:333
net.sf.gridarta.model.mapcontrol
Definition: DefaultMapControl.java:20
net.sf.gridarta.mainactions.MainActions
Encapsulates actions and related functions.
Definition: MainActions.java:73
net.sf.gridarta.mainactions.MainActions.floodFill
void floodFill()
"Flood fill" was selected from the Edit menu.
Definition: MainActions.java:750
net.sf.gridarta.mainactions.MainActions.aShiftWest
Action aShiftWest
Action called for "shift west".
Definition: MainActions.java:175
net.sf.gridarta.mainactions.MainActions.aShiftSouthEast
Action aShiftSouthEast
Action called for "shift south east".
Definition: MainActions.java:157
net.sf.gridarta.mainactions.MainActions.mapGridListener
final MapGridListener mapGridListener
The map grid listener used to detect map grid changes.
Definition: MainActions.java:343
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net.sf.gridarta.model.mapmodel.InsertionModeSet.getAutoInsertionMode
InsertionMode getAutoInsertionMode()
Returns the "auto" insertion mode.
Definition: InsertionModeSet.java:89
net.sf.gridarta.model.direction.Direction.NORTH
NORTH
North.
Definition: Direction.java:33
net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction
void beginTransaction()
Starts a new transaction.
Definition: MapGrid.java:756
net.sf.gridarta.mainactions.MainActions.doPaste
boolean doPaste(final boolean performAction)
Executes the "paste" action.
Definition: MainActions.java:962
net.sf.gridarta.mainactions.MainActions.randomFillDialog
final RandomFillDialog randomFillDialog
The RandomFillDialog instance.
Definition: MainActions.java:313
net.sf.gridarta.gui.map.mapview.MapView.getMapCursor
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
net.sf.gridarta.mainactions.MainActions.randFillBelow
void randFillBelow()
"Random fill below" was selected from the Edit menu.
Definition: MainActions.java:742
net.sf.gridarta.mainactions.MainActions.fillRandom
void fillRandom(@NotNull final MapView< G, A, R > mapView, @NotNull final InsertionMode insertionMode)
"RandomFill" was selected from the Edit menu.
Definition: MainActions.java:1405
net.sf.gridarta.mainactions.MainActions.doCopy
boolean doCopy(final boolean performAction)
Executes the "copy" action.
Definition: MainActions.java:939
net.sf.gridarta.mainactions.MainActions.aFloodFill
Action aFloodFill
Action called for "flood fill".
Definition: MainActions.java:259
net.sf.gridarta.mainactions.RandomFillDialog.getFillDensity
int getFillDensity()
Returns the fill density.
Definition: RandomFillDialog.java:260
net.sf.gridarta.model.floodfill.FillUtils.floodFill
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > void floodFill(@NotNull final MapModel< G, A, R > mapModel, @NotNull final Point start, @NotNull final List<? extends BaseObject< G, A, R, ?>> gameObjects, @NotNull final InsertionModeSet< G, A, R > insertionModeSet)
Definition: FillUtils.java:141
net.sf.gridarta.mainactions.MainActions.tileStretchingIncrease
void tileStretchingIncrease()
Invoked when the user wants to increase tile stretching on the selected map squares.
Definition: MainActions.java:810
net.sf.gridarta.mainactions.MainActions.shiftEast
void shiftEast()
"Shift East" was selected from the Edit menu.
Definition: MainActions.java:622
net.sf.gridarta.model.direction.Direction.NORTH_WEST
NORTH_WEST
North west.
Definition: Direction.java:68
net.sf.gridarta.mainactions.MainActions.currentMapView
MapView< G, A, R > currentMapView
The last known active map view, or.
Definition: MainActions.java:337
net.sf.gridarta.gui.panel.objectchooser
Definition: DefaultObjectChooser.java:20
net.sf.gridarta.model.floodfill
Definition: FillUtils.java:20
net.sf.gridarta.mainactions.MainActions.doTileStretchingChange
boolean doTileStretchingChange(final boolean performAction, final int heightValue, final boolean isAbsolute)
Executes one of the "tile stretching clear/increase/decrease" actions.
Definition: MainActions.java:1378
net.sf.gridarta.mainactions.MainActions.selectAll
void selectAll()
Invoked when the user wants to select all squares from a map.
Definition: MainActions.java:766
net.sf.gridarta.model.mapgrid.MapGrid.selectAll
void selectAll()
Marks all squares as selected.
Definition: MapGrid.java:593
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.gui.copybuffer.CopyBuffer.addMapModelListener
void addMapModelListener(@NotNull final MapModelListener< G, A, R > listener)
Adds a MapModelListener to be notified about changes of the cut/copied game objects.
Definition: CopyBuffer.java:100
net.sf.gridarta.gui.panel.objectchooser.ObjectChooser.getSelections
List<? extends BaseObject< G, A, R, ?> > getSelections()
Returns the selected arches in the left-side panel.
net.sf.gridarta.mainactions.MainActions.aRandFillAbove
Action aRandFillAbove
Action called for "random fill above".
Definition: MainActions.java:247
net.sf.gridarta.mainactions.MainActions.shiftSouth
void shiftSouth()
"Shift South" was selected from the Edit menu.
Definition: MainActions.java:638
net.sf.gridarta.mainactions.MainActions.doPasteTiled
boolean doPasteTiled(final boolean performAction)
Executes the "paste tiled" action.
Definition: MainActions.java:985
net.sf.gridarta.gui.dialog.replace.ReplaceDialogManager.showDialog
void showDialog(@NotNull final MapView< G, A, R > mapView)
Displays the replace dialog.
Definition: ReplaceDialogManager.java:131
net.sf.gridarta.mainactions.MainActions.doShift
boolean doShift(final boolean performAction, @NotNull final Direction direction)
Executes the "shift" action.
Definition: MainActions.java:1020
net.sf.gridarta.mainactions.MainActions.aExpandEmptySelection
Action aExpandEmptySelection
Action called for "grow empty selection".
Definition: MainActions.java:283
net.sf.gridarta.gui.dialog.replace
The Replace dialog: replaces game objects in a map.
Definition: ReplaceDialog.java:20
net.sf.gridarta.mainactions.MainActions.fillBelow
void fillBelow()
"Fill below" was selected from the Edit menu.
Definition: MainActions.java:718
net.sf.gridarta.mainactions.MainActions.mapViewClosing
void mapViewClosing(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view is to be closed.
Definition: MainActions.java:1587
net.sf.gridarta.gui.misc.ShiftProcessor.shift
void shift(@NotNull final Direction dir)
Shifts the map contents by one square.
Definition: ShiftProcessor.java:157
net.sf.gridarta.mainactions.MainActions.fill
void fill(@NotNull final MapView< G, A, R > mapView, @NotNull final InsertionMode insertionMode)
"Fill" was selected from the Edit menu.
Definition: MainActions.java:1396
net.sf.gridarta.mainactions.MainActions.doRandFillAbove
boolean doRandFillAbove(final boolean performAction)
Executes the "rand fill above" action.
Definition: MainActions.java:1120
net.sf.gridarta.mainactions.MainActions.copyBuffer
final CopyBuffer< G, A, R > copyBuffer
The copy buffer instance.
Definition: MainActions.java:103
errors
errors
Definition: ArchetypeTypeSetParserTest-ignoreDefaultAttribute1-result.txt:1
net.sf.gridarta.mainactions.MassChangeDialog.getLayers
Integer[] getLayers()
Returns the layers to affect.
Definition: MassChangeDialog.java:317
net.sf.gridarta.mainactions.MainActions.cut
void cut()
"Cut" was selected from the Edit menu.
Definition: MainActions.java:574
net.sf.gridarta.mainactions.MainActions.aFillAuto
Action aFillAuto
Action called for "fill".
Definition: MainActions.java:223
net.sf.gridarta.mainactions.TileStretchingDialog.getSubLayers
Integer[] getSubLayers()
Returns the sub-layers to affect.
Definition: TileStretchingDialog.java:280
net.sf.gridarta.mainactions.MainActions.aRandFillAuto
Action aRandFillAuto
Action called for "random fill".
Definition: MainActions.java:241
net.sf.gridarta.mainactions.MassChangeDialog
Displays a dialog asking for parameters for the "mass change" function.
Definition: MassChangeDialog.java:55
net.sf.gridarta.model.direction.Direction.SOUTH_EAST
SOUTH_EAST
South east.
Definition: Direction.java:58
net.sf.gridarta.model.maparchobject.MapArchObject
Interface for MapArchObjects.
Definition: MapArchObject.java:40
net.sf.gridarta.mainactions.TileStretchingDialog.getHeightValue
int getHeightValue()
Returns the height value.
Definition: TileStretchingDialog.java:271
net.sf.gridarta.gui.copybuffer.CopyBuffer.copy
void copy(@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec)
Executes the Copy command.
Definition: CopyBuffer.java:136
net.sf.gridarta.mainactions.MainActions.aPaste
Action aPaste
Action called for "paste".
Definition: MainActions.java:187
net.sf.gridarta.mainactions.MainActions.doFillAuto
boolean doFillAuto(final boolean performAction)
Executes the "fill auto" action.
Definition: MainActions.java:1048
net.sf.gridarta.gui.map.mapview
Definition: AbstractMapView.java:20
net.sf.gridarta.mainactions.MainActions.aTileStretchingDecrease
Action aTileStretchingDecrease
Action called for "tile stretching -> decrease Z".
Definition: MainActions.java:307
net.sf.gridarta.mainactions.MainActions.getSelection
MapView< G, A, R > getSelection()
Determine if the current map has a selection.
Definition: MainActions.java:828
net.sf.gridarta.mainactions.MainActions.aMassChange
Action aMassChange
Action called for "mass change".
Definition: MainActions.java:265
net.sf.gridarta.mainactions.MainActions.aInvertSelection
Action aInvertSelection
Action called for "invert selection".
Definition: MainActions.java:277
net.sf.gridarta.mainactions.TileStretchingDialog.isTileStretchingAbsolute
boolean isTileStretchingAbsolute()
Action method for "absolute" action.
Definition: TileStretchingDialog.java:238
net.sf.gridarta.model.validation.ErrorCollector
An interface for classes that collect errors.
Definition: ErrorCollector.java:33
net.sf.gridarta.model.mapcursor.MapCursor.getLocation
Point getLocation()
Get position of cursor.
Definition: MapCursor.java:227
net.sf.gridarta.gui.map.mapview.MapView
A map view consists of a map grid and a map cursor, and is attached to a map control.
Definition: MapView.java:43
net.sf.gridarta.model.mapgrid.SelectionMode
Modes that describe how squares get selected.
Definition: SelectionMode.java:26
net.sf.gridarta.mainactions.MassChangeDialog.getArchNames
String[] getArchNames()
Returns the arch names to affect.
Definition: MassChangeDialog.java:285
net.sf.gridarta.mainactions.MainActions.copy
void copy()
"Copy" was selected from the Edit menu.
Definition: MainActions.java:582
net.sf.gridarta.model.archetypeset.ArchetypeSet
Interface that captures similarities between different ArchetypeSet implementations.
Definition: ArchetypeSet.java:37
net.sf.gridarta.mainactions.MainActions.objectChooser
final ObjectChooser< G, A, R > objectChooser
The ObjectChooser instance to use.
Definition: MainActions.java:109
net.sf.gridarta.gui.dialog.find.FindDialogManager
Creates and displays the find dialog.
Definition: FindDialogManager.java:36
net.sf.gridarta.model.validation
This package contains the framework for validating maps.
Definition: AbstractValidator.java:20
net.sf.gridarta.mainactions.MainActions.tileStretchingDecrease
void tileStretchingDecrease()
Invoked when the user wants to decrease tile stretching on the selected map squares.
Definition: MainActions.java:819
net.sf.gridarta.model.mapmodel.InsertionModeSet.getBottommostInsertionMode
InsertionMode getBottommostInsertionMode()
Returns the "bottommost" insertion mode.
Definition: InsertionModeSet.java:125
net.sf.gridarta.model.mapgrid.MapGrid.select
void select(@NotNull final Point pos, @NotNull final SelectionMode selectionMode)
Selects or deselects a single square.
Definition: MapGrid.java:408
net.sf.gridarta.gui.copybuffer.CopyBuffer
Common base implementation of CopyBuffer.
Definition: CopyBuffer.java:52
net.sf.gridarta.model.mapmodel.InsertionMode
Insertion modes.
Definition: InsertionMode.java:33
net.sf.gridarta.mainactions.RandomFillDialog.isRandomFillSkipAdjacentSquares
boolean isRandomFillSkipAdjacentSquares()
Action method for "skip adjacent squares" action.
Definition: RandomFillDialog.java:226
net.sf.gridarta.mainactions.MainActions.shiftSouthEast
void shiftSouthEast()
"Shift South East" was selected from the Edit menu.
Definition: MainActions.java:630
net.sf.gridarta.mainactions.MainActions.currentMapControl
MapControl< G, A, R > currentMapControl
The last known active map, or.
Definition: MainActions.java:331
net.sf.gridarta.gui.dialog
net.sf.gridarta.mainactions.MainActions.doMassChange
boolean doMassChange(final boolean performAction)
Executes the "mass change" actions.
Definition: MainActions.java:1175
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.mainactions.MainActions.aTileStretchingSet
Action aTileStretchingSet
Action called for "tile stretching -> set Z".
Definition: MainActions.java:289
net.sf.gridarta.mainactions.MassChangeDialog.showMassChangeDialog
boolean showMassChangeDialog(@NotNull final Component parent)
Displays the mass change dialog.
Definition: MassChangeDialog.java:234
net.sf.gridarta.gui.panel.objectchooser.ObjectChooser
Common base interface for ObjectChoosers.
Definition: ObjectChooser.java:34
net.sf.gridarta.gui.copybuffer.CopyBuffer.cut
void cut(@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec)
Executes the Cut command.
Definition: CopyBuffer.java:127
net.sf.gridarta.mainactions.TileStretchingDialog
Displays a dialog asking for parameters for the "tile stretching set" function.
Definition: TileStretchingDialog.java:53
net.sf.gridarta.mainactions.MainActions.shiftNorthEast
void shiftNorthEast()
"Shift North East" was selected from the Edit menu.
Definition: MainActions.java:614
net.sf.gridarta.mainactions.MassChangeDialog.getNames
String[] getNames()
Returns the object names to affect.
Definition: MassChangeDialog.java:301
net.sf.gridarta.mainactions.MainActions.tileStretchingSet
void tileStretchingSet()
Invoked when the user wants to set tile stretching on the selected map squares.
Definition: MainActions.java:792
net.sf.gridarta.gui.dialog.find
Definition: FindDialog.java:20
net.sf.gridarta.mainactions.MainActions.aTileStretchingClear
Action aTileStretchingClear
Action called for "tile stretching -> clear Z".
Definition: MainActions.java:295
net.sf.gridarta.mainactions.MainActions.aRandFillBelow
Action aRandFillBelow
Action called for "random fill below".
Definition: MainActions.java:253
net.sf.gridarta.mainactions.MainActions.pasteTiled
void pasteTiled()
"Paste Tiled" was selected from the Edit menu.
Definition: MainActions.java:598
net.sf.gridarta.model.mapmodel.MapModelListener
Interface for listeners listening on MapModel events.
Definition: MapModelListener.java:36
net.sf.gridarta.model.mapgrid.MapGrid
2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.
Definition: MapGrid.java:46
net.sf.gridarta.model.mapgrid.SelectionMode.ADD
ADD
All squares that are preselected get selected.
Definition: SelectionMode.java:31
net.sf.gridarta.model.mapmodel.MapModel.getMapSquare
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
net.sf.gridarta.mainactions.MainActions.shiftNorth
void shiftNorth()
"Shift North" was selected from the Edit menu.
Definition: MainActions.java:606
net.sf.gridarta.gui.copybuffer.CopyBuffer.paste
void paste(@NotNull final MapView< G, A, R > mapView, @NotNull final Point startLocation)
Executes the Paste command.
Definition: CopyBuffer.java:180
net.sf.gridarta.mainactions.MassChangeDialog.getChanges
String getChanges()
Returns the actual changes to apply.
Definition: MassChangeDialog.java:349
net.sf.gridarta.model.mapgrid
Definition: MapGrid.java:20
net.sf.gridarta.mainactions.MainActions.expandEmptySelection
void expandEmptySelection()
Invoked when the user wants to expand the selection of empty map squares to surrounding empty map squ...
Definition: MainActions.java:783
net.sf.gridarta.mainactions.MainActions.shiftNorthWest
void shiftNorthWest()
"Shift North West" was selected from the Edit menu.
Definition: MainActions.java:662
net.sf.gridarta.mainactions.MainActions.aCut
Action aCut
Action called for "cut".
Definition: MainActions.java:127
net.sf.gridarta.mainactions.MainActions.aFind
Action aFind
Action called for "find".
Definition: MainActions.java:199
net.sf.gridarta.mainactions.MainActions.invertSelection
void invertSelection()
Invoked when the user wants to invert all selected squares from a map.
Definition: MainActions.java:774
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Reflects an Archetype.
Definition: Archetype.java:41
net.sf.gridarta.model.floodfill.FillUtils
Utility class implementing fill operations on map instances.
Definition: FillUtils.java:43
net.sf.gridarta.mainactions.MainActions.aSelectAll
Action aSelectAll
Action called for "select all".
Definition: MainActions.java:271
net.sf.gridarta.mainactions.MainActions.newMapModelListener
MapModelListener< G, A, R > newMapModelListener()
Creates a new MapModelListener that refreshes the actions when the map contents change.
Definition: MainActions.java:424
net.sf.gridarta.gui.dialog.find.FindDialogManager.showDialog
void showDialog(@NotNull final MapView< G, A, R > mapView)
Displays the replace dialog.
Definition: FindDialogManager.java:94
net.sf.gridarta.gui.map
Base classes for rendering maps.
Definition: AbstractPerMapDialogManager.java:20
net.sf.gridarta.model.select.ObjectNameMatchCriteria
A MatchCriteria that matches by object name.
Definition: ObjectNameMatchCriteria.java:33
net.sf.gridarta.model.baseobject.GameObjectContainer.isEmpty
boolean isEmpty()
Check whether this square is empty.
Definition: GameObjectContainer.java:182
net.sf.gridarta.mainactions.MainActions.doTileStretchingChangeSet
boolean doTileStretchingChangeSet(final boolean performAction)
Executes one of the "tile stretching" actions.
Definition: MainActions.java:1351
net.sf.gridarta.model.direction.Direction.EAST
EAST
East.
Definition: Direction.java:38
net.sf.gridarta.mainactions.MainActions.randFillAbove
void randFillAbove()
"Random fill above" was selected from the Edit menu.
Definition: MainActions.java:734
net.sf.gridarta.mainactions.MainActions.findDialogManager
final FindDialogManager< G, A, R > findDialogManager
The find dialog manager to use.
Definition: MainActions.java:79
net.sf.gridarta.mainactions.MainActions.doSelectAll
boolean doSelectAll(final boolean performAction)
Executes the "select all" action.
Definition: MainActions.java:1248
net.sf.gridarta.mainactions.MainActions.aClear
Action aClear
Action called for "clear".
Definition: MainActions.java:121
net.sf.gridarta.mainactions.MainActions.findPrev
void findPrev()
"Find previous" was selected from the Edit menu.
Definition: MainActions.java:686
net.sf.gridarta.model.direction.Direction.NORTH_EAST
NORTH_EAST
North east.
Definition: Direction.java:53
net.sf.gridarta.model.mapcontrol.MapControl
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
net.sf.gridarta.model.mapgrid.MapGridListener
Interface for listeners listening to MapGridEvents.
Definition: MapGridListener.java:29
net.sf.gridarta.model.mapcontrol.MapControl.getMapModel
MapModel< G, A, R > getMapModel()
Returns the map model.
net.sf.gridarta.mainactions.MainActions.doFillBelow
boolean doFillBelow(final boolean performAction)
Executes the "fill below" action.
Definition: MainActions.java:1084
net.sf.gridarta.mainactions.MainActions.replaceDialogManager
final ReplaceDialogManager< G, A, R > replaceDialogManager
The replace dialog manager to use.
Definition: MainActions.java:85
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.mainactions.MainActions.aShiftSouthWest
Action aShiftSouthWest
Action called for "shift south west".
Definition: MainActions.java:169
net.sf.gridarta.mainactions.MainActions.doFindPrev
boolean doFindPrev(final boolean performAction)
Executes the "find prev" action.
Definition: MainActions.java:865
net.sf.gridarta.gui.misc.ShiftProcessor
Performs a "shift" operation in a map: shift all selected squares into the given direction.
Definition: ShiftProcessor.java:46
net.sf.gridarta.mainactions.MainActions.aShiftEast
Action aShiftEast
Action called for "shift east".
Definition: MainActions.java:151
net.sf.gridarta.gui.map.mapview.MapView.getSelectedSquares
List< MapSquare< G, A, R > > getSelectedSquares()
Returns the selected squares.
net.sf.gridarta.mainactions.MainActions.aShiftNorthEast
Action aShiftNorthEast
Action called for "shift north east".
Definition: MainActions.java:145
net.sf.gridarta.mainactions.MainActions.doFloodFill
boolean doFloodFill(final boolean performAction)
Executes the "flood fill" action.
Definition: MainActions.java:1156
net.sf.gridarta.mainactions.MainActions.shiftWest
void shiftWest()
"Shift West" was selected from the Edit menu.
Definition: MainActions.java:654
net.sf.gridarta.mainactions.MainActions.randFillAuto
void randFillAuto()
"Random fill" was selected from the Edit menu.
Definition: MainActions.java:726
net.sf.gridarta.mainactions.MainActions.aFillAbove
Action aFillAbove
Action called for "fill above".
Definition: MainActions.java:229
net.sf.gridarta.model.mapgrid.MapGridEvent
This event is created by MapGrid.
Definition: MapGridEvent.java:29
net.sf.gridarta.mainactions.MainActions.massChangeDialog
final MassChangeDialog massChangeDialog
The MassChangeDialog instance.
Definition: MainActions.java:325
net.sf.gridarta.mainactions.MainActions.doRandFillBelow
boolean doRandFillBelow(final boolean performAction)
Executes the "rand fill below" action.
Definition: MainActions.java:1138
net.sf.gridarta.mainactions.MainActions.doCut
boolean doCut(final boolean performAction)
Executes the "cut" action.
Definition: MainActions.java:916
net.sf.gridarta.mainactions.MainActions.setAction
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
Definition: MainActions.java:1439
net.sf.gridarta.mainactions.MainActions.tileStretchingClear
void tileStretchingClear()
Invoked when the user wants to clear tile stretching on the selected map squares.
Definition: MainActions.java:801
net.sf.gridarta.mainactions.MainActions.aFindPrev
Action aFindPrev
Action called for "find prev".
Definition: MainActions.java:211
net.sf.gridarta.mainactions.MainActions.aShiftNorthWest
Action aShiftNorthWest
Action called for "shift north west".
Definition: MainActions.java:181
net.sf.gridarta.model.direction.Direction.WEST
WEST
West.
Definition: Direction.java:48
net.sf.gridarta.utils.EditorAction
A global editor action.
Definition: EditorAction.java:29
net.sf.gridarta.mainactions.MainActions.replace
void replace()
"Replace" was selected from the Edit menu.
Definition: MainActions.java:694
net.sf.gridarta.mainactions.MainActions.aShiftSouth
Action aShiftSouth
Action called for "shift south".
Definition: MainActions.java:163
net.sf.gridarta.model.archetypeset
Definition: ArchetypeSet.java:20
net.sf.gridarta.mainactions.MainActions.tileStretchingDialog
final TileStretchingDialog tileStretchingDialog
The TileStretchingDialog instance.
Definition: MainActions.java:319
net.sf.gridarta.mainactions.MainActions.aTileStretchingIncrease
Action aTileStretchingIncrease
Action called for "tile stretching -> increase Z".
Definition: MainActions.java:301
net.sf.gridarta.gui.misc.ShiftProcessor.canShift
boolean canShift(@NotNull final Direction dir)
Checks whether shifting is possible.
Definition: ShiftProcessor.java:113
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.model.mapgrid.MapGrid.unSelect
void unSelect()
Clears all selection and pre-selection flags from the grid.
Definition: MapGrid.java:263
net.sf.gridarta.mainactions.MainActions.doReplace
boolean doReplace(final boolean performAction)
Executes the "replace" action.
Definition: MainActions.java:875
net.sf.gridarta.mainactions.MainActions.doInvertSelection
boolean doInvertSelection(final boolean performAction)
Executes the "invert selection" action.
Definition: MainActions.java:1265
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.model.direction
Definition: Direction.java:20
net.sf.gridarta.mainactions.MainActions.MainActions
MainActions(@NotNull final FindDialogManager< G, A, R > findDialogManager, @NotNull final ReplaceDialogManager< G, A, R > replaceDialogManager, @NotNull final JFrame parent, @NotNull final MapViewSettings mapViewSettings, @NotNull final ArchetypeSet< G, A, R > archetypeSet, @NotNull final CopyBuffer< G, A, R > copyBuffer, @NotNull final ObjectChooser< G, A, R > objectChooser, @NotNull final MapManager< G, A, R > mapManager, @NotNull final InsertionModeSet< G, A, R > insertionModeSet)
Creates a new instance.
Definition: MainActions.java:369
net.sf.gridarta.model.floodfill.FillUtils.fill
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > void fill(@NotNull final MapModel< G, A, R > mapModel, @NotNull final Collection< MapSquare< G, A, R >> selection, @NotNull final InsertionMode insertionMode, @NotNull final List<? extends BaseObject< G, A, R, ?>> gameObjects, final int density, final boolean noAdjacent)
Definition: FillUtils.java:61
net.sf.gridarta.gui.copybuffer.CopyBuffer.pasteTiled
void pasteTiled(@NotNull final MapView< G, A, R > mapView, @NotNull final Iterable< MapSquare< G, A, R >> selectedSquares, @NotNull final Point origin)
Executes the Paste Tiled command.
Definition: CopyBuffer.java:220
net.sf.gridarta.mainactions.RandomFillDialog.showRandomFillDialog
boolean showRandomFillDialog(@NotNull final Component parent)
Displays the random fill dialog.
Definition: RandomFillDialog.java:193
net.sf.gridarta.mainactions.MainActions.parent
final JFrame parent
The parent component for dialog windows.
Definition: MainActions.java:91
net.sf.gridarta.mainactions.MainActions.aReplace
Action aReplace
Action called for "replace".
Definition: MainActions.java:217
net.sf.gridarta.mainactions.MainActions.clear
void clear()
"Clear" was selected from the Edit menu.
Definition: MainActions.java:566
net.sf.gridarta.gui.copybuffer.CopyBuffer.clear
void clear(@NotNull final MapView< G, A, R > mapView, @NotNull final Rectangle selectedRec)
Executes the Clear command.
Definition: CopyBuffer.java:118
net.sf.gridarta.mainactions.MainActions.mapViewCreated
void mapViewCreated(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view was created.
Definition: MainActions.java:1582