| 130 | } |
| 131 | |
| 132 | @AstroImageJ(reason = "Add method for moving sliced in a stack") |
| 133 | public void swapSlices(int o, int n) { |
| 134 | if (isTranslatingIndices()) { |
| 135 | throw new IllegalArgumentException("Virtual hyperstack with non-czt order cannot be modified"); |
| 136 | } |
| 137 | if (o<1 || o>nSlices || n<1 || n>nSlices) |
| 138 | throw new IllegalArgumentException("Argument out of range: "+o+" "+n); |
| 139 | if (o==n) return; |
| 140 | |
| 141 | var no = names[o-1]; |
| 142 | var lo = labels[o-1]; |
| 143 | |
| 144 | names[o-1] = names[n-1]; |
| 145 | labels[o-1] = labels[n-1]; |
| 146 | names[n-1] = no; |
| 147 | labels[n-1] = lo; |
| 148 | |
| 149 | if (indexes != null) { |
| 150 | var io = indexes[o-1]; |
| 151 | indexes[o-1] = indexes[n-1]; |
| 152 | indexes[n-1] = io; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Sorts the stack based on provided indexes array. |