View RSS Feed

Java AWT

Clipping the Drawing Region

Rate this Entry
by , 03-04-2012 at 04:49 PM (557 Views)
As a clipping path, shape object is used so that to restrict that drawing areas which will render. Clipping path is considered to be the portion of Graphic2D context. Call the Graphics2D.setClip & pass ahpe so that to set clip’s attributes. Clipping path gets shrink by clip method calling & then passing to other shape. A clip intersects to current shape and specified shape.

To set clip method pass the ellipse & call clip so that for setting the clip path for intersection of rectangle & ellipse.
Java Code:
private Ellipse2D ellipse = new Ellipse2D.Float();
private Rectangle2D rect = new Rectangle2D.Float();
...
ellipse.setFrame(x, y, ew, eh);
g2.setClip(ellipse);
rect.setRect(x+5, y+5, ew-10, eh-10);
g2.clip(rect);

Submit "Clipping the Drawing Region" to Facebook Submit "Clipping the Drawing Region" to Digg Submit "Clipping the Drawing Region" to del.icio.us Submit "Clipping the Drawing Region" to StumbleUpon Submit "Clipping the Drawing Region" to Google

Categories
Graphics

Comments