}
}
this.path = path;
pathLength = new PathLength(path);
int segments = 0;
ExtendedPathIterator epi = path.getExtendedPathIterator();
while (!epi.isDone()) {
int type = epi.currentSegment();
if (type != ExtendedPathIterator.SEG_MOVETO) {
segments++;
}
epi.next();
}
int count = keyPoints == null ? segments + 1 : keyPoints.length;
float totalLength = pathLength.lengthOfPath();
if (this.keyTimes != null && calcMode != CALC_MODE_PACED) {
if (this.keyTimes.length != count) {
throw timedElement.createException
("attribute.malformed",
new Object[] { null,
SMILConstants.SMIL_KEY_TIMES_ATTRIBUTE });
}
} else {
if (calcMode == CALC_MODE_LINEAR || calcMode == CALC_MODE_SPLINE) {
this.keyTimes = new float[count];
for (int i = 0; i < count; i++) {
this.keyTimes[i] = (float) i / (count - 1);
}
} else if (calcMode == CALC_MODE_DISCRETE) {
this.keyTimes = new float[count];
for (int i = 0; i < count; i++) {
this.keyTimes[i] = (float) i / count;
}
} else { // CALC_MODE_PACED
// This corrects the keyTimes to be paced, so from now on
// it can be considered the same as CALC_MODE_LINEAR.
epi = path.getExtendedPathIterator();
this.keyTimes = new float[count];
int j = 0;
for (int i = 0; i < count - 1; i++) {
while (epi.currentSegment() ==
ExtendedPathIterator.SEG_MOVETO) {
j++;
epi.next();
}
this.keyTimes[i] =
pathLength.getLengthAtSegment(j) / totalLength;
j++;
epi.next();
}
this.keyTimes[count - 1] = 1f;
}
}
if (keyPoints != null) {
if (keyPoints.length != this.keyTimes.length) {
throw timedElement.createException
("attribute.malformed",
new Object[] { null,
SMILConstants.SMIL_KEY_POINTS_ATTRIBUTE });
}
} else {
epi = path.getExtendedPathIterator();
keyPoints = new float[count];
int j = 0;
for (int i = 0; i < count - 1; i++) {
while (epi.currentSegment() ==
ExtendedPathIterator.SEG_MOVETO) {
j++;
epi.next();
}
keyPoints[i] = pathLength.getLengthAtSegment(j) / totalLength;
j++;
epi.next();
}
keyPoints[count - 1] = 1f;
}
this.keyPoints = keyPoints;
}