public void paint(Graphics g) 
	{
		super.paint(g);		
		if (shapes == null) return;

		long timeOverlap = - System.currentTimeMillis();

		// reset overlaps
		for (Shape s: shapes) s.overlaps = false;

		// Calculate overlaps
		for (Shape s1: shapes) {
			for (Shape s2: shapes) {
				if (s1.hashCode() < s2.hashCode()) { // check distinct pairs once
					if (s1.overlaps(s2)) {
						s1.overlaps = true;
						s2.overlaps = true;
					}
				}
			}
		}

		// Calculate overlap with off-screen canvas: (Can't move objects off-screen to win)
		for (Shape s1: shapes) {
			if(s1.overlapsOffscreen(width/scale, height/scale)) // omit "pixelWidth"
				s1.overlaps = true;
		}

		timeOverlap += System.currentTimeMillis();

		long timeDisplay = - System.currentTimeMillis();
		for (Shape s: shapes) {
			s.paint(g,scale);
		}
		timeDisplay += System.currentTimeMillis();
		System.out.println("Timing Breakdown: Overlap="+timeOverlap+"ms,  Display="+timeDisplay+"ms");
	}