});
}
// Take advantage of CreatePolyPolygonalRgn on w32
private void setMask(final Component w, final Area area) {
GDI32 gdi = GDI32.INSTANCE;
PathIterator pi = area.getPathIterator(null);
int mode = pi.getWindingRule() == PathIterator.WIND_NON_ZERO
? WinGDI.WINDING: WinGDI.ALTERNATE;
float[] coords = new float[6];
List<POINT> points = new ArrayList<POINT>();
int size = 0;
List<Integer> sizes = new ArrayList<Integer>();
while (!pi.isDone()) {
int type = pi.currentSegment(coords);
if (type == PathIterator.SEG_MOVETO) {
size = 1;
points.add(new POINT((int)coords[0], (int)coords[1]));
}
else if (type == PathIterator.SEG_LINETO) {
++size;
points.add(new POINT((int)coords[0], (int)coords[1]));
}
else if (type == PathIterator.SEG_CLOSE) {
sizes.add(new Integer(size));
}
else {
throw new RuntimeException("Area is not polygonal: " + area);
}
pi.next();
}
POINT[] lppt = (POINT[])new POINT().toArray(points.size());
POINT[] pts = points.toArray(new POINT[points.size()]);
for (int i=0;i < lppt.length;i++) {
lppt[i].x = pts[i].x;
lppt[i].y = pts[i].y;
}
int[] counts = new int[sizes.size()];
for (int i=0;i < counts.length;i++) {
counts[i] = sizes.get(i).intValue();
}
HRGN hrgn = gdi.CreatePolyPolygonRgn(lppt, counts, counts.length, mode);
setWindowRegion(w, hrgn);
}