return element;
}
};
boolean canConcatenate = false;
int i = 0, j = 0, next = 0;
TransformStackElement element = null;
// We keep a separate 'presentation' stack, which contains
// all concatenated elements. The top of this stack is the
// element we try to concatenate onto. If this element
// becomes an identity transform, we discard it and look at
// the element underneath it instead.
// The presentation stack is guaranteed not to contain
// identity transforms.
while(i < nTransforms) {
// If we do not have an element to concatenate onto,
// we grab one here.
next = i;
if(element == null) {
element = (TransformStackElement) transformStack[i].clone();
next++;
}
// try to concatenate as much as possible
canConcatenate = true;
for(j = next; j < nTransforms; j++) {
canConcatenate = element.concatenate(transformStack[j]);
if(!canConcatenate)
break;
}
// loop variable assertion:
// If "i" does not increment during this iteration, it is guaranteed