private void selectCloestPoint(int x, int y){
		double distance = pattern.windowHeight+pattern.windowWidth;
		double d = pattern.windowHeight+pattern.windowWidth; //temporary distance
		//search the array backwards, so the line that is on top will get selected
		for (int i =drawings.getShapes().size()-1; i >=0 ; --i){
			CustomShape s = drawings.getShapes().get(i);
			s.setSelected(false);
			d = s.findCloestestDistance(x,y);

			if (d < distance ){
				distance = d;
				selectedShape = s;
				if (d == 0) {//close point found, no longer need to keep seraching
					break;
				}
			}

	    }
		if (selectedShape != null && distance <= distanceToSelect) selectedShape.setSelected(true);
	}