/** * cleverAdd add cleverly a CoordinateOperation in a list of * CoordinateOperations by removing the last element of list if it is the * inverse of the element to add. If not, it simply add the * CoordinateOperation at the end of the list. NB1: If * <code>op</code> is the Identity transformation, it is added only if * <code>ops</code> is empty. NB2: If * <code>ops</code> contains only the identity transformation, it is * replaced by * <code>op</code>. * * @param ops the list in which the CoordinateOperation should be added * @param op the CoordinateOperation to add list) */ public static List<CoordinateOperation> cleverAdd(List<CoordinateOperation> ops, CoordinateOperation op) { List<CoordinateOperation> result = new ArrayList<CoordinateOperation>(ops); List<CoordinateOperation> addedOp = new ArrayList<CoordinateOperation>(); addedOp.add(op); result = fusionSequences(result, addedOp); return result; }
if (op1.equals(Identity.IDENTITY)) { lst1.remove(lst1.size() - 1); return fusionSequences(lst1, lst2); return fusionSequences(lst1, lst2); lst1.remove(lst1.size() - 1); lst2.remove(0); return fusionSequences(lst1, lst2);
result.add(op); } else if (op instanceof CoordinateOperationSequence) { result = fusionSequences(result, Arrays.asList(((CoordinateOperationSequence) op).getSequence()));