BufferedImage finalImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
// Polygon polygon = d.polygon(new int[]{40,30, 60,70, 30,130, 130,130, 130,30});
int[] xy = new int[]{(int) (height * 0.15), (int) (width * 0.85), (int) (height * 0.35), (int) (width * 0.15),
(int) (height * 0.75), (int) (width * 0.85), (int) (height * 0.85), (int) (width * 0.15)};
LineString line = d.line(xy);
d.drawDirect(finalImage, d.feature(line), newRule);
Graphics2D g2d = finalImage.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawImage(finalImage, 0, 0, null);
g2d.dispose();