if (this.validArea.isEmpty()) {
area = new Double(0);
return;
}
PathIterator pi = this.validArea.getPathIterator(new AffineTransform());
ArrayList points = new ArrayList();
//System.out.println("iteracao: " + cor);
while (!pi.isDone()) {
double[] point = new double[6];
int mode = pi.currentSegment(point);
if (mode == PathIterator.SEG_MOVETO) {
//System.out.println("MOVE_TO");
if (points.size() != 0) {
// FINALIZAR ESSA SHAPE E ADICIONAR A AREA A A
// System.out.println("WEIRD MOVE_TO");
a += calculaArea(points);
}
double[] p = new double[2];
p[0] = point[0];
p[1] = point[1];
// System.out.println("Comecando em " + p[0] + "," + p[1]);
points.add(p);
} else if (mode == PathIterator.SEG_LINETO) {
double[] p = new double[2];
p[0] = point[0];
p[1] = point[1];
// System.out.println("passando em " + p[0] + "," + p[1]);
points.add(p);
} else if (mode == PathIterator.SEG_CLOSE) {
// System.out.println("fechando com " + points.size() + "
// pontos");
a += calculaArea(points);
} else {
throw new AssertionError();
}
pi.next();
}
this.area = new Double(Math.abs(a));