public void handleMouseClickEvent(int clicks, Point pos) {
		double clickX = (double)pos.getX()/(double)getWidth();
		double clickY = (double)pos.getY()/(double)getHeight();

		//System.out.println("Handling mouse click event with # clicks = " + clicks);
		//Kind of confusing implementation, the tricky part is that we want to call
		//unclicked() even if the click has been consumed. 
		boolean clickConsumed = false;  
		
		if (clicks>1) {
			//Traverse in reverse order so elements that are on top get called first
			for(int i=elements.size()-1; i>=0; i--) {
				FigureElement element = elements.get(i);
				if (element.contains(clickX, clickY)) {
					if (!clickConsumed) {
						element.doubleClicked(pos);
						clickConsumed = element.consumesMouseClick();
					}
				}
				
			}
		}
		else {	//Single click
			boolean somethingClicked = false;
			for(int i=elements.size()-1; i>=0; i--) {
				FigureElement element = elements.get(i);
				if (element.contains(clickX, clickY)) {
					if (!clickConsumed) {  
						element.clicked(pos);
						somethingClicked = true;
						clickConsumed = element.consumesMouseClick();		
					}
				}
				else { 
					element.unClicked();
				}		
			}
			
			if (! somethingClicked) {
				selectRect.x = 0;
				selectRect.y = 0;
				selectRect.width = 0;
				selectRect.height = 0;
				selectionRectUpdated(selectRect);
			}
			
		}// Single click
		
		repaint();		
	}