for (int i = 0; i < transforms.size() - 1; i++, index++) {
res.transforms.setElementAt(transforms.elementAt(i), index);
}
if (to != null) {
AbstractSVGTransform tt =
(AbstractSVGTransform) toTransformList.transforms.lastElement();
AbstractSVGTransform ft = null;
int type;
if (transforms.isEmpty()) {
// For the case of an additive animation with an underlying
// transform list of zero elements.
type = tt.getType();
switch (type) {
case SVGTransform.SVG_TRANSFORM_SKEWX:
ft = IDENTITY_SKEWX;
break;
case SVGTransform.SVG_TRANSFORM_SKEWY:
ft = IDENTITY_SKEWY;
break;
case SVGTransform.SVG_TRANSFORM_SCALE:
ft = IDENTITY_SCALE;
break;
case SVGTransform.SVG_TRANSFORM_ROTATE:
ft = IDENTITY_ROTATE;
break;
case SVGTransform.SVG_TRANSFORM_TRANSLATE:
ft = IDENTITY_TRANSLATE;
break;
}
} else {
ft = (AbstractSVGTransform) transforms.lastElement();
type = ft.getType();
}
if (type == tt.getType()) {
AbstractSVGTransform t;
if (res.transforms.isEmpty()) {
t = new SVGOMTransform();
res.transforms.add(t);
} else {
t = (AbstractSVGTransform) res.transforms.elementAt(index);
if (t == null) {
t = new SVGOMTransform();
res.transforms.setElementAt(t, index);
}
}
float x, y, r = 0;
switch (type) {
case SVGTransform.SVG_TRANSFORM_SKEWX:
case SVGTransform.SVG_TRANSFORM_SKEWY:
r = ft.getAngle();
r += interpolation * (tt.getAngle() - r);
if (type == SVGTransform.SVG_TRANSFORM_SKEWX) {
t.setSkewX(r);
} else if (type == SVGTransform.SVG_TRANSFORM_SKEWY) {
t.setSkewY(r);
}
break;
case SVGTransform.SVG_TRANSFORM_SCALE: {
SVGMatrix fm = ft.getMatrix();
SVGMatrix tm = tt.getMatrix();
x = fm.getA();
y = fm.getD();
x += interpolation * (tm.getA() - x);
y += interpolation * (tm.getD() - y);
t.setScale(x, y);
break;
}
case SVGTransform.SVG_TRANSFORM_ROTATE: {
x = ft.getX();
y = ft.getY();
x += interpolation * (tt.getX() - x);
y += interpolation * (tt.getY() - y);
r = ft.getAngle();
r += interpolation * (tt.getAngle() - r);
t.setRotate(r, x, y);
break;
}
case SVGTransform.SVG_TRANSFORM_TRANSLATE: {
SVGMatrix fm = ft.getMatrix();
SVGMatrix tm = tt.getMatrix();
x = fm.getE();
y = fm.getF();
x += interpolation * (tm.getE() - x);
y += interpolation * (tm.getF() - y);
t.setTranslate(x, y);
break;
}
}
}
} else {
AbstractSVGTransform ft =
(AbstractSVGTransform) transforms.lastElement();
AbstractSVGTransform t =
(AbstractSVGTransform) res.transforms.elementAt(index);
if (t == null) {
t = new SVGOMTransform();
res.transforms.setElementAt(t, index);
}
t.assign(ft);
}
// XXX Do better checking for changes.
res.hasChanged = true;