Commit e5fe468b authored by Eric Tobias's avatar Eric Tobias

2.1.2 - Finalized SpatialMatrix's basic position management

parent e90a6339
2.1.2
+ Added ShapeCorona and related builders.
2.1.0 2.1.0
+ Adding event broadcaster for TUI context events. + Adding event broadcaster for TUI context events.
......
...@@ -160,7 +160,10 @@ public class SpatialMatrix { ...@@ -160,7 +160,10 @@ public class SpatialMatrix {
* object (by ID). The method will return a new list build from the sublist of the horizontal * object (by ID). The method will return a new list build from the sublist of the horizontal
* space.<br /> * space.<br />
* To determine whether something is "left", the method will make a sub-list of all elements * To determine whether something is "left", the method will make a sub-list of all elements
* with a lower index in the list than the parameterized object. * with a lower index in the list than the parameterized object.<br />
* The returned list is to be read from left to right, that is, to be treated as if the object
* was added to the end. Hence, the first element is furthest away while the last element is
* closest.
* *
* @param objectId * @param objectId
* The object for which to retrieve all objects to the left of. * The object for which to retrieve all objects to the left of.
...@@ -169,12 +172,12 @@ public class SpatialMatrix { ...@@ -169,12 +172,12 @@ public class SpatialMatrix {
*/ */
public synchronized List<TangibleObject> leftOf(int objectId) { public synchronized List<TangibleObject> leftOf(int objectId) {
int index = findHorizontalIndexFor(objectId); int index = findHorizontalIndexFor(objectId);
return new ArrayList<>(horizontal.subList(index, horizontal.size())); return new ArrayList<>(horizontal.subList(0, index));
} }
public synchronized List<TangibleObject> rightOf(int objectId) { public synchronized List<TangibleObject> rightOf(int objectId) {
int index = findHorizontalIndexFor(objectId); int index = findHorizontalIndexFor(objectId) + 1;
return new ArrayList<>(horizontal.subList(0, index)); return new ArrayList<>(horizontal.subList(index, horizontal.size()));
} }
public synchronized List<TangibleObject> above(int objectId) { public synchronized List<TangibleObject> above(int objectId) {
...@@ -183,8 +186,8 @@ public class SpatialMatrix { ...@@ -183,8 +186,8 @@ public class SpatialMatrix {
} }
public synchronized List<TangibleObject> below(int objectId) { public synchronized List<TangibleObject> below(int objectId) {
int index = findHorizontalIndexFor(objectId); int index = findHorizontalIndexFor(objectId) + 1;
return new ArrayList<>(horizontal.subList(index, vertical.size())); return new ArrayList<>(vertical.subList(index, vertical.size()));
} }
String printLists() { String printLists() {
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
*/ */
package lu.list.itis.dkd.tui.space; package lu.list.itis.dkd.tui.space;
import lu.list.itis.dkd.tui.TangibleObjectManager;
import lu.list.itis.dkd.tui.event.SpatialEvent; import lu.list.itis.dkd.tui.event.SpatialEvent;
import lu.list.itis.dkd.tui.event.SpatialEventListener; import lu.list.itis.dkd.tui.event.SpatialEventListener;
import lu.list.itis.dkd.tui.utility.PropertiesFetcher; import lu.list.itis.dkd.tui.utility.PropertiesFetcher;
...@@ -68,6 +69,15 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -68,6 +69,15 @@ public class SpatialPositioningManager implements SpatialEventListener {
return INSTANCE; return INSTANCE;
} }
/**
* Simple getter method for spatialMatrix.
*
* @return The value of spatialMatrix.
*/
public SpatialMatrix getSpatialMatrix() {
return spatialMatrix;
}
/** /**
* Method for configuring a {@link Logger} with several properties as given by the loader * Method for configuring a {@link Logger} with several properties as given by the loader
* properties file. * properties file.
...@@ -89,10 +99,20 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -89,10 +99,20 @@ public class SpatialPositioningManager implements SpatialEventListener {
unconfiguredLogger.setLevel(Level.parse(properties.getProperty("logger.level"))); //$NON-NLS-1$ unconfiguredLogger.setLevel(Level.parse(properties.getProperty("logger.level"))); //$NON-NLS-1$
} }
/** {@inheritDoc} */ /**
* {@inheritDoc} <br/>
* <br/>
*
* The event will not be registered if the if of the tangible is not recognized by the
* {@link TangibleObjectManager}.
*/
@Override @Override
public void spaceUpdated(SpatialEvent event) { public void spaceUpdated(SpatialEvent event) {
if (TangibleObjectManager.getWidget(event.getSource().getObjectId()) == null) {
return;
}
switch (event.getType()) { switch (event.getType()) {
case UPDATE: case UPDATE:
spatialMatrix.update(event.getSource()); spatialMatrix.update(event.getSource());
...@@ -107,6 +127,15 @@ public class SpatialPositioningManager implements SpatialEventListener { ...@@ -107,6 +127,15 @@ public class SpatialPositioningManager implements SpatialEventListener {
logger.log(Level.SEVERE, "Spatial event type \"" + event.getType() + "\" not recognized!"); //$NON-NLS-1$ //$NON-NLS-2$ logger.log(Level.SEVERE, "Spatial event type \"" + event.getType() + "\" not recognized!"); //$NON-NLS-1$ //$NON-NLS-2$
break; break;
} }
System.out.println(spatialMatrix.printLists()); // System.out.println(spatialMatrix.printLists());
// System.out.println("Left of " + event.getSource().getObjectId() + ": " +
// spatialMatrix.leftOf(event.getSource().getObjectId())); //$NON-NLS-1$ //$NON-NLS-2$
// System.out.println("Right of " + event.getSource().getObjectId() + ": " +
// spatialMatrix.rightOf(event.getSource().getObjectId())); //$NON-NLS-1$ //$NON-NLS-2$
// System.out.println("Above " + event.getSource().getObjectId() + ": " +
// spatialMatrix.above(event.getSource().getObjectId())); //$NON-NLS-1$ //$NON-NLS-2$
// System.out.println("Below " + event.getSource().getObjectId() + ": " +
// spatialMatrix.below(event.getSource().getObjectId())); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
\ No newline at end of file
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