for (int y = Math.min(mousePressLocation.y,tile.y); y < Math.max(mousePressLocation.y,tile.y); y++) { for (int x = Math.min(mousePressLocation.x,tile.x); x < Math.max(mousePressLocation.x,tile.x); x++) {
for (int y = Math.min(mouseInitialPressLocation.y,tile.y); y < Math.max(mouseInitialPressLocation.y,tile.y); y++) { for (int x = Math.min(mouseInitialPressLocation.x,tile.x); x < Math.max(mouseInitialPressLocation.x,tile.x); x++) {
    private void doMouse(MouseEvent event) {        if (currentMap == null || currentLayer < 0) {            return;        }        Point tile = mapView.screenToTileCoords(event.getX(), event.getY());        MapLayer layer = currentMap.getLayer(currentLayer);        if (layer == null) {            return;        } else if (mouseButton == MouseEvent.BUTTON3) {            Tile newTile = layer.getTileAt(tile.x, tile.y);            if (newTile != currentMap.getNullTile()) {                setCurrentTile(newTile);            }        } else if (mouseButton == MouseEvent.BUTTON1) {            switch (currentPointerState) {                case PS_PAINT:                    paintEdit.setPresentationName("Paint");                    currentBrush.commitPaint(                            currentMap, tile.x, tile.y, currentLayer);                    mapView.repaintRegion(                            currentBrush.getCenteredBounds(tile.x, tile.y));                    break;                case PS_ERASE:                    paintEdit.setPresentationName("Erase");                    layer.setTileAt(tile.x, tile.y, currentMap.getNullTile());                    mapView.repaintRegion(new Rectangle(tile.x, tile.y, 1, 1));                    break;                case PS_POUR:                    paintEdit = null;                    Tile oldTile = layer.getTileAt(tile.x, tile.y);                    pour(layer, tile.x, tile.y, currentTile, oldTile);                    mapView.repaint();                    break;                case PS_EYED:                    Tile newTile = layer.getTileAt(tile.x, tile.y);                    if (newTile != currentMap.getNullTile()) {                        setCurrentTile(newTile);                    }                    break;                case PS_MOVE:                    layer.translate(                            tile.x - this.mousePressLocation.x,                            tile.y - mousePressLocation.y);                    mapView.repaint();                    break;				case PS_MARQUEE:					if(marqueeSelection != null) {						for (int y = Math.min(mousePressLocation.y,tile.y); y < Math.max(mousePressLocation.y,tile.y); y++) {								for (int x = Math.min(mousePressLocation.x,tile.x); x < Math.max(mousePressLocation.x,tile.x); x++) {										marqueeSelection.select(x,y);								}						}						mapView.repaintRegion(new Rectangle(mousePressLocation.x, mousePressLocation.y, tile.x, tile.y));					}					break;            }        }    }