} else if (mouseButton == MouseEvent.BUTTON2 || mouseButton == MouseEvent.BUTTON1
&& (event.getModifiersEx() & InputEvent.ALT_DOWN_MASK) != 0) {
// Scroll with middle mouse button
int dx = event.getX() - mouseInitialScreenLocation.x;
int dy = event.getY() - mouseInitialScreenLocation.y;
JViewport mapViewPort = mapScrollPane.getViewport();
Point currentPosition = mapViewPort.getViewPosition();
mouseInitialScreenLocation = new Point(event.getX() - dx, event.getY() - dy);
Point newPosition = new Point(currentPosition.x - dx, currentPosition.y - dy);
// Take into account map boundaries in order to prevent
// scrolling past them
int maxX = mapView.getWidth() - mapViewPort.getWidth();
int maxY = mapView.getHeight() - mapViewPort.getHeight();
newPosition.x = Math.min(maxX, Math.max(0, newPosition.x));
newPosition.y = Math.min(maxY, Math.max(0, newPosition.y));
mapViewPort.setViewPosition(newPosition);
} else if (mouseButton == MouseEvent.BUTTON1) {
switch (currentPointerState) {
case PS_PAINT:
paintEdit.setPresentationName(TOOL_PAINT);
if (layer instanceof TileLayer) {