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
+ Adding event broadcaster for TUI context events.
......
......@@ -160,7 +160,10 @@ public class SpatialMatrix {
* object (by ID). The method will return a new list build from the sublist of the horizontal
* space.<br />
* 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
* The object for which to retrieve all objects to the left of.
......@@ -169,12 +172,12 @@ public class SpatialMatrix {
*/
public synchronized List<TangibleObject> leftOf(int 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) {
int index = findHorizontalIndexFor(objectId);
return new ArrayList<>(horizontal.subList(0, index));
int index = findHorizontalIndexFor(objectId) + 1;
return new ArrayList<>(horizontal.subList(index, horizontal.size()));
}
public synchronized List<TangibleObject> above(int objectId) {
......@@ -183,8 +186,8 @@ public class SpatialMatrix {
}
public synchronized List<TangibleObject> below(int objectId) {
int index = findHorizontalIndexFor(objectId);
return new ArrayList<>(horizontal.subList(index, vertical.size()));
int index = findHorizontalIndexFor(objectId) + 1;
return new ArrayList<>(vertical.subList(index, vertical.size()));
}
String printLists() {
......
......@@ -16,6 +16,7 @@
*/
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.SpatialEventListener;
import lu.list.itis.dkd.tui.utility.PropertiesFetcher;
......@@ -68,6 +69,15 @@ public class SpatialPositioningManager implements SpatialEventListener {
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
* properties file.
......@@ -89,10 +99,20 @@ public class SpatialPositioningManager implements SpatialEventListener {
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
public void spaceUpdated(SpatialEvent event) {
if (TangibleObjectManager.getWidget(event.getSource().getObjectId()) == null) {
return;
}
switch (event.getType()) {
case UPDATE:
spatialMatrix.update(event.getSource());
......@@ -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$
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