Commit 5ff4cc20 authored by Eric Tobias's avatar Eric Tobias

Minor modification, added Null Analysis related annotations

parent 03974785
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
package lu.list.itis.dkd.tui.space; package lu.list.itis.dkd.tui.space;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.dbc.annotation.Nullable;
import lu.list.itis.dkd.tui.TangibleObjectManager; import lu.list.itis.dkd.tui.TangibleObjectManager;
import lu.list.itis.dkd.tui.adapter.TangibleObject; import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.widget.BaseWidget; import lu.list.itis.dkd.tui.widget.BaseWidget;
...@@ -316,8 +317,11 @@ public class SpatialMatrix { ...@@ -316,8 +317,11 @@ public class SpatialMatrix {
* @return The object with the smallest x-axis coordinate. Returns the first if more than one * @return The object with the smallest x-axis coordinate. Returns the first if more than one
* are tied. * are tied.
*/ */
public TangibleObject getLeftMostObject() { public @Nullable TangibleObject getLeftMostObject() {
return horizontal.get(0); if (horizontal.size() > 0) {
return horizontal.get(0);
}
return null;
} }
/** /**
...@@ -327,8 +331,11 @@ public class SpatialMatrix { ...@@ -327,8 +331,11 @@ public class SpatialMatrix {
* @return The object with the largest x-axis coordinate. Returns the last if more than one are * @return The object with the largest x-axis coordinate. Returns the last if more than one are
* tied. * tied.
*/ */
public TangibleObject getRightMostObject() { public @Nullable TangibleObject getRightMostObject() {
return horizontal.get(horizontal.size() - 1); if (horizontal.size() > 0) {
return horizontal.get(horizontal.size() - 1);
}
return null;
} }
/** /**
...@@ -339,7 +346,10 @@ public class SpatialMatrix { ...@@ -339,7 +346,10 @@ public class SpatialMatrix {
* are tied. * are tied.
*/ */
public TangibleObject getTopObject() { public TangibleObject getTopObject() {
return vertical.get(0); if (vertical.size() > 0) {
return vertical.get(0);
}
return null;
} }
/** /**
...@@ -350,7 +360,10 @@ public class SpatialMatrix { ...@@ -350,7 +360,10 @@ public class SpatialMatrix {
* tied. * tied.
*/ */
public TangibleObject getBottomObject() { public TangibleObject getBottomObject() {
return vertical.get(vertical.size() - 1); if (vertical.size() > 0) {
return vertical.get(vertical.size() - 1);
}
return null;
} }
/** /**
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
*/ */
package lu.list.itis.dkd.tui.space; package lu.list.itis.dkd.tui.space;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.dbc.annotation.Nullable;
import lu.list.itis.dkd.tui.TangibleObjectManager; import lu.list.itis.dkd.tui.TangibleObjectManager;
import lu.list.itis.dkd.tui.adapter.TangibleObject; import lu.list.itis.dkd.tui.adapter.TangibleObject;
import lu.list.itis.dkd.tui.event.SpatialEvent; import lu.list.itis.dkd.tui.event.SpatialEvent;
...@@ -54,6 +56,7 @@ import java.util.logging.Logger; ...@@ -54,6 +56,7 @@ import java.util.logging.Logger;
* @since 2.1 * @since 2.1
* @version 2.1.3 * @version 2.1.3
*/ */
@NonNullByDefault
public class SpatialPositioningManager implements SpatialEventListener { public class SpatialPositioningManager implements SpatialEventListener {
private static final Logger logger = Logger.getLogger(SpatialPositioningManager.class.getSimpleName()); private static final Logger logger = Logger.getLogger(SpatialPositioningManager.class.getSimpleName());
...@@ -66,6 +69,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -66,6 +69,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* Enumeration showing all alignment types this class supports. * Enumeration showing all alignment types this class supports.
* *
* @author Eric Tobias [eric.tobias@list.lu] * @author Eric Tobias [eric.tobias@list.lu]
* @author Valérie Maquil [valerie.maquil@list.lu]
* @since 2.1 * @since 2.1
* @version 2.1.3 * @version 2.1.3
*/ */
...@@ -172,7 +176,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -172,7 +176,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* @return The widget with the smallest x-axis coordinate. Returns the first if more than one * @return The widget with the smallest x-axis coordinate. Returns the first if more than one
* are tied. Will return <code>null</code> if no object is present. * are tied. Will return <code>null</code> if no object is present.
*/ */
public BaseWidget getLeftMostWidget() { public @Nullable BaseWidget getLeftMostWidget() {
if (getLeftMostObject() == null) { if (getLeftMostObject() == null) {
return null; return null;
} }
...@@ -185,7 +189,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -185,7 +189,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* *
* @return The object with the smallest x coordinate. * @return The object with the smallest x coordinate.
*/ */
public TangibleObject getLeftMostObject() { public @Nullable TangibleObject getLeftMostObject() {
return spatialMatrix.getLeftMostObject(); return spatialMatrix.getLeftMostObject();
} }
...@@ -197,9 +201,10 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -197,9 +201,10 @@ public class SpatialPositioningManager implements SpatialEventListener {
* @return The widget with the largest x-axis coordinate. Returns the last if more than one are * @return The widget with the largest x-axis coordinate. Returns the last if more than one are
* tied. Will return <code>null</code> if no object is present. * tied. Will return <code>null</code> if no object is present.
*/ */
public BaseWidget getRightMostWidget() { public @Nullable BaseWidget getRightMostWidget() {
if (getRightMostObject() == null) if (null == getRightMostObject()) {
return null; return null;
}
return TangibleObjectManager.getWidget(getRightMostObject().getObjectId()); return TangibleObjectManager.getWidget(getRightMostObject().getObjectId());
} }
...@@ -209,7 +214,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -209,7 +214,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* *
* @return The object with the largest x coordinate. * @return The object with the largest x coordinate.
*/ */
public TangibleObject getRightMostObject() { public @Nullable TangibleObject getRightMostObject() {
return spatialMatrix.getRightMostObject(); return spatialMatrix.getRightMostObject();
} }
...@@ -220,8 +225,8 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -220,8 +225,8 @@ public class SpatialPositioningManager implements SpatialEventListener {
* @return The widget with the smallest y-axis coordinate. Returns the first if more than one * @return The widget with the smallest y-axis coordinate. Returns the first if more than one
* are tied. Will return <code>null</code> if no object is present. * are tied. Will return <code>null</code> if no object is present.
*/ */
public BaseWidget getTopWidget() { public @Nullable BaseWidget getTopWidget() {
if (getTopObject() == null) { if (null == getTopObject()) {
return null; return null;
} }
...@@ -233,7 +238,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -233,7 +238,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* *
* @return The object with the smallest y coordinate. * @return The object with the smallest y coordinate.
*/ */
public TangibleObject getTopObject() { public @Nullable TangibleObject getTopObject() {
return spatialMatrix.getTopObject(); return spatialMatrix.getTopObject();
} }
...@@ -244,7 +249,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -244,7 +249,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* @return The widget with the largest y-axis coordinate. Returns the last if more than one are * @return The widget with the largest y-axis coordinate. Returns the last if more than one are
* tied. Will return <code>null</code> if no object is present. * tied. Will return <code>null</code> if no object is present.
*/ */
public BaseWidget getBottomWidget() { public @Nullable BaseWidget getBottomWidget() {
if (getBottomObject() == null) { if (getBottomObject() == null) {
return null; return null;
} }
...@@ -257,7 +262,7 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -257,7 +262,7 @@ public class SpatialPositioningManager implements SpatialEventListener {
* *
* @return The object with the largest y coordinate. * @return The object with the largest y coordinate.
*/ */
public TangibleObject getBottomObject() { public @Nullable TangibleObject getBottomObject() {
return spatialMatrix.getBottomObject(); return spatialMatrix.getBottomObject();
} }
...@@ -284,7 +289,6 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -284,7 +289,6 @@ public class SpatialPositioningManager implements SpatialEventListener {
public List<TangibleObject> getObjectToLeftOf(BaseWidget widget) { public List<TangibleObject> getObjectToLeftOf(BaseWidget widget) {
return spatialMatrix.leftOf(TangibleObjectManager.getIdentifier(widget)); return spatialMatrix.leftOf(TangibleObjectManager.getIdentifier(widget));
} }
/** /**
......
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