diff --git a/TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java b/TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java index bfd44c1e5abaa3af7d4614e9dbb0c550138794a7..d72f9a05c88f819c8d43e901fac7eb7d18b0d58a 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java +++ b/TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java @@ -284,7 +284,10 @@ public class SpatialMatrix { * are tied. */ public TangibleObject getLeftMostObject() { - return horizontal.get(0); + if (horizontal.size() > 0) + return horizontal.get(0); + + return null; } /** @@ -295,7 +298,10 @@ public class SpatialMatrix { * tied. */ public TangibleObject getRightMostObject() { - return horizontal.get(horizontal.size() - 1); + if (horizontal.size() > 0) + return horizontal.get(horizontal.size() - 1); + + return null; } /** @@ -306,7 +312,10 @@ public class SpatialMatrix { * are tied. */ public TangibleObject getTopObject() { - return vertical.get(0); + if (vertical.size() > 0) + return vertical.get(0); + + return null; } /** @@ -317,7 +326,10 @@ public class SpatialMatrix { * tied. */ public TangibleObject getBottomObject() { - return vertical.get(vertical.size() - 1); + if (vertical.size() > 0) + return vertical.get(vertical.size() - 1); + + return null; } /** diff --git a/TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java b/TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java index ab5163c536b9bc3419f523888d3408d00823d088..125d8514de0283610e3a25fa5c0e9bcad07114b6 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java +++ b/TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java @@ -164,9 +164,22 @@ public class SpatialPositioningManager implements SpatialEventListener { * are tied. */ public BaseWidget getLeftMostWidget() { + if (spatialMatrix.getLeftMostObject() == null) + return null; + return TangibleObjectManager.getWidget(spatialMatrix.getLeftMostObject().getObjectId()); } + /** + * The method will return the left-most tangible object. + * + * @return The object with the smallest x coordinate. + */ + public TangibleObject getLeftMostObject() { + return spatialMatrix.getLeftMostObject(); + } + + /** * The method will return the right-most widget, that is, the last widget found based based on * its x-axis coordinate. The retrieval is based on the underlying handles. @@ -175,9 +188,21 @@ public class SpatialPositioningManager implements SpatialEventListener { * tied. */ public BaseWidget getRightMostWidget() { + if (spatialMatrix.getRightMostObject() == null) + return null; + return TangibleObjectManager.getWidget(spatialMatrix.getRightMostObject().getObjectId()); } + /** + * The method will return the right-most tangible object. + * + * @return The object with the largest x coordinate. + */ + public TangibleObject getRightMostObject() { + return spatialMatrix.getRightMostObject(); + } + /** * The method will return the top-most widget, that is, the first widget found based based on * its y-axis coordinate. The retrieval is based on the underlying handles. @@ -186,9 +211,21 @@ public class SpatialPositioningManager implements SpatialEventListener { * are tied. */ public BaseWidget getTopWidget() { + if (spatialMatrix.getTopObject() == null) + return null; + return TangibleObjectManager.getWidget(spatialMatrix.getTopObject().getObjectId()); } + /** + * The method will return the top-most tangible object. + * + * @return The object with the smallest y coordinate. + */ + public TangibleObject getTopObject() { + return spatialMatrix.getTopObject(); + } + /** * The method will return the bottom-most widget, that is, the last widget found based based on * its y-axis coordinate. The retrieval is based on the underlying handles. @@ -197,9 +234,21 @@ public class SpatialPositioningManager implements SpatialEventListener { * tied. */ public BaseWidget getBottomWidget() { + if (spatialMatrix.getBottomObject() == null) + return null; + return TangibleObjectManager.getWidget(spatialMatrix.getBottomObject().getObjectId()); } + /** + * The method will return the bottom-most tangible object. + * + * @return The object with the largest y coordinate. + */ + public TangibleObject getBottomObject() { + return spatialMatrix.getBottomObject(); + } + /** * Method for returning a list of widgets that are to the left of a given widget. The method * either returns all objects no matter their alignment with this widget, or only returns