mouseButton = MouseEvent.NOBUTTON; bMouseIsDown = false; bMouseIsDragging = false;
    public void mouseReleased(MouseEvent event) {        mouseButton = MouseEvent.NOBUTTON;        bMouseIsDown = false;        MapLayer layer = getCurrentLayer();        Point limp = mouseInitialPressLocation;       if (currentPointerState == PS_MARQUEE) {           Point tile = mapView.screenToTileCoords(event.getX(), event.getY());           if (tile.y - limp.y == 0 && tile.x - limp.x == 0) {               if (marqueeSelection != null) {                   currentMap.removeLayerSpecial(marqueeSelection);                   marqueeSelection = null;               }           }        } else if (currentPointerState == PS_MOVE) {            if (layer != null && moveDist.x != 0 || moveDist.x != 0) {                undoSupport.postEdit(new MoveLayerEdit(layer, moveDist));            }        } else if (currentPointerState == PS_PAINT) {            currentBrush.endPaint();        }        if (paintEdit != null) {            if (layer != null) {                try {                    MapLayer endLayer = paintEdit.getStart().createDiff(layer);                    paintEdit.end(endLayer);                    undoSupport.postEdit(paintEdit);                } catch (Exception e) {                    e.printStackTrace();                }            }            paintEdit = null;        }    }