Checks whether the places can be pasted relatively to x,y on layer @param x @param y @param layer @return
(final int x, final int y, final Layer layer)
| 99 | * @return |
| 100 | */ |
| 101 | public static boolean canPaste(final int x, final int y, final Layer layer) { |
| 102 | if (copyPlaces == null || copyPlaces.isEmpty()) { |
| 103 | return false; |
| 104 | } |
| 105 | if (copyPlaceLocations != null && layer != null) { |
| 106 | for (final Pair<Integer, Integer> coordinate : copyPlaceLocations) { |
| 107 | final LayerElement collision = layer.get(x + coordinate.first, y + coordinate.second); |
| 108 | if (collision != null) { |
| 109 | if (copyMode) { |
| 110 | return false; |
| 111 | } else { // if places are moved: checkif the colliding place is in the movied group, too |
| 112 | if (!copyPlaces.contains(collision)) { |
| 113 | return false; |
| 114 | } |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | return true; |
| 120 | } |
| 121 | |
| 122 | /** |
| 123 | * Pastes the cut / copied places to layer, if possible |
no test coverage detected