public Raster getRaster(int xOffset, int yOffset, int w, int h) {
            ColorModel cm = getColorModel();
            if (raster == null) createRaster();
            // TODO: eventually use caching here
            WritableRaster childRaster = cm.createCompatibleWritableRaster(w, h);
            Rectangle2D childRect = new Rectangle2D.Double(xOffset, yOffset, w, h);
            if (!childRect.intersects(deviceBounds)) {
                // usually doesn't happen ...
                return childRaster;
            }
            Rectangle2D destRect = new Rectangle2D.Double();
            Rectangle2D.intersect(childRect, deviceBounds, destRect);
            int dx = (int)(destRect.getX()-deviceBounds.getX());
            int dy = (int)(destRect.getY()-deviceBounds.getY());
            int dw = (int)destRect.getWidth();
            int dh = (int)destRect.getHeight();
            Object data = raster.getDataElements(dx, dy, dw, dh, null);
            dx = (int)(destRect.getX()-childRect.getX());
            dy = (int)(destRect.getY()-childRect.getY());
            childRaster.setDataElements(dx, dy, dw, dh, data);
            return childRaster;
        }
public Raster getRaster(int xOffset, int yOffset, int w, int h) {
            ColorModel cm = getColorModel();
            if (raster == null) createRaster();
           
            WritableRaster childRaster = cm.createCompatibleWritableRaster(w, h);
            Rectangle2D childRect = new Rectangle2D.Double(xOffset, yOffset, w, h);
            if (!childRect.intersects(deviceBounds)) {
               
                return childRaster;
            }
            Rectangle2D destRect = new Rectangle2D.Double();
            Rectangle2D.intersect(childRect, deviceBounds, destRect);
            int dx = (int)(destRect.getX()-deviceBounds.getX());
            int dy = (int)(destRect.getY()-deviceBounds.getY());
            int dw = (int)destRect.getWidth();
            int dh = (int)destRect.getHeight();
            Object data = raster.getDataElements(dx, dy, dw, dh, null);
            dx = (int)(destRect.getX()-childRect.getX());
            dy = (int)(destRect.getY()-childRect.getY());
            childRaster.setDataElements(dx, dy, dw, dh, data);
            return childRaster;
        }
public raster getraster(int xoffset, int yoffset, int w, int h) { colormodel cm = getcolormodel(); if (raster == null) createraster(); writableraster childraster = cm.createcompatiblewritableraster(w, h); rectangle2d childrect = new rectangle2d.double(xoffset, yoffset, w, h); if (!childrect.intersects(devicebounds)) { return childraster; } rectangle2d destrect = new rectangle2d.double(); rectangle2d.intersect(childrect, devicebounds, destrect); int dx = (int)(destrect.getx()-devicebounds.getx()); int dy = (int)(destrect.gety()-devicebounds.gety()); int dw = (int)destrect.getwidth(); int dh = (int)destrect.getheight(); object data = raster.getdataelements(dx, dy, dw, dh, null); dx = (int)(destrect.getx()-childrect.getx()); dy = (int)(destrect.gety()-childrect.gety()); childraster.setdataelements(dx, dy, dw, dh, data); return childraster; }