diff --git a/TULIP/properties.properties b/TULIP/properties.properties
index aedbb6884fbd9771f8f8b0c97732d3f9648ffa55..610fbb6f74d6cc4235f21e62dd8fa9f5d528e2b8 100644
--- a/TULIP/properties.properties
+++ b/TULIP/properties.properties
@@ -1,7 +1,7 @@
# Properties for the Logger
logger.event.output.location = log.txt
logger.event.output.enabled = false
-logger.level = SEVERE
+logger.level = ALL
logger.event.configuration = logger.xml
# Widget IDs to be mapped
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 5a64d7abfaaee3c330994085829ba6a33ff06590..aa03abaf43eff5e2bc2fcc1dd363f48ce199a004 100644
--- a/TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
+++ b/TULIP/src/lu/list/itis/dkd/tui/space/SpatialMatrix.java
@@ -17,9 +17,12 @@
package lu.list.itis.dkd.tui.space;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
+import lu.list.itis.dkd.tui.TangibleObjectManager;
import lu.list.itis.dkd.tui.adapter.TangibleObject;
+import lu.list.itis.dkd.tui.widget.BaseWidget;
import java.util.ArrayList;
+import java.util.List;
/**
* @author Eric Tobias [eric.tobias@list.lu]
@@ -41,7 +44,7 @@ public class SpatialMatrix {
* @param object
* The object to add.
*/
- public void add(TangibleObject object) {
+ public synchronized void add(TangibleObject object) {
horizontal.add(findHorizontalIndexFor(object), object);
vertical.add(findVerticalIndexFor(object), object);
}
@@ -53,7 +56,7 @@ public class SpatialMatrix {
* @param object
* The object to remove.
*/
- public void remove(TangibleObject object) {
+ public synchronized void remove(TangibleObject object) {
horizontal.remove(object);
vertical.remove(object);
}
@@ -81,7 +84,7 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* at the end.
*/
- private int findHorizontalIndexFor(TangibleObject object) {
+ private synchronized int findHorizontalIndexFor(TangibleObject object) {
for (int index = 0; index < horizontal.size(); index++) {
if (Double.compare(object.getPosition().toScreenCoordinates().getX(), horizontal.get(index).getPosition().toScreenCoordinates().getX()) <= 0) {
return index;
@@ -90,6 +93,28 @@ public class SpatialMatrix {
return horizontal.size();
}
+ /**
+ * Method used to find the index of the first horizontal object whose x-axis coordinate is
+ * bigger than this object's. Returns the size of the horizontal list if no such element could
+ * be found.
+ *
+ * @param objectId
+ * The ID of the object to look up the insertion index for.
+ * @return The index to add the element or the size of the list if the element should be added
+ * at the end.
+ */
+ private synchronized int findHorizontalIndexFor(int objectId) {
+ BaseWidget widget = TangibleObjectManager.getWidget(objectId);
+
+ for (int index = 0; index < horizontal.size(); index++) {
+ if (Double.compare(widget.getPosition(objectId).toScreenCoordinates().getX(), horizontal.get(index).getPosition().toScreenCoordinates().getX()) <= 0) {
+ return index;
+ }
+ }
+ return horizontal.size();
+ }
+
+
/**
* Method used to find the index of the first horizontal object whose x-axis coordinate is
* bigger than this object's. Returns the size of the horizontal list if no such element could
@@ -100,7 +125,7 @@ public class SpatialMatrix {
* @return The index to add the element or the size of the list if the element should be added
* at the end.
*/
- private int findVerticalIndexFor(TangibleObject object) {
+ private synchronized int findVerticalIndexFor(TangibleObject object) {
for (int index = 0; index < vertical.size(); index++) {
if (Double.compare(object.getPosition().toScreenCoordinates().getY(), vertical.get(index).getPosition().toScreenCoordinates().getY()) <= 0) {
return index;
@@ -109,14 +134,66 @@ public class SpatialMatrix {
return vertical.size();
}
- public void printLists() {
+ /**
+ * Method used to find the index of the first horizontal object whose x-axis coordinate is
+ * bigger than this object's. Returns the size of the horizontal list if no such element could
+ * be found.
+ *
+ * @param objectId
+ * The ID of the object to look up the insertion index for.
+ * @return The index to add the element or the size of the list if the element should be added
+ * at the end.
+ */
+ private synchronized int findVerticalIndexFor(int objectId) {
+ BaseWidget widget = TangibleObjectManager.getWidget(objectId);
+
+ for (int index = 0; index < vertical.size(); index++) {
+ if (Double.compare(widget.getPosition(objectId).toScreenCoordinates().getY(), vertical.get(index).getPosition().toScreenCoordinates().getY()) <= 0) {
+ return index;
+ }
+ }
+ return vertical.size();
+ }
+
+ /**
+ * Method used to retrieve all {@link TangibleObject} instances to the left of the parameterized
+ * object (by ID). The method will return a new list build from the sublist of the horizontal
+ * space.
+ * 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.
+ *
+ * @param objectId
+ * The object for which to retrieve all objects to the left of.
+ * @return A {@link List} of {@link TangibleObject} instances which are considered to be to the
+ * left of the given object.
+ */
+ public synchronized List leftOf(int objectId) {
+ int index = findHorizontalIndexFor(objectId);
+ return new ArrayList<>(horizontal.subList(index, horizontal.size()));
+ }
+
+ public synchronized List rightOf(int objectId) {
+ int index = findHorizontalIndexFor(objectId);
+ return new ArrayList<>(horizontal.subList(0, index));
+ }
+
+ public synchronized List above(int objectId) {
+ int index = findVerticalIndexFor(objectId);
+ return new ArrayList<>(vertical.subList(0, index));
+ }
+
+ public synchronized List below(int objectId) {
+ int index = findHorizontalIndexFor(objectId);
+ return new ArrayList<>(horizontal.subList(index, vertical.size()));
+ }
+
+ String printLists() {
StringBuilder verticalBuilder = new StringBuilder();
StringBuilder horizontalbuilder = new StringBuilder();
vertical.forEach(object -> verticalBuilder.append(object.getObjectId() + ", ")); //$NON-NLS-1$
horizontal.forEach(object -> horizontalbuilder.append(object.getObjectId() + ", ")); //$NON-NLS-1$
- System.out.println("Vertical : " + verticalBuilder.toString()); //$NON-NLS-1$
- System.out.println("Horizontal : " + horizontalbuilder.toString()); //$NON-NLS-1$
+ return "Vertical : " + verticalBuilder.toString() + "\n" + "Horizontal : " + horizontalbuilder.toString(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
\ No newline at end of file
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 323ecea8feeb5ddf1fcf537ea9ab73744b03de55..dcb50451fba652796734f4835769bdb133975bdd 100644
--- a/TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java
+++ b/TULIP/src/lu/list/itis/dkd/tui/space/SpatialPositioningManager.java
@@ -107,6 +107,6 @@ public class SpatialPositioningManager implements SpatialEventListener {
logger.log(Level.SEVERE, "Spatial event type \"" + event.getType() + "\" not recognized!"); //$NON-NLS-1$ //$NON-NLS-2$
break;
}
- spatialMatrix.printLists();
+ System.out.println(spatialMatrix.printLists());
}
}
\ No newline at end of file
diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeCorona.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeCorona.java
new file mode 100644
index 0000000000000000000000000000000000000000..d9c46e205da4e164e292fb670391dde27773ba07
--- /dev/null
+++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeCorona.java
@@ -0,0 +1,77 @@
+/**
+ * Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
+ *
+ * This file is part of TULIP.
+ *
+ * TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
+ * Lesser General Public License as published by the Free Software Foundation, version 3 of the
+ * License.
+ *
+ * TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with TULIP. If
+ * not, see .
+ */
+package lu.list.itis.dkd.tui.widget.corona;
+
+import lu.list.itis.dkd.tui.utility.Point;
+import lu.list.itis.dkd.tui.widget.corona.builder.BaseShapeCoronaBuilder;
+
+import java.awt.BasicStroke;
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Stroke;
+import java.awt.geom.AffineTransform;
+
+/**
+ * @author Eric Tobias [eric.tobias@list.lu]
+ * @since 2.1
+ * @version 2.1.2
+ */
+public class ShapeCorona extends Corona {
+
+ private Color colour = Color.GRAY;
+ private int borderWidth = 20;
+
+ /**
+ * Constructor building all fields and calling the implicit super constructor using a
+ * {@link BaseShapeCoronaBuilder} instance holding all values.
+ *
+ * @param builder
+ * The {@link BaseShapeCoronaBuilder} instance holding all values.
+ */
+ public ShapeCorona(BaseShapeCoronaBuilder> builder) {
+ super(builder);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void paint(Graphics2D canvas) {
+ if (!active) {
+ return;
+ }
+
+ centre.toScreenCoordinates();
+ if (initialTranslation != null) {
+ initialTranslation.toScreenCoordinates();
+ }
+
+ Point drawAt = centre.add(initialTranslation);
+
+ AffineTransform transformation = new AffineTransform();
+ transformation.translate(drawAt.getX(), drawAt.getY());
+ if (rotateWithHandle) {
+ transformation.rotate(drawAt.getAngle());
+ }
+
+ Stroke oldStroke = canvas.getStroke();
+ canvas.setStroke(new BasicStroke(borderWidth));
+ canvas.draw(shape);
+ canvas.setStroke(oldStroke);
+
+ canvas.setPaint(colour);
+ canvas.fill(transformation.createTransformedShape(shape));
+ }
+}
\ No newline at end of file
diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShapeCoronaBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShapeCoronaBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..f7c1824a735b65211599bc8f1646715a70b73043
--- /dev/null
+++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShapeCoronaBuilder.java
@@ -0,0 +1,79 @@
+/**
+ * Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
+ *
+ * This file is part of TULIP.
+ *
+ * TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
+ * Lesser General Public License as published by the Free Software Foundation, version 3 of the
+ * License.
+ *
+ * TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with TULIP. If
+ * not, see .
+ */
+package lu.list.itis.dkd.tui.widget.corona.builder;
+
+import lu.list.itis.dkd.tui.utility.Point;
+import lu.list.itis.dkd.tui.widget.corona.Corona;
+import lu.list.itis.dkd.tui.widget.corona.ShapeCorona;
+
+import java.awt.Color;
+
+/**
+ * {@link CoronaBuilder} extension building {@link ShapeCorona} coronas.
+ *
+ * @author Eric Tobias [eric.tobias@list.lu]
+ * @since 2.1
+ * @version 2.1.2
+ * @param
+ * The concrete builder.
+ */
+public abstract class BaseShapeCoronaBuilder> extends CoronaBuilder {
+ public Color colour = Color.GRAY;
+ public int borderWidth = 20;
+
+ /**
+ * Constructor setting the centre of the corona.
+ *
+ * @param centre
+ * The centre of the corona, usually the centre of the handle.
+ */
+ protected BaseShapeCoronaBuilder(Point centre) {
+ super(centre);
+ }
+
+
+ /**
+ * Method for setting the colour of the shape drawn for this {@link Corona}.
+ *
+ * @param color
+ * The colour the shape should be filled with.
+ * @return An instance of this builder for chain calling.
+ */
+ @SuppressWarnings("unchecked")
+ public B withColor(Color color) {
+ this.colour = color;
+ return (B) this;
+ }
+
+ /**
+ * Method for setting the width of the border to draw around the shape.
+ *
+ * @param width
+ * The width of the line to draw the border with.
+ * @return An instance of this builder for chain calling.
+ */
+ @SuppressWarnings("unchecked")
+ public B withBorderWidth(int width) {
+ this.borderWidth = width;
+ return (B) this;
+
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public abstract ShapeCorona build();
+}
\ No newline at end of file
diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShapeCoronaBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShapeCoronaBuilder.java
new file mode 100644
index 0000000000000000000000000000000000000000..c7a647a41da329af9aa0477957985f94c9804995
--- /dev/null
+++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShapeCoronaBuilder.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright Luxembourg Institute of Science and Technology, 2015. All rights reserved.
+ *
+ * This file is part of TULIP.
+ *
+ * TULIP is free software: you can redistribute it and/or modify it under the terms of the GNU
+ * Lesser General Public License as published by the Free Software Foundation, version 3 of the
+ * License.
+ *
+ * TULIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+ * the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License along with TULIP. If
+ * not, see .
+ */
+package lu.list.itis.dkd.tui.widget.corona.builder;
+
+import lu.list.itis.dkd.tui.utility.Point;
+import lu.list.itis.dkd.tui.widget.corona.ShapeCorona;
+
+/**
+ * {@link ShapeCoronaBuilder} class used to construct a {@link ShapeCorona} corona by providing
+ * methods to set all parameters and permutations thereof.
+ *
+ * @author Eric Tobias [eric.tobias@list.lu]
+ * @since 2.1
+ * @version 2.1.2
+ */
+public class ShapeCoronaBuilder extends BaseShapeCoronaBuilder {
+
+ /**
+ * Constructor setting the centre of the corona.
+ *
+ * @param centre
+ * The centre of the corona, usually the centre of the handle.
+ */
+ protected ShapeCoronaBuilder(Point centre) {
+ super(centre);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public ShapeCorona build() {
+ return new ShapeCorona(this);
+ }
+}
\ No newline at end of file