Commit b2d45017 authored by Valérie Maquil's avatar Valérie Maquil

added method for rightmostWidget of a certain class

parent 7b304a28
......@@ -294,6 +294,37 @@ public class SpatialPositioningManager implements SpatialEventListener {
return TangibleObjectManager.getWidget(getRightMostObject().getObjectId());
}
/**
* The method will return the right-most widget, that is, the last widget found based based on
* its x-axis coordinate that is of the provided class. The retrieval is based on the underlying
* handles.
*
* @param <T>
*
* @param _class
* The {@link Class} of the widget that should be returned.
*
* @return The widget with the largest x-axis coordinate that is of the given class. Returns the
* last if more than one are tied. Will return <code>null</code> if no object is
* present.
*/
@SuppressWarnings("unchecked")
public @Nullable <T> T getRightMostWidget(Class<T> _class) {
if (getRightMostObject() == null) {
return null;
}
for (int i = spatialMatrix.getHorizontal().size() - 1; i >= 0; i--) {
TangibleObject object = spatialMatrix.getHorizontal().get(i);
BaseWidget widget = TangibleObjectManager.getWidget(object.getObjectId());
if (widget.getClass().equals(_class)) {
return (T) widget;
}
}
return null;
}
/**
* The method will return the right-most tangible object.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment