public Section shiftOrigin(int[] newOrigin) throws InvalidRangeException { if (newOrigin.length != getRank()) throw new InvalidRangeException("Invalid Section rank"); List<Range> results = new ArrayList<>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); results.add(base.shiftOrigin(-newOrigin[j])); } return new Section(results); }
/** * Create a new Section by shifting each range by newOrigin.first() * The result is then a reletive offset from the newOrigin. * * @param newOrigin this becomes the origin of the result * @return new Section, shifted * @throws InvalidRangeException if want.getRank() not equal to this.getRank() */ public Section shiftOrigin(Section newOrigin) throws InvalidRangeException { if (newOrigin.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); // check individual nulls List<Range> results = new ArrayList<>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); Range r = newOrigin.getRange(j); results.add(base.shiftOrigin(r.first())); } return new Section(results); }
/** * Create a new Section by shifting each range by newOrigin.first() * The result is then a reletive offset from the newOrigin. * * @param newOrigin this becomes the origin of the result * @return new Section, shifted * @throws InvalidRangeException if want.getRank() not equal to this.getRank() */ public Section shiftOrigin(Section newOrigin) throws InvalidRangeException { if (newOrigin.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); // check individual nulls List<Range> results = new ArrayList<Range>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); Range r = newOrigin.getRange(j); results.add(base.shiftOrigin(r.first())); } return new Section(results); }
/** * Create a new Section by shifting each range by newOrigin.first() * The result is then a reletive offset from the newOrigin. * * @param newOrigin this becomes the origin of the result * @return new Section, shifted * @throws InvalidRangeException if want.getRank() not equal to this.getRank() */ public Section shiftOrigin(Section newOrigin) throws InvalidRangeException { if (newOrigin.getRank() != getRank()) throw new InvalidRangeException("Invalid Section rank"); // check individual nulls List<Range> results = new ArrayList<>(getRank()); for (int j = 0; j < list.size(); j++) { Range base = list.get(j); Range r = newOrigin.getRange(j); results.add(base.shiftOrigin(r.first())); } return new Section(results); }