if (tm != null) {
if (tm != null && tm.isVisible()) {
    public Rectangle commitPaint(MultilayerPlane mp, int x, int y,            int initLayer)    {        Rectangle bounds = this.getBounds();        int centerx = (int)(x - (bounds.width / 2));        int centery = (int)(y - (bounds.height / 2));                ListIterator itr = getLayers();        while (itr.hasNext()) {            TileLayer tl = (TileLayer)itr.next();                        TileLayer tm = (TileLayer)mp.getLayer(initLayer++);            if (tm != null) {                tl.setOffset(centerx, centery);                tl.mergeOnto(tm);            }        }                return new Rectangle(centerx, centery, bounds.width, bounds.height);    }