void strokeDrawPolyPath(SimpleRasterizer rasterizer,
MultiPathImpl polyPath, double tol) {
Point2D[] fan = new Point2D[4];
for (int i = 0; i < fan.length; i++)
fan[i] = new Point2D();
SegmentIteratorImpl segIter = polyPath.querySegmentIterator();
double strokeHalfWidth = m_transform.transform(tol) + 1.5;
double shortSegment = 0.5;
Point2D vec = new Point2D();
Point2D vecA = new Point2D();
Point2D vecB = new Point2D();
// TODO check this Java workaroung
Point2D ptStart = new Point2D();
Point2D ptEnd = new Point2D();
Envelope2D segEnv = new Envelope2D();
Point2D ptOld = new Point2D();
while (segIter.nextPath()) {
boolean hasFan = false;
boolean first = true;
ptOld.setCoords(0, 0);
while (segIter.hasNextSegment()) {
Segment seg = segIter.nextSegment();
ptStart.x = seg.getStartX();
ptStart.y = seg.getStartY();// Point2D ptStart =
// seg.getStartXY();
ptEnd.x = seg.getEndX();
ptEnd.y = seg.getEndY();// Point2D ptEnd = seg.getEndXY();
segEnv.setEmpty();
segEnv.merge(ptStart.x, ptStart.y);
segEnv.mergeNE(ptEnd.x, ptEnd.y);
if (!m_geomEnv.isIntersectingNE(segEnv)) {
if (hasFan) {
fillConvexPolygon(rasterizer, fan, 4);
hasFan = false;
}
first = true;
continue;
}
m_transform.transform(ptEnd, ptEnd);
if (first) {
m_transform.transform(ptStart, ptStart);
ptOld.setCoords(ptStart);
first = false;
} else {
ptStart.setCoords(ptOld);
}
vec.sub(ptEnd, ptStart);
double len = vec.length();
boolean bShort = len < shortSegment;
if (len == 0) {
vec.setCoords(1.0, 0);
len = 1.0;
continue;
}
if (!bShort)
ptOld.setCoords(ptEnd);
vec.scale(strokeHalfWidth / len);
vecA.setCoords(-vec.y, vec.x);
vecB.setCoords(vec.y, -vec.x);
ptStart.sub(vec);