I am wanting to turn the example below in a figure that uses RoundedRectangles instead of normal rectangles, I know there are possibilities with the clipping frame. But I don't really know how they would apply to my current situation, as I am not using a g2d.fillXXX() function currently.
The image: example http://img827.imageshack.us/img827/6048/cardbackgroundcut.jpg
The code:
private void createImage() {
bufferedImage = new BufferedImage(dimension.width, dimension.height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = (Graphics2D)bufferedImage.createGraphics();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
g2d.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
int colorRed = 128;
int colorGreen = 0;
int colorBlue = 128;
for (int x = 0; x < dimension.width; x++) {
for (int y = 0; y < dimension.height; y++) {
int dx = Math.min(x, dimension.width - x);
int dy = Math.min(y, dimension.height - y);
if (dx < 10 || dy < 10) {
g2d.setColor(new Color(colorRed, colorGreen, colorBlue, 255 - Math.min(dx, dy)));
g2d.drawLine(x, y, x, y);
}
else {
g2d.setColor(new Color(colorRed, colorGreen, colorBlue, 192 - Math.min(dx, dy)));
g2d.drawLine(x, y, x, y);
}
}
}
}
So basically I would want both the outer edge and the inner edge of the image have a rounded rectangle, while preversing the changes in color.
Any clues how to accomplish this?
Regards.