@Override
	public void mouseDragged(MouseEvent e) {
		Point mouse = new Point((int) (e.getX() / (pv.getZoom() / 100)), (int) (e.getY() / (pv.getZoom() / 100)));
		
		if(pv.act == SELECT) {
			if(!isKeyDown(KeyEvent.VK_CONTROL)) {
				
				int dx = mouse.x - lastMouse.x;
				int dy = mouse.y - lastMouse.y;
				
				if(pv.selected.size() > 1) {					
					for(int i = 0; i < pv.selected.size(); i++) {
						Table t = pv.selected.get(i);
						t.addX(dx);
						t.addY(dy);
						pv.clampTable(t);
					}
				} else if(pv.selected.size() == 1 && isKeyDown(KeyEvent.VK_SHIFT)) {
					Table sel = pv.selected.get(0);
					
					if(!sel.contains(mouse)) {
						sel.setX(mouse.x - sel.getWidth() / 2);
						sel.setY(mouse.y - sel.getHeight() / 2);
					}
					
					int onX = sel.getX();
					int onY = sel.getY();
					
					Rectangle snapTo = ((JViewport) pv.getParent()).getViewRect();
					
					boolean xSet = false;
					boolean ySet = false;
					
					for(int i = 0; i < pv.tables.size(); i++) {
						Table t = pv.tables.get(i);
						if(t != sel && snapTo.intersects(new Rectangle(t.getX(), t.getY(), t.getWidth(), t.getHeight()))) {
							int lowX = t.getX() - Constants.SNAP_TO_CHECK;
							int highX = t.getX() + Constants.SNAP_TO_CHECK;
							int lowY = t.getY() - Constants.SNAP_TO_CHECK;
							int highY = t.getY() + Constants.SNAP_TO_CHECK;
							
							if(!xSet && lowX < onX && onX < highX) {
								sel.setX(t.getX());
								xSet = true;
							}
								
							
							if(!ySet && lowY < onY && onY < highY) {
								sel.setY(t.getY());
								ySet = true;
							}
							
							if(xSet && ySet) break;
						}
					}
					
					if(!xSet) sel.addX(dx);
					if(!ySet) sel.addY(dy);
					
					pv.clampTable(sel);
					pv.info.updatePos();
				} else if(pv.selected.size() == 1 && !isKeyDown(KeyEvent.VK_SHIFT)) {
					Table sel = pv.selected.get(0);
					
					if(!sel.contains(mouse)) {
						sel.setX(mouse.x - sel.getWidth() / 2);
						sel.setY(mouse.y - sel.getHeight() / 2);
					}
					
					sel.addX(dx);
					sel.addY(dy);
					pv.clampTable(sel);
					pv.info.updatePos();
				} else if(pv.selected.isEmpty()) {
					if(!isKeyDown(KeyEvent.VK_SHIFT) && !pv.dragRect.isDragging()) {
						pv.act = DRAG;
						pv.dragRect.start(mouse);
					}
				}
				
				lastMouse = mouse;
			}
		} else if(pv.act == DRAG) {
			pv.dragRect.updateRect(mouse);
		}
	}