/*******************************************************************************
 * Copyright 2013 Comcast Cable Communications Management, LLC
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package com.comcast.freeflow.utils;

import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import com.comcast.freeflow.core.FreeFlowItem;

public class ViewUtils {
	public static FreeFlowItem getItemAt(Map<? extends Object, FreeFlowItem> frameDescriptors, int x, int y){

		Iterator<? extends Object> it=  frameDescriptors.entrySet().iterator();
			
		while (it.hasNext()) {
			Entry<Object, FreeFlowItem> pair = (Entry<Object, FreeFlowItem>) it.next();
			if(pair.getValue().frame.contains((int)x, (int)y)) return pair.getValue();
	      
	    }
		return null;
	}
}

@@ -1010,31 +1010,16 @@
 At(Map%3C?
- extends Object
 , FreeFl
@@ -1063,268 +1063,200 @@
 y)%7B%0A
-%0A%09%09Iterator%3C? extends Object%3E it=  frameDescriptors.entrySet().iterator();%0A%09%09%09%0A%09%09while (it.hasNext()) %7B%0A%09%09%09Entry%3CObject, FreeFlowItem%3E pair = (Entry%3CObject, FreeFlowItem%3E) it.next();%0A%09%09%09if(pair.getValue().frame.contains((int)x, (int)y)) return pair.getValue();
+        FreeFlowItem returnValue = null;%0A%0A%09%09for(FreeFlowItem item : frameDescriptors.values()) %7B%0A%09%09%09if(item.frame.contains((int)x, (int)y)) %7B%0A                returnValue =  item;%0A            %7D
 %0A%09  
@@ -1276,19 +1276,26 @@
 %09return 
-null
+returnValue
 ;%0A%09%7D%0A%7D%0A

Refactor ViewUtils