if (mouseButton == MouseEvent.BUTTON3 && getCurrentLayer() instanceof TileLayer && currentPointerState == PS_PAINT) { Point limp = mouseInitialPressLocation; int minx = Math.min(limp.x, tile.x); int miny = Math.min(limp.y, tile.y); Rectangle oldArea = null;  if (currentBrush instanceof CustomBrush) { oldArea = ((CustomBrush)currentBrush).getBounds(); }  Rectangle bounds = new Rectangle( minx, miny, (Math.max(limp.x, tile.x) - minx)+1, (Math.max(limp.y, tile.y) - miny)+1);   MultilayerPlane mlp = new MultilayerPlane(bounds.width, bounds.height); TileLayer brushLayer = new TileLayer(bounds); brushLayer.copyFrom(getCurrentLayer()); mlp.addLayer(brushLayer); setBrush(new CustomBrush(mlp)); } else { doMouse(e); }
    public void mouseDragged(MouseEvent e) {        doMouse(e);        mousePressLocation = mapView.screenToTileCoords(e.getX(), e.getY());        Point tile = mapView.screenToTileCoords(e.getX(), e.getY());        if (currentMap.inBounds(tile.x, tile.y)) {            tileCoordsLabel.setText("" + tile.x + ", " + tile.y);        } else {            tileCoordsLabel.setText(" ");        }        updateCursorHighlight(tile);    }