From 83bf257b4058bbc6a56e10490892273fd11a30ca Mon Sep 17 00:00:00 2001 From: Eric Tobias Date: Tue, 29 Dec 2015 15:02:54 +0100 Subject: [PATCH] Bootstrapping and library updates. This commit constitutes the first nightly bootstrapping build. As of now, bootstrapping supports most coronas but no InformationProvides. Only the BaseWidget is supported at the moment. + String Externalization for to make changes regarding the boostrapping XML maintainable. + Updated some libraries such as Guava and JDOM2 (see Changelog) + Added constructors to most base builders of the coronas and the base widget to work with a provided JDOM2 Element node. + Added bootstrapping classes with static methods to provide support to bootstrap other major classes such as concrete NetworkArapter implementations. --- CHANGELOG.txt | 14 ++ README.txt | 6 +- TULIP/config/bootstrapping.xml | 45 +++++ TULIP/config/messages.properties | 34 ++++ TULIP/config/test_bootstrapping.xml | 47 +++++ TULIP/pom.xml | 12 +- .../dkd/tui/TangibleInterfaceManager.java | 5 +- .../itis/dkd/tui/TangibleObjectManager.java | 71 ++++--- .../tui/bootstrapping/CoronaBootstrapper.java | 101 ++++++++++ .../itis/dkd/tui/bootstrapping/Messages.java | 72 +++++++ .../NetworkAdapterBootstrapper.java | 117 +++++++++++ .../tui/bootstrapping/ShapeBootstrapper.java | 80 ++++++++ .../TangibleObjectBootstrapper.java | 188 ++++++++++++++++++ .../dkd/tui/exception/BuildException.java | 16 +- .../tui/network/adapter/BluetoothClient.java | 6 +- .../dkd/tui/network/adapter/XbeeAdapter.java | 2 +- .../lu/list/itis/dkd/tui/utility/Point.java | 50 ++++- .../list/itis/dkd/tui/widget/BaseWidget.java | 22 +- .../dkd/tui/widget/builder/BaseBuilder.java | 43 +++- .../tui/widget/builder/BaseWidgetBuilder.java | 30 ++- .../itis/dkd/tui/widget/corona/Corona.java | 63 ++---- .../itis/dkd/tui/widget/corona/Image.java | 12 +- .../dkd/tui/widget/corona/ShapeFactory.java | 17 +- .../corona/builder/BaseImageBuilder.java | 50 ++++- .../corona/builder/BaseInfoBoxBuilder.java | 57 +++++- .../corona/builder/BasePointerBuilder.java | 31 ++- .../corona/builder/BaseRadiusBuilder.java | 89 ++++++++- .../corona/builder/BaseShadowBuilder.java | 27 ++- .../builder/BaseShapeCoronaBuilder.java | 43 +++- .../corona/builder/BaseTextBoxBuilder.java | 78 +++++++- .../corona/builder/BaseWedgeBuilder.java | 80 +++++++- .../widget/corona/builder/CoronaBuilder.java | 122 ++++++------ .../widget/corona/builder/ImageBuilder.java | 28 ++- .../widget/corona/builder/InfoBoxBuilder.java | 27 ++- .../widget/corona/builder/PointerBuilder.java | 26 ++- .../widget/corona/builder/RadiusBuilder.java | 27 ++- .../widget/corona/builder/ShadowBuilder.java | 22 +- .../corona/builder/ShapeCoronaBuilder.java | 21 +- .../widget/corona/builder/TextBoxBuilder.java | 28 ++- .../widget/corona/builder/WedgeBuilder.java | 28 ++- .../TangibleObjectBootstrapperTest.java | 79 ++++++++ .../tui/event/PositionChangeListenerTest.java | 10 +- .../itis/dkd/tui/space/SpatialMatrixTest.java | 10 +- .../tui/utility/CameraCoordinatesTest.java | 8 +- .../list/itis/dkd/tui/utility/PointTest.java | 10 +- .../tui/utility/ScreenCoordinatesTest.java | 8 +- .../dkd/tui/utility/TableCoordinatesTest.java | 8 +- .../tui/widget/state/FunctionStateTest.java | 12 +- .../dkd/tui/widget/state/LimboStateTest.java | 14 +- .../tui/widget/state/MovementStateTest.java | 36 ++-- .../tui/widget/state/RotationStateTest.java | 36 ++-- .../tui/widget/state/StateManagerTest.java | 6 +- .../dkd/tui/widget/state/StillStateTest.java | 36 ++-- 53 files changed, 1753 insertions(+), 357 deletions(-) create mode 100644 TULIP/config/bootstrapping.xml create mode 100644 TULIP/config/messages.properties create mode 100644 TULIP/config/test_bootstrapping.xml create mode 100644 TULIP/src/lu/list/itis/dkd/tui/bootstrapping/CoronaBootstrapper.java create mode 100644 TULIP/src/lu/list/itis/dkd/tui/bootstrapping/Messages.java create mode 100644 TULIP/src/lu/list/itis/dkd/tui/bootstrapping/NetworkAdapterBootstrapper.java create mode 100644 TULIP/src/lu/list/itis/dkd/tui/bootstrapping/ShapeBootstrapper.java create mode 100644 TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java create mode 100644 TULIP/test/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapperTest.java diff --git a/CHANGELOG.txt b/CHANGELOG.txt index ed58f73..5d43961 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,17 @@ +2.2.0 + +Implementation of XML based bootstrapping for widgets and coronas. + ++ Moved to Guava 19 ++ Moved to JDOM2 2.0.6 ++ Added org.eclipse.osgi in version 3.7.1 to manage string internationalization (licensed as EPL 1) + ++ Image and its related builders, notably those for the image-based corona, no longer throw a BuildException. This was already the case but the signature still contained the exception being thrown. ++ Removed the field method to set "alwaysActive" for coronas from the CoronaBuilder. The concept was removed as it is thought that coronas should not be always active. ++ Removed field and methods for corona persistence from Corona and the CoronaBuilder. No scenario exists that accounts for persistence and the related methods when drawing were not supported either. ++ Removed the field "background" and all related methods from Corona. Adjusted Image accordingly. The field was not used. Conceptually, coronas should never be part of the background. + + 2.1.4 + Added test method for various classes. diff --git a/README.txt b/README.txt index 7de0579..b6d179b 100644 --- a/README.txt +++ b/README.txt @@ -10,13 +10,15 @@ History TULIP was designed and implemented in an iterative process as of 2014. The bulk of the framework has been developed by @etobias with the help of and under the watchful eyes of @vmaquil who heads the research activities in the Natural User Interfaces domain. From January to June 2014 the framework saw the first major developments with some complementary implementation and bug fixing activity done during the Summer and Fall of 2014. In Fall 2014, @yrangoni added the first traces of a lightweight logging library. In January 2015 the project was migrated to Git, using GitLab as a platform. + Current development -We currently develop an adapter for the computer vision framework and are in the stages of testing it. Similarly, we are developing adapters to address networked devices. +We are currently developping a boostrapping mechanism that will allow to instantiate widgets and their coronas from an XML file. This development is part of the Re-Engage project. + Libraries and Licenses As of now, the provided sources are still in development. -Currently the project depends on an in-house annotation library that is distributed with this project as well as Guava (licensed under Apache 2.0), JDOM (licensed under an Apache-style open source license), and the TUIO Java client (licensed as LGPL). +Currently the project depends on an in-house annotation library that is distributed with this project as well as Guava (licensed under Apache 2.0), JDOM2 (licensed under an Apache-style open source license), and the TUIO Java client (licensed as LGPL). The project uses the Eclipse OSGI Utility library (licensed as EPL1) for string externalization. The network adapters are using BlueCove (licensed under Apache 2.0) for Bluetooth communication and RXTX (licensed as LGPL) for Xbee communication. \ No newline at end of file diff --git a/TULIP/config/bootstrapping.xml b/TULIP/config/bootstrapping.xml new file mode 100644 index 0000000..839b640 --- /dev/null +++ b/TULIP/config/bootstrapping.xml @@ -0,0 +1,45 @@ + + + + + BaseWidget + + + Shadow + + 0 + 0 + 0 + + + + Marty + Circle + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TULIP/config/messages.properties b/TULIP/config/messages.properties new file mode 100644 index 0000000..c6493b2 --- /dev/null +++ b/TULIP/config/messages.properties @@ -0,0 +1,34 @@ +ALPHA=alpha +BACKGROUND_COLOUR=backgroundColour +BORDER_THICKNESS=borderThickness +BORDER_WIDTH=borderWidth +CENTRE_NODE=centre +CENTRED=centred +COLOUR=colour +CORONAS_NODE=coronas +DEFINING_SHAPE_NODE=definingShape +DRAW_BORDER=drawBorder +DRAW_PRIORITY_NODE=drawPriority +EDGE_COLOUR=edgeColour +FILL_COLOUR=fillColour +FONT=font +FONT_SIZE=fontSize +HANDLE_NODE=handle +HANDLES_NODE=handles +IMAGE=image +INFORMATION=information +INITIAL_ROTATION_NODE=initialRotation +INITIAL_TRANSLATION_NODE=initialTranslation +JAVA_AWT_COLOR_NAMESPACE=java.awt.Color +LENGTH=length +LINE=line +LINE_HEIGHT_RATIO=lineHeightRatio +LINE_WIDTH=lineWidth +NAME_NODE=name +NETWORK_ADAPTER_NODE=networkAdapter +RADIUS=radius +ROTATE_WITH_HANDLE_NODE=rotateWithHandle +SHAPE_NODE=shape +SPIN_ON_CORONA_CENTRE_NODE=spinOnCoronaCentre +START=start +TEXT=text diff --git a/TULIP/config/test_bootstrapping.xml b/TULIP/config/test_bootstrapping.xml new file mode 100644 index 0000000..d0ad79b --- /dev/null +++ b/TULIP/config/test_bootstrapping.xml @@ -0,0 +1,47 @@ + + + + + BaseWidget + + 1 + + + + Shadow + 1 + + 0 + 0 + 0 + + + + Marty + Circle + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TULIP/pom.xml b/TULIP/pom.xml index e3bded0..aa469b8 100644 --- a/TULIP/pom.xml +++ b/TULIP/pom.xml @@ -2,7 +2,7 @@ 4.0.0 lu.list.itis.dkd.tui tulip - 2.0.41 + 2.2.0 TULIP A framework for tabletop tangible user interface applications. @@ -23,12 +23,12 @@ org.jdom jdom2 - 2.0.5 + 2.0.6 com.google.guava guava - 15.0 + 19.0 net.sf.bluecove @@ -40,7 +40,6 @@ rxtx 2.1.7 - net.sourceforge.tuio tuio @@ -51,5 +50,10 @@ dbc-annotation 1.1 + + org.eclipse.osgi + org.eclipse.osgi + 3.7.1 + \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/TangibleInterfaceManager.java b/TULIP/src/lu/list/itis/dkd/tui/TangibleInterfaceManager.java index 9bb1d49..1bd2f81 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/TangibleInterfaceManager.java +++ b/TULIP/src/lu/list/itis/dkd/tui/TangibleInterfaceManager.java @@ -47,7 +47,7 @@ import javax.swing.JFrame; * Class managing the setup of the window displaying all top-level TUI related visualisation as well * as any configuration behaviour. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 * @version 1.0.2 */ @@ -113,8 +113,9 @@ public class TangibleInterfaceManager extends JComponent { title = interfaceProperties.getProperty("frameTitle", "TangibleApplication"); //$NON-NLS-1$ //$NON-NLS-2$ String calibration = interfaceProperties.getProperty("calibrationFileURI"); //$NON-NLS-1$ - if (calibration != null) + if (calibration != null) { calibrationFileURI = calibration; + } device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice(); Calibration.loadFromFile(calibrationFileURI); diff --git a/TULIP/src/lu/list/itis/dkd/tui/TangibleObjectManager.java b/TULIP/src/lu/list/itis/dkd/tui/TangibleObjectManager.java index 782a822..f7f09ef 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/TangibleObjectManager.java +++ b/TULIP/src/lu/list/itis/dkd/tui/TangibleObjectManager.java @@ -42,23 +42,23 @@ import java.util.logging.Logger; * like. The class also holds the collection of tangibles managed by the application. The class uses * locks to synchronise all calls to manage objects. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @author Nicolas Gilmard * @since 1.0 - * @version 2.0.2 + * @version 2.2.0 */ @NonNullByDefault public abstract class TangibleObjectManager { /** * This dictionary stores all tangibles detected by reacTIVision relevant to the application. */ - protected volatile static ConcurrentHashMap objectList = new ConcurrentHashMap<>(); + protected volatile static ConcurrentHashMap objectMap = new ConcurrentHashMap<>(); /** This dictionary stores all cursors detected by reacTIVision. */ - protected volatile static ConcurrentHashMap cursorList = new ConcurrentHashMap<>(); + protected volatile static ConcurrentHashMap cursorMap = new ConcurrentHashMap<>(); /** This dictionary stores all blobs detected by reacTIVision. */ - protected volatile static ConcurrentHashMap blobList = new ConcurrentHashMap<>(); + protected volatile static ConcurrentHashMap blobMap = new ConcurrentHashMap<>(); /** A {@link Logger} to log all messages during execution. */ protected Logger logger; @@ -95,15 +95,14 @@ public abstract class TangibleObjectManager { * When adding Widgets to map to cursors, refer to {@link IdMapper#remapCursorId(int)}. Cursor * IDs are remapped as not to clash with any symbol ID assigned by reacTIVision. A good practice * is to reason with regular cursor IDs and add them to the map by calling for example: - * objectList.put(remapCursorID(0), W extends BaseWidget); to the first cursor that + * objectMap.put(remapCursorID(0), W extends BaseWidget); to the first cursor that * is placed to the widget in the put statement.
*
* * To dynamically allocate widgets to cursors, the addTuioCursor() method should be * overridden or reimplimented to dynamically instantiate the desired widget and add it to the * dictionary of objects. This would require manual removal of the dynamically created widget in - * the - * removeTuioCursor() method. + * the removeTuioCursor() method. * * @throws BuildException * Exception raised when the building on a widget or corona instance cannot complete @@ -119,7 +118,7 @@ public abstract class TangibleObjectManager { private void ensureConsistency() { Vector objectBlackList = new Vector<>(); for (TangibleObject object : tangibleApplication.getActiveObjects()) { - if (!objectList.keySet().contains(object.getObjectId())) { + if (!objectMap.keySet().contains(object.getObjectId())) { objectBlackList.add(object); } } @@ -130,7 +129,7 @@ public abstract class TangibleObjectManager { Vector cursorBlackList = new Vector<>(); for (TangibleObject cursor : tangibleApplication.getActiveCursors()) { - if (!cursorList.keySet().contains(cursor.getObjectId())) { + if (!cursorMap.keySet().contains(cursor.getObjectId())) { cursorBlackList.add(cursor); } } @@ -148,9 +147,9 @@ public abstract class TangibleObjectManager { */ public static synchronized Collection getWidgets() { Collection widgets = new ArrayList<>(); - widgets.addAll(objectList.values()); - widgets.addAll(cursorList.values()); - widgets.addAll(blobList.values()); + widgets.addAll(objectMap.values()); + widgets.addAll(cursorMap.values()); + widgets.addAll(blobMap.values()); return widgets; } @@ -164,14 +163,14 @@ public abstract class TangibleObjectManager { * identifier. */ public static synchronized @Nullable BaseWidget getWidget(int identifier) { - if (null != objectList.get(identifier)) { - return objectList.get(identifier); + if (null != objectMap.get(identifier)) { + return objectMap.get(identifier); } - if (null != cursorList.get(identifier)) { - return cursorList.get(identifier); + if (null != cursorMap.get(identifier)) { + return cursorMap.get(identifier); } - return blobList.get(identifier); + return blobMap.get(identifier); } /** @@ -197,15 +196,15 @@ public abstract class TangibleObjectManager { switch (tangibleObject.getType()) { case CURSOR: - cursorList.putIfAbsent(tangibleObject.getObjectId(), new BaseWidgetBuilder().withCorona(tangibleObject.getObjectId(), new ShadowBuilder(new Point()).withShape(ShapeFactory.buildCircle(5)).build()).build()); + cursorMap.putIfAbsent(tangibleObject.getObjectId(), new BaseWidgetBuilder().withCorona(tangibleObject.getObjectId(), new ShadowBuilder(new Point()).withShape(ShapeFactory.buildCircle(5)).build()).build()); - cursorList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); + cursorMap.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); ensureConsistency(); break; case OBJECT: - if (objectList.containsKey(tangibleObject.getObjectId())) { - objectList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); + if (objectMap.containsKey(tangibleObject.getObjectId())) { + objectMap.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); } else { logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ } @@ -214,9 +213,9 @@ public abstract class TangibleObjectManager { case BLOB: // TODO This line add a small shadow with each blob. This behaviour might not be // desired but needs to be investigated. Opening issue #27. - blobList.putIfAbsent(tangibleObject.getObjectId(), new BaseWidgetBuilder().withCorona(tangibleObject.getObjectId(), new ShadowBuilder(new Point()).withShape(ShapeFactory.buildCircle(5)).build()).build()); + blobMap.putIfAbsent(tangibleObject.getObjectId(), new BaseWidgetBuilder().withCorona(tangibleObject.getObjectId(), new ShadowBuilder(new Point()).withShape(ShapeFactory.buildCircle(5)).build()).build()); - blobList.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); + blobMap.get(tangibleObject.getObjectId()).actionDrop(tangibleObject); break; default: logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ @@ -236,22 +235,22 @@ public abstract class TangibleObjectManager { switch (tangibleObject.getType()) { case CURSOR: - if (cursorList.containsKey(tangibleObject.getObjectId())) { - cursorList.remove(tangibleObject.getObjectId()).actionLift(tangibleObject); + if (cursorMap.containsKey(tangibleObject.getObjectId())) { + cursorMap.remove(tangibleObject.getObjectId()).actionLift(tangibleObject); } break; case OBJECT: - if (objectList.containsKey(tangibleObject.getObjectId())) { - objectList.get(tangibleObject.getObjectId()).actionLift(tangibleObject); + if (objectMap.containsKey(tangibleObject.getObjectId())) { + objectMap.get(tangibleObject.getObjectId()).actionLift(tangibleObject); } else { logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ } break; case BLOB: - if (blobList.containsKey(tangibleObject.getObjectId())) { - blobList.remove(tangibleObject.getObjectId()).actionLift(tangibleObject); + if (blobMap.containsKey(tangibleObject.getObjectId())) { + blobMap.remove(tangibleObject.getObjectId()).actionLift(tangibleObject); } break; default: @@ -272,22 +271,22 @@ public abstract class TangibleObjectManager { switch (tangibleObject.getType()) { case CURSOR: - if (cursorList.containsKey(tangibleObject.getObjectId())) { - cursorList.get(tangibleObject.getObjectId()).actionMove(tangibleObject); + if (cursorMap.containsKey(tangibleObject.getObjectId())) { + cursorMap.get(tangibleObject.getObjectId()).actionMove(tangibleObject); } else { logger.log(Level.WARNING, "The cursor could not be recognised!"); //$NON-NLS-1$ } break; case OBJECT: - if (objectList.containsKey(tangibleObject.getObjectId())) { - objectList.get(tangibleObject.getObjectId()).actionMove(tangibleObject); + if (objectMap.containsKey(tangibleObject.getObjectId())) { + objectMap.get(tangibleObject.getObjectId()).actionMove(tangibleObject); } else { logger.log(Level.WARNING, "The recognised symbol was not assigned to a widget!"); //$NON-NLS-1$ } break; case BLOB: - if (blobList.containsKey(tangibleObject.getObjectId())) { - blobList.get(tangibleObject.getObjectId()).actionMove(tangibleObject); + if (blobMap.containsKey(tangibleObject.getObjectId())) { + blobMap.get(tangibleObject.getObjectId()).actionMove(tangibleObject); } else { logger.log(Level.WARNING, "The blob could not be recognised!"); //$NON-NLS-1$ } diff --git a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/CoronaBootstrapper.java b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/CoronaBootstrapper.java new file mode 100644 index 0000000..1864ccb --- /dev/null +++ b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/CoronaBootstrapper.java @@ -0,0 +1,101 @@ +/** + * 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.bootstrapping; + +import lu.list.itis.dkd.tui.exception.BuildException; +import lu.list.itis.dkd.tui.widget.corona.Corona; +import lu.list.itis.dkd.tui.widget.corona.builder.CoronaBuilder; + +import com.google.common.collect.Multimap; +import com.google.common.collect.TreeMultimap; + +import org.jdom2.Element; + +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; + +/** + * @author Eric Tobias [eric.tobias@list.lu] + * @since 2.2 + * @version 2.2.0 + */ +public class CoronaBootstrapper { + + private static final String CORONA_BUILDER_NAMESPACE = "lu.list.itis.dkd.tui.widget.corona.builder."; //$NON-NLS-1$ + + /** + * Method used to determine the appropriate builder for a given corona and then issue a build + * call. + * + * @param coronaNode + * The node from a larger document that contains, as children, all the necessary + * information to resolve the correct builder and build the final, concrete, corona. + * @return The final concrete corona as defined by the children of the element node. + * @throws ClassNotFoundException + * Thrown when the class of the builder for the corona could not be found. + * @throws SecurityException + * Thrown when the constructor cannot be retrieved due to some security constraints. + * @throws NoSuchMethodException + * Thrown when no constructor with the given parameter type is available. + * @throws InvocationTargetException + * Thrown if the invocation of any constructor through reflection throws an exception. + * @throws IllegalArgumentException + * Thrown when the provided argument is not eligible for the builder's constructor. + * @throws IllegalAccessException + * Thrown if this Constructor object is enforcing Java language access control and the + * underlying constructor is inaccessible. + * @throws InstantiationException + * Thrown if the class that declares the underlying constructor represents an abstract + * class. + */ + private static Corona getCorona(Element coronaNode) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException { + Element type = coronaNode.getChild("type"); //$NON-NLS-1$ + Class builder = Class.forName(CORONA_BUILDER_NAMESPACE + type.getValue() + "Builder"); //$NON-NLS-1$ + + @SuppressWarnings("unchecked") + Constructor> constructor = (Constructor>) builder.getConstructor(new Class[] {Element.class}); + return constructor.newInstance(new Object[] {coronaNode}).build(); + } + + /** + * Method used for bootstrapping all coronas found as child nodes of a root node. The method + * will look for child nodes names corona. + * + * @param coronaRootNode + * The root node that holds all corona child nodes. + * @return A map containing all concrete {@link Corona} instances that could be build from the + * provided root node keyed to the handle ID to which they are associated. * + * @throws BuildException + * Thrown when a corona was not associated to any handle. + */ + public static Multimap getCoronas(Element coronaRootNode) throws BuildException { + Multimap coronas = TreeMultimap.create(); + + for (Element coronaNode : coronaRootNode.getChildren("corona")) { //$NON-NLS-1$ + try { + int handleId = Integer.parseInt(coronaNode.getChildText("handle")); //$NON-NLS-1$ + coronas.put(handleId, getCorona(coronaNode)); + } catch (NumberFormatException nfe) { + throw new BuildException("The corona was not associated with any handle. The handle ID may not be null!", nfe); //$NON-NLS-1$ + } catch (ReflectiveOperationException roe) { + throw new BuildException("One or more operations failed while issuing a reflective call!", roe); //$NON-NLS-1$ + } + } + + return coronas; + } +} \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/Messages.java b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/Messages.java new file mode 100644 index 0000000..3a1daf0 --- /dev/null +++ b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/Messages.java @@ -0,0 +1,72 @@ +/** + * 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.bootstrapping; + +import org.eclipse.osgi.util.NLS; + +/** + * Auto-generated class for string externalization to be used to bundle all node names. + * + * @author Eric Tobias [eric.tobias@list.lu] + * @since 2.2 + * @version 2.2.0 + */ +@SuppressWarnings("javadoc") +public class Messages extends NLS { + private static final String BUNDLE_NAME = "messages"; //$NON-NLS-1$ + public static String ALPHA; + public static String BACKGROUND_COLOUR; + public static String BORDER_THICKNESS; + public static String BORDER_WIDTH; + public static String CENTRE_NODE; + public static String CENTRED; + public static String COLOUR; + public static String CORONAS_NODE; + public static String DEFINING_SHAPE_NODE; + public static String DRAW_BORDER; + public static String DRAW_PRIORITY_NODE; + public static String EDGE_COLOUR; + public static String FILL_COLOUR; + public static String FONT; + public static String FONT_SIZE; + public static String HANDLE_NODE; + public static String HANDLES_NODE; + public static String IMAGE; + public static String INFORMATION; + public static String INITIAL_ROTATION_NODE; + public static String INITIAL_TRANSLATION_NODE; + public static String JAVA_AWT_COLOR_NAMESPACE; + public static String LENGTH; + public static String LINE; + public static String LINE_HEIGHT_RATIO; + public static String LINE_WIDTH; + public static String NAME_NODE; + public static String NETWORK_ADAPTER_NODE; + public static String RADIUS; + public static String ROTATE_WITH_HANDLE_NODE; + public static String SHAPE_NODE; + public static String SPIN_ON_CORONA_CENTRE_NODE; + public static String START; + public static String TEXT; + + static { + // initialize resource bundle + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + + private Messages() {} +} \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/NetworkAdapterBootstrapper.java b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/NetworkAdapterBootstrapper.java new file mode 100644 index 0000000..2b40a59 --- /dev/null +++ b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/NetworkAdapterBootstrapper.java @@ -0,0 +1,117 @@ +/** + * 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.bootstrapping; + +import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.exception.BuildException; +import lu.list.itis.dkd.tui.network.adapter.BluetoothClient; +import lu.list.itis.dkd.tui.network.adapter.BluetoothServer; +import lu.list.itis.dkd.tui.network.adapter.NetworkAdapter; +import lu.list.itis.dkd.tui.network.adapter.TcpClient; +import lu.list.itis.dkd.tui.network.adapter.TcpServer; +import lu.list.itis.dkd.tui.network.adapter.XbeeAdapter; + +import com.google.common.base.Strings; + +import org.jdom2.Element; + +import java.io.IOException; + +/** + * Simple bootstrapper for the network adapter. + * + * @author Eric Tobias [eric.tobias@list.lu] + * @since 2.2 + * @version 2.2.0 + */ +@NonNullByDefault +public class NetworkAdapterBootstrapper { + + /** + * /** Method used to build a {@link NetworkAdapter} instance given an archetype. The method + * will delegate the construction of the adapter to the adapter class' constructor, checking + * that preconditions on available parameters are met by the XML. + * + * @param networkAdapterNode + * Element that may contain, as child nodes, the parameters required to successfully + * bootstrap the required network adapter. The node required a child node named "type" + * that holds the exact type of adapter to be initialized. For example: {@link TcpServer} + * or {@link BluetoothClient}. Supported adapters are concrete sub-classes of + * {@link NetworkAdapter}. + * @return A {@link NetworkAdapter} as specified by the archetype with its fields set by the + * information found in the XML. Will return null should parameter be null. + * @throws BuildException + * Thrown when no archetype could be associated with the provided archetype parameter or + * if one or more of the preconditions on required parameters are not met. + */ + public static @Nullable NetworkAdapter getNetworkAdapter(@Nullable Element networkAdapterNode) throws BuildException { + if (null == networkAdapterNode || Strings.isNullOrEmpty(networkAdapterNode.getText())) { + return null; + } + + String archetype = networkAdapterNode.getChildText("type"); //$NON-NLS-1$ + if (Strings.isNullOrEmpty(archetype)) { + throw new BuildException("The \"type\" node must bot be null or empty. It must conform to one of the supported network adapters. Please consult TULIP's documentation for a list of supported network adapters!"); //$NON-NLS-1$ + } + + switch (archetype.toLowerCase()) { + case "bluetoothclient": //$NON-NLS-1$ + try { + return new BluetoothClient(networkAdapterNode.getChildText("serviceUuid")); //$NON-NLS-1$ + } catch (NullPointerException | IllegalArgumentException e) { + throw new BuildException("The network adapter failed to be initialized. The adapter requires a non-null and well-formed UUID held by a node named \"serviceUuid\"!", e); //$NON-NLS-1$ + } + case "tcpclient": //$NON-NLS-1$ + try { + int port = Integer.parseInt(networkAdapterNode.getChildText("port")); //$NON-NLS-1$ + return new TcpClient(networkAdapterNode.getChildText("host"), port); //$NON-NLS-1$ + } catch (NumberFormatException | IllegalStateException e) { + throw new BuildException("The network adapter failed to be initialized. The adapter requires non-null nodes named \"port\" greater than 0 and smaller or equal to 65535!", e); //$NON-NLS-1$ + } + case "xbeeadapter": //$NON-NLS-1$ + try { + String port = networkAdapterNode.getChildText("port"); //$NON-NLS-1$ + int baudRate = Integer.parseInt(networkAdapterNode.getChildText("baudRate")); //$NON-NLS-1$ + return new XbeeAdapter(port, baudRate); + } catch (NumberFormatException nfe) { + throw new BuildException("The network adapter failed to be initialized. The adapter requires non-null nodes named \"port\" and \"baudRate\"!", nfe); //$NON-NLS-1$ + } catch (IllegalStateException ise) { + throw new BuildException("The baudRate must be either 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 or 230400!", ise); //$NON-NLS-1$ + } + case "bluetoothserver": //$NON-NLS-1$ + try { + return new BluetoothServer(networkAdapterNode.getChildText("serviceUuid")); //$NON-NLS-1$ + } catch (NullPointerException | IllegalArgumentException e) { + throw new BuildException("The network adapter failed to be initialized. The adapter requires a non-null and well-formed UUID held by a node named \"serviceUuid\"!", e); //$NON-NLS-1$ + } catch (IOException ioe) { + throw new BuildException("The adapter could not be set to being discoverable or it failed to open a connection!", ioe); //$NON-NLS-1$ + } + case "tcpserver": //$NON-NLS-1$ + try { + int port = Integer.parseInt(networkAdapterNode.getChildText("port")); //$NON-NLS-1$ + return new TcpServer(port); + } catch (NumberFormatException | IllegalStateException e) { + throw new BuildException("The network adapter failed to be initialized. The adapter requires non-null nodes named \"port\" greater than 0 and smaller or equal to 65535!", e); //$NON-NLS-1$ + } catch (IOException ioe) { + throw new BuildException("The socket underlying the TCP server failed to initialize!", ioe); //$NON-NLS-1$ + } + default: + throw new BuildException("No network adapter could be initiated for the provided shape archetype: " + archetype); //$NON-NLS-1$ + } + } +} \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/ShapeBootstrapper.java b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/ShapeBootstrapper.java new file mode 100644 index 0000000..d9743c4 --- /dev/null +++ b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/ShapeBootstrapper.java @@ -0,0 +1,80 @@ +/** + * 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.bootstrapping; + +import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.exception.BuildException; +import lu.list.itis.dkd.tui.widget.corona.ShapeFactory; + +import com.google.common.base.Strings; + +import java.awt.Shape; + +/** + * Simple bootstrapper to initialize shapes. + * + * @author Eric Tobias [eric.tobias@list.lu] + * @since 2.2 + * @version 2.2.0 + */ +@NonNullByDefault +public class ShapeBootstrapper { + + /** + * Method used to build a {@link Shape} instance given an archetype. The method will delegate + * the construction of the shape to the given public static non-arg build method found in the + * {@link ShapeFactory}. + * + * @param archetype + * The archetype of the shape to build. Supported are:
+ *
    + *
  • Circle
  • + *
  • Rectangle
  • + *
  • RoundedSquare
  • + *
  • Square
  • + *
  • Triangle
  • + *
+ * @return A shape as specified by the archetype with dimensions as set by the calibration file. + * Will return null should the archetype by Empty or null. + * @throws BuildException + * Thrown when no archetype could be associated with the provided parameter. + */ + public static @Nullable Shape getShape(@Nullable String archetype) throws BuildException { + if (Strings.isNullOrEmpty(archetype)) { + return null; + } + + // TODO The code is currently lacking the ability to add sizes on the fly. This should be + // added in future releases. + + switch (archetype.toLowerCase()) { + case "circle": //$NON-NLS-1$ + return ShapeFactory.buildCircle(); + case "rectangle": //$NON-NLS-1$ + return ShapeFactory.buildRectangle(); + case "roundedsquare": //$NON-NLS-1$ + return ShapeFactory.buildRoundedSquare(); + case "square": //$NON-NLS-1$ + return ShapeFactory.buildSquare(); + case "triangle": //$NON-NLS-1$ + return ShapeFactory.buildTriangle(); + default: + throw new BuildException("No shape could be initiated for the provided shape archetype: " + archetype); //$NON-NLS-1$ + } + } +} \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java new file mode 100644 index 0000000..d29e1c9 --- /dev/null +++ b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java @@ -0,0 +1,188 @@ +/** + * 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.bootstrapping; + +import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; +import lu.list.itis.dkd.tui.widget.BaseWidget; +import lu.list.itis.dkd.tui.widget.builder.BaseBuilder; + +import com.google.common.base.Strings; + +import org.jdom2.Document; +import org.jdom2.Element; +import org.jdom2.JDOMException; +import org.jdom2.input.SAXBuilder; + +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * @author Eric Tobias [eric.tobias@list.lu] + * @since 2.2 + * @version 2.2.0 + */ +@NonNullByDefault +public class TangibleObjectBootstrapper { + private static final String WIDGET_BUILDER_NAMESPACE = "lu.list.itis.dkd.tui.widget.builder."; //$NON-NLS-1$ + + private static final Logger logger = Logger.getLogger(TangibleObjectBootstrapper.class.getSimpleName()); + + private Document document; + + private ArrayList objects = new ArrayList<>(); + private ArrayList cursors = new ArrayList<>(); + private ArrayList blobs = new ArrayList<>(); + + + /** + * Constructor initializing all fields. + * + * @param document + * The document containing the XML definition of all objects to initialize. + */ + public TangibleObjectBootstrapper(Document document) { + this.document = document; + } + + /** + * Constructor initializing all fields. + * + * @param fileURI + * The URI of the document containing the XML definition of all objects to initialize. + * @throws BuildException + * Thrown when the provided file URI it not valid or empty. + */ + public TangibleObjectBootstrapper(String fileURI) throws BuildException { + + if (Strings.isNullOrEmpty(fileURI)) { + throw new BuildException("The provided file URI may not be null or empty!"); //$NON-NLS-1$ + } + + SAXBuilder builder = new SAXBuilder(); + File xmlFile = new File(fileURI); + + try { + this.document = builder.build(xmlFile); + } catch (IOException | JDOMException e) { + logger.log(Level.SEVERE, "Error occured while trying to process the object bootstrapping file!", e); //$NON-NLS-1$ + throw new BuildException("The document containing the bootstrapping information could not be processed!", e); //$NON-NLS-1$ + } + } + + /** + * Method called to initialize bootstrapping from a previously provided XML file. The method + * will create all objects, cursors, and blobs. + * + * @throws BuildException + * Thrown when one or more of the tangibles failed to build. + */ + public void bootstrap() throws BuildException { + Element rootNode = document.getRootElement(); + List objectRootNodes = rootNode.getChildren("objects"); //$NON-NLS-1$ + + for (Element objectNode : objectRootNodes) { + switch (objectNode.getName()) { + case "objects": //$NON-NLS-1$ + loadObjects(objectNode); + break; + case "cursors": //$NON-NLS-1$ + break; + case "blobs": //$NON-NLS-1$ + break; + default: + throw new BuildException("Unrecognized object type_\"" + objectNode.getName() + "\"!"); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + loadCursors(); + loadBlobs(); + } + + /** + * Note: When this method encounters an exception, it clears all previously loaded objects from + * the list. + * + * @param objectRootNode + * The root node holding the object node(s). + * @throws BuildException + * TODO + */ + private void loadObjects(Element objectRootNode) throws BuildException { + List objectNodes = objectRootNode.getChildren("object"); //$NON-NLS-1$ + + try { + for (Element objectNode : objectNodes) { + objects.add(buildObjectFromElement(objectNode)); + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | NoSuchMethodException | SecurityException | IllegalArgumentException | InvocationTargetException e) { + + // TODO add logging and collect all other exceptions. + objects.clear(); + throw new BuildException("One of the desired tangibles could not be build! " + e.getMessage(), e); //$NON-NLS-1$ + } + } + + /** + * Method used to determine the appropriate builder for a given object and then issue a build + * call. + * + * @param objectNode + * The node from a larger document that contains, as children, all the necessary + * information to resolve the correct builder and build the final widget. + * @return The final widget as defined by the children of the element node. + * @throws ClassNotFoundException + * Thrown when the class of the builder for the widget or those of the nested corona + * builder(s) could not be found. + * @throws SecurityException + * Thrown when the constructor cannot be retrieved due to some security constraints. + * @throws NoSuchMethodException + * Thrown when no constructor with the given parameter type is available. + * @throws InvocationTargetException + * Thrown if the invocation of any constructor through reflection throws an exception. + * @throws IllegalArgumentException + * Thrown when the provided argument is not eligible for the builder's constructor. + * @throws IllegalAccessException + * Thrown if this Constructor object is enforcing Java language access control and the + * underlying constructor is inaccessible. + * @throws InstantiationException + * Thrown if the class that declares the underlying constructor represents an abstract + * class. + */ + private BaseWidget buildObjectFromElement(Element objectNode) throws ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException { + + Element type = objectNode.getChild("type"); //$NON-NLS-1$ + Class builder = Class.forName(WIDGET_BUILDER_NAMESPACE + type.getValue() + "Builder"); //$NON-NLS-1$ + + @SuppressWarnings("unchecked") + Constructor> constructor = (Constructor>) builder.getConstructor(new Class[] {Element.class}); + return constructor.newInstance(new Object[] {objectNode}).build(); + } + + private void loadCursors() { + Element rootNode = document.getRootElement(); + } + + private void loadBlobs() { + Element rootNode = document.getRootElement(); + } +} \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/exception/BuildException.java b/TULIP/src/lu/list/itis/dkd/tui/exception/BuildException.java index a0ba688..a0cc123 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/exception/BuildException.java +++ b/TULIP/src/lu/list/itis/dkd/tui/exception/BuildException.java @@ -22,9 +22,9 @@ import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; * Exception raised when the building on a widget or corona instance cannot complete successfully * due to the violation of one or more contracts associated with the instance. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.3 + * @version 2.2.0 */ @NonNullByDefault public class BuildException extends Exception { @@ -39,4 +39,16 @@ public class BuildException extends Exception { public BuildException(String reason) { super(reason); } + + /** + * Constructor initializing the reason and the cause. + * + * @param reason + * The reason why this exception was thrown. + * @param throwable + * The cause why this exception was thrown. + */ + public BuildException(String reason, Throwable throwable) { + super(reason, throwable); + } } \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/network/adapter/BluetoothClient.java b/TULIP/src/lu/list/itis/dkd/tui/network/adapter/BluetoothClient.java index d592760..c018193 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/network/adapter/BluetoothClient.java +++ b/TULIP/src/lu/list/itis/dkd/tui/network/adapter/BluetoothClient.java @@ -50,11 +50,11 @@ public class BluetoothClient extends ClientAdapter { /** * Default constructor which assign uuidService. * - * @param uuidService + * @param serviceUuid * The UUID of the service to connect to. */ - public BluetoothClient(String uuidService) { - this.uuidService = uuidService; + public BluetoothClient(String serviceUuid) { + this.uuidService = serviceUuid; } /** diff --git a/TULIP/src/lu/list/itis/dkd/tui/network/adapter/XbeeAdapter.java b/TULIP/src/lu/list/itis/dkd/tui/network/adapter/XbeeAdapter.java index 302a91e..d257841 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/network/adapter/XbeeAdapter.java +++ b/TULIP/src/lu/list/itis/dkd/tui/network/adapter/XbeeAdapter.java @@ -80,7 +80,7 @@ public class XbeeAdapter extends ClientAdapter { // find an instance of serial port as set in port field. while (portEnum.hasMoreElements()) { CommPortIdentifier currPortId = (CommPortIdentifier) portEnum.nextElement(); - if (currPortId.getName().equals(port)) { + if (currPortId.getName().equals(this.port)) { portId = currPortId; break; } diff --git a/TULIP/src/lu/list/itis/dkd/tui/utility/Point.java b/TULIP/src/lu/list/itis/dkd/tui/utility/Point.java index 01867bf..bc48320 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/utility/Point.java +++ b/TULIP/src/lu/list/itis/dkd/tui/utility/Point.java @@ -18,10 +18,15 @@ package lu.list.itis.dkd.tui.utility; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.exception.BuildException; import com.google.common.base.Preconditions; +import org.jdom2.Element; + import java.awt.geom.Point2D.Float; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.util.logging.Level; import java.util.logging.Logger; @@ -30,9 +35,9 @@ import java.util.logging.Logger; * representing the point in multiple coordinate systems.
* Note: This is a mutable object and should never be used as key. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 2.1.4 + * @version 2.2.0 */ @NonNullByDefault public class Point extends Float { @@ -149,6 +154,37 @@ public class Point extends Float { } } + /** + * Constructor for initializing a point from XML. + * + * @param rootNode + * The node that contains, as child nodes, all relevant nodes to initialize the + * corresponding fields. + * @throws BuildException + * Thrown when one or more of the required parameters for the Point could not be set. + */ + public Point(Element rootNode) throws BuildException { + + super(java.lang.Float.parseFloat(rootNode.getChildText("x")), java.lang.Float.parseFloat(rootNode.getChildText("y"))); //$NON-NLS-1$ //$NON-NLS-2$ + this.angle = java.lang.Float.parseFloat(rootNode.getChildText("z")); //$NON-NLS-1$ + + if (rootNode.getChild("state") != null) { //$NON-NLS-1$ + try { + Class stateClass = Class.forName(Point.class.getPackage() + "." + rootNode.getChildText("state")); //$NON-NLS-1$ //$NON-NLS-2$ + Constructor stateConstructor = stateClass.getConstructor(new Class[] {Point.class, java.lang.Float.TYPE, java.lang.Float.TYPE}); + this.state = (CoordinateState) stateConstructor.newInstance(new Object[] {this, x, y}); + } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { + throw new BuildException("The state of the point cannot be resolved for " + rootNode.getChildText("state"), e); //$NON-NLS-1$ //$NON-NLS-2$ + } + } else { + state = new CameraCoordinates(this, x, y); + } + + if (rootNode.getChild("rotationDirection") != null) { //$NON-NLS-1$ + rotationDirection = java.lang.Float.parseFloat(rootNode.getChildText("rotationDirection")); //$NON-NLS-1$ + } + } + /** * Simple getter method for state. * @@ -188,7 +224,8 @@ public class Point extends Float { /** * Method for testing the equality of two points as neither equals not hashCode can be - * implemented due to the objects high mutability. This test for equality ignores orientation. + * implemented due to the objects high mutability. This test for equality ignores orientation + * (z-axis). * * @param a * The first point to test for equality. @@ -198,7 +235,7 @@ public class Point extends Float { * floating point number, and both points hold the same class of {@link CoordinateState} * . Orientation is ignored. */ - public static boolean testForEqualPosition(Point a, Point b) { + public static boolean areEqual(Point a, Point b) { if (a.getState().getClass().equals(b.getState().getClass())) { /** * A B A AND B 1 0 0 1 1 1 0 0 0 0 1 0 @@ -210,7 +247,8 @@ public class Point extends Float { /** * Method for testing the equality of two points as neither equals not hashCode can be - * implemented due to the objects high mutability. This test for equality ignores position. + * implemented due to the objects high mutability. This test for equality ignores position + * (x-axis and y-axis) and focuses on the z-axis only. * * @param a * The first point to test for equality. @@ -219,7 +257,7 @@ public class Point extends Float { * @return True if and only if a.agle == b.angle within the delta of a floating * point number, and both points hold the same class of {@link CoordinateState}. */ - public static boolean testForEqualAngle(Point a, Point b) { + public static boolean areAnglesEqual(Point a, Point b) { if (a.getState().getClass().equals(b.getState().getClass())) { return java.lang.Float.compare(a.getAngle(), b.getAngle()) == 0; } diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/BaseWidget.java b/TULIP/src/lu/list/itis/dkd/tui/widget/BaseWidget.java index 4c20f1a..aec032e 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/BaseWidget.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/BaseWidget.java @@ -31,7 +31,6 @@ import com.google.common.collect.Ordering; import java.awt.Graphics2D; import java.awt.Shape; import java.util.ArrayList; -import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; @@ -42,9 +41,9 @@ import java.util.List; * Concretely, the {@link BaseWidget} caters to the base, including angle, of all handles and holds * a map of all {@link Corona} instances defined for the widget and its handles. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 2.1.1 + * @version 2.2.0 */ @NonNullByDefault public class BaseWidget { @@ -198,23 +197,6 @@ public class BaseWidget { return new ArrayList<>(coronas.values()); } - /** - * Method returning all {@link Corona} instances that are forming the visual background. - * - * @return A {@link Collection} of {@link Corona} instances that are set to form the visual - * background. The {@link Collection} will be empty if the widget does not manage any - * background coronas. - */ - public Collection getBackgroundCoronas() { - Collection results = new ArrayList<>(); - - for (Corona corona : coronas.values()) { - if (corona.formsBackground()) { - results.add(corona); - } - } - return results; - } /** * Method for returning the {@link Point} that holds the position at which the handle with the diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseBuilder.java index 0b04fb0..cbc3333 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseBuilder.java @@ -18,24 +18,32 @@ package lu.list.itis.dkd.tui.widget.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; +import lu.list.itis.dkd.tui.bootstrapping.CoronaBootstrapper; +import lu.list.itis.dkd.tui.bootstrapping.NetworkAdapterBootstrapper; +import lu.list.itis.dkd.tui.bootstrapping.ShapeBootstrapper; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.network.adapter.NetworkAdapter; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.BaseWidget; import lu.list.itis.dkd.tui.widget.corona.Corona; +import com.google.common.base.Strings; import com.google.common.collect.Multimap; import com.google.common.collect.TreeMultimap; +import org.jdom2.Element; + import java.awt.Shape; import java.util.HashMap; /** * Abstract builder class serving as the top level hierarchical construct for all widget builders. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @author Nicolas Gilmard * @since 1.0 - * @version 2.1.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -63,6 +71,37 @@ public abstract class BaseBuilder> { name = ""; //$NON-NLS-1$ } + /** + * Constructor initializing all fields from an {@link Element} containing as child elements all + * the information on fields to initialize. This constructor will add all associated handles as + * keys in the position map. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Thrown when any of the fields fail to populate due to an error in reading information + * from the XML file. + */ + public BaseBuilder(Element rootElement) throws BuildException { + coronas = TreeMultimap.create(); + positions = new HashMap<>(); + + for (Element handleNode : rootElement.getChild(Messages.HANDLES_NODE).getChildren(Messages.HANDLE_NODE)) { + try { + int id = Integer.parseInt(handleNode.getText()); + positions.put(id, null); + } catch (NumberFormatException nfe) { + throw new BuildException("The handle id could not be interpreted!", nfe); //$NON-NLS-1$ + } + } + + name = Strings.nullToEmpty(rootElement.getChildText(Messages.NAME_NODE)); + definingShape = ShapeBootstrapper.getShape(rootElement.getChildText(Messages.DEFINING_SHAPE_NODE)); + networkAdapter = NetworkAdapterBootstrapper.getNetworkAdapter(rootElement.getChild(Messages.NETWORK_ADAPTER_NODE)); + + coronas = CoronaBootstrapper.getCoronas(rootElement.getChild(Messages.CORONAS_NODE)); + } /** * Method for adding a corona to a given handle. diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseWidgetBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseWidgetBuilder.java index 9492155..fd8e33f 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseWidgetBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/builder/BaseWidgetBuilder.java @@ -17,18 +17,46 @@ package lu.list.itis.dkd.tui.widget.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.widget.BaseWidget; +import org.jdom2.Element; + /** * BaseWidgetBuilder class used to construct a simple widget by providing methods to set all * parameters and permutations thereof. * * @author Eric TOBIAS [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public final class BaseWidgetBuilder extends BaseBuilder { + + /** + * Default no-arg constructor that is to be used if not bootstrapping from an XML. + */ + public BaseWidgetBuilder() { + super(); + } + + /** + * Constructor initializing all fields from an {@link Element} containing as child elements all + * the information on fields to initialize. This constructor is used if tangibles are to be + * bootstrapped from an XML file. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Thrown when one or more of the required parameters for correctly initializing the + * {@link BaseWidgetBuilder} were missing or couldn't be read from the provided root + * element. + */ + public BaseWidgetBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** * Method for building a {@link BaseWidget} with the values set by the builder. * diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Corona.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Corona.java index a176094..a116dba 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Corona.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Corona.java @@ -33,10 +33,10 @@ import java.awt.geom.Point2D; /** * The top class in a hierarchy of backgrounds that a tangible widget's handle can show. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @author Valérie MAQUIL [valerie.maquil@list.lu] * @since 1.0 - * @version 2.0.1 + * @version 2.2.0 */ @NonNullByDefault public abstract class Corona implements Comparable { @@ -58,11 +58,6 @@ public abstract class Corona implements Comparable { * centre axis. */ protected boolean spinOnCoronaCentre = false; - /** - * Field indicating whether the corona is to persist after the handle has been lifted from the - * surface. Default: false - */ - protected boolean persisting = false; /** * Field indicating if a corona is to be drawn. Default: false */ @@ -75,10 +70,6 @@ public abstract class Corona implements Comparable { /** Field holding the shape representing the corona. */ @Nullable protected Shape shape; - /** - * Field indicating whether the corona is part of the background. Default: false. - */ - protected boolean background = false; /** * Constructor setting all fields as given by the builder instance. @@ -92,9 +83,7 @@ public abstract class Corona implements Comparable { initialTranslation = builder.initialTranslation; shape = builder.shape; active = builder.active; - background = builder.background; drawPriority = builder.drawPriority; - persisting = builder.persisting; rotateWithHandle = builder.rotateWithHandle; spinOnCoronaCentre = builder.spinOnCoronaCentre; initialRotation = builder.initialRotation; @@ -158,25 +147,6 @@ public abstract class Corona implements Comparable { this.rotateWithHandle = rotateWithHandle; } - /** - * Simple getter method for persisting. - * - * @return The value of persisting. - */ - public boolean isPersisting() { - return persisting; - } - - /** - * Simple setter method for persisting. - * - * @param persisting - * The value to set persisting to. - */ - public synchronized void setPersistance(boolean persisting) { - this.persisting = persisting; - } - /** * Simple getter method for active. * @@ -235,25 +205,6 @@ public abstract class Corona implements Comparable { this.initialTranslation = initialTranslation; } - /** - * Simple getter method for background. - * - * @return The value of background. - */ - public boolean formsBackground() { - return background; - } - - /** - * Simple setter method for background. - * - * @param background - * The value to set background to. - */ - public void setBackground(boolean background) { - this.background = background; - } - /** * Comparison as defined by the {@link Comparable} interface. This comparison is based on the * integer comparison of the draw priorities, ordering lower priorities first. This will result @@ -292,6 +243,16 @@ public abstract class Corona implements Comparable { return relativePoint; } + /** + * Method used to get a {@link Shape} with a relative position to this corona's centre. The + * method uses the current centre and adds and initial offset translations and rotations, + * accounting for any settings, before issuing a transformation of the base shape. + * + * @return A new shape obtained by performing, potentially, a series of affine transformations + * on a clone of the original shape. + * + * @see AffineTransform#createTransformedShape(Shape) + */ public Shape getShapeRelativeToCentre() { centre.toScreenCoordinates(); diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Image.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Image.java index 240ddb8..cc008a8 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Image.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/Image.java @@ -22,7 +22,6 @@ import lu.list.itis.dkd.tui.content.InformationProvider; import lu.list.itis.dkd.tui.content.InformationReceiver; import lu.list.itis.dkd.tui.event.ContextEvent; import lu.list.itis.dkd.tui.event.ContextEventListener; -import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.exception.UnsupportedInformationException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.builder.ImageBuilder; @@ -33,9 +32,9 @@ import java.awt.geom.AffineTransform; /** * Class implementing an image corona for displaying simple images with different options. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public class Image extends Corona implements ContextEventListener, InformationReceiver { @@ -51,11 +50,8 @@ public class Image extends Corona implements ContextEventListener, InformationRe * * @param builder * The {@link ImageBuilder} instance holding all values. - * @throws BuildException - * Thrown when the provided builder cannot initialise the image due to it being - * null. */ - public Image(ImageBuilder builder) throws BuildException { + public Image(ImageBuilder builder) { super(builder); image = builder.image; informationProvider = builder.informationProvider; @@ -84,7 +80,7 @@ public class Image extends Corona implements ContextEventListener, InformationRe initialTranslation = new Point(); } - Point drawAt = background ? (initialTranslation != null ? initialTranslation : new Point()) : centre.add(initialTranslation); + Point drawAt = centre.add(initialTranslation); AffineTransform rotation = new AffineTransform(); rotation.rotate(rotateWithHandle ? drawAt.getAngle() : initialTranslation != null ? initialTranslation.getAngle() : 0, centre.getX(), centre.getY()); diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeFactory.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeFactory.java index 9050a34..19f238a 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeFactory.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/ShapeFactory.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -28,9 +28,9 @@ import java.awt.geom.RoundRectangle2D; /** * Factory constructing different instances of {@link java.awt.Shape}. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public class ShapeFactory { @@ -134,6 +134,15 @@ public class ShapeFactory { return buildSquare(Calibration.getSquareSize()); } + /** + * Method for building a rectangle with dimensions specified in the calibration file. + * + * @return A {@link Rectangle2D} instance. + */ + public static Rectangle2D.Float buildRectangle() { + return buildRectangle(Calibration.getRectangleWidth(), Calibration.getRectangleHeight()); + } + /** * Method for building a rectangle with given width and height. diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseImageBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseImageBuilder.java index 249f8a9..196967e 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseImageBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseImageBuilder.java @@ -18,18 +18,26 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; import lu.list.itis.dkd.tui.content.InformationProvider; import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Image; import lu.list.itis.dkd.tui.widget.corona.TextBox; +import org.jdom2.Element; + +import java.io.File; +import java.io.IOException; + +import javax.imageio.ImageIO; + /** * Builder serving as abstract super class for all {@link Image} builders. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -37,10 +45,10 @@ import lu.list.itis.dkd.tui.widget.corona.TextBox; public abstract class BaseImageBuilder> extends CoronaBuilder { /** Field holding the image to display. */ @Nullable - public java.awt.Image image; + public java.awt.Image image = null; /** Field holding an {@link InformationProvider} instances to draw information from. */ @Nullable - public InformationProvider informationProvider; + public InformationProvider informationProvider = null; /** * Constructor setting the centre of the corona. @@ -52,6 +60,38 @@ public abstract class BaseImageBuilder> extends Co super(centre); } + /** + * Constructor initializing the centre of the corona as well as a possible image and information + * provider as given by the children of a provided element. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + protected BaseImageBuilder(Element rootElement) throws BuildException { + super(rootElement); + + try { + Element imageNode = rootElement.getChild(Messages.IMAGE); + if (null != imageNode) { + image = ImageIO.read(new File(imageNode.getText())); + } + } catch (NullPointerException npe) { + throw new BuildException("The provided image path may not be empty. To add no image, remove the \"image\" element!", npe); //$NON-NLS-1$ + } catch (IllegalArgumentException iae) { + throw new BuildException("The image could not be read from the provided location. The location should be given as absolute path, i.e.: \"C:\\My Image\\image.jpeg\"!", iae); //$NON-NLS-1$ + } catch (IOException ioe) { + throw new BuildException("The image could not be read!", ioe); //$NON-NLS-1$ + } + + // TODO No information provider is instantiated. This would need to be added in future + // releases. + } + /** * Method for adding an {@link java.awt.Image} to the corona. * @@ -82,5 +122,5 @@ public abstract class BaseImageBuilder> extends Co /** {@inheritDoc} */ @Override - public abstract Image build() throws BuildException; + public abstract Image build(); } \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseInfoBoxBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseInfoBoxBuilder.java index abbd466..a309e70 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseInfoBoxBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseInfoBoxBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -18,17 +18,24 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.InfoBox; +import com.google.common.base.Strings; + +import org.jdom2.Element; + +import java.util.ArrayList; import java.util.List; /** * {@link CoronaBuilder} extension building {@link InfoBox} coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -52,6 +59,48 @@ public abstract class BaseInfoBoxBuilder> extend super(centre); } + /** + * Constructor initializing the centre of the corona as well as a possible text and the + * appropriate font size and line height ratio. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof + */ + public BaseInfoBoxBuilder(Element rootElement) throws BuildException { + super(rootElement); + + Element informationNode = rootElement.getChild(Messages.INFORMATION); + if (null != informationNode) { + information = new ArrayList<>(); + for (Element lineNode : informationNode.getChildren(Messages.LINE)) { + information.add(Strings.nullToEmpty(lineNode.getText())); + } + } + + try { + Element fontSizeNode = rootElement.getChild(Messages.FONT_SIZE); + if (null != fontSizeNode) { + fontSize = Integer.parseInt(fontSizeNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided font size must be an integer value!", nfe); //$NON-NLS-1$ + } + + try { + Element lineHeightRatioNode = rootElement.getChild(Messages.LINE_HEIGHT_RATIO); + if (null != lineHeightRatioNode) { + lineHeightRatio = Float.parseFloat(lineHeightRatioNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided line height ratio must be a floating point value!", nfe); //$NON-NLS-1$ + } + } + /** {@inheritDoc} */ @Override public abstract InfoBox build(); diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BasePointerBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BasePointerBuilder.java index 6c300e0..aa513fd 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BasePointerBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BasePointerBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,15 +17,18 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Pointer; +import org.jdom2.Element; + /** * {@link CoronaBuilder} extension building {@link Pointer} coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -41,6 +44,26 @@ public abstract class BasePointerBuilder> extend super(centre); } + /** + * Constructor initializing the centre of the corona as well as a possible text and the + * appropriate font size and line height ratio. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof + */ + protected BasePointerBuilder(Element rootElement) throws BuildException { + super(rootElement); + + if (null == initialTranslation) { + throw new BuildException("The initial translation may not be null. An offset must be specified as to where the pointer will have its centre, relative from the centre of the widget!"); //$NON-NLS-1$ + } + } + /** {@inheritDoc} */ @Override public abstract Pointer build(); diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseRadiusBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseRadiusBuilder.java index baab685..0a8dd15 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseRadiusBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseRadiusBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -18,24 +18,33 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Radius; import com.google.common.base.Preconditions; +import org.jdom2.Element; + import java.awt.Color; import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.Ellipse2D; import java.awt.image.BufferedImage; +import java.io.File; +import java.io.IOException; +import java.lang.reflect.Field; import java.util.Objects; +import javax.imageio.ImageIO; + /** * {@link BaseRadiusBuilder} extension building {@link Radius} coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -66,6 +75,78 @@ public abstract class BaseRadiusBuilder> extends super(centre); } + /** + * Constructor initializing all fields from a given element node. Non-present and non-nullable + * fields will use their default values instead. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + protected BaseRadiusBuilder(Element rootElement) throws BuildException { + super(rootElement); + + try { + Element alphaNode = rootElement.getChild(Messages.ALPHA); + if (null != alphaNode) { + alpha = Float.parseFloat(alphaNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided alpha value ratio must be a floating point value!", nfe); //$NON-NLS-1$ } + } + + try { + Element backgroundColourNode = rootElement.getChild(Messages.BACKGROUND_COLOUR); + if (null != backgroundColourNode) { + + Field field = Class.forName(Messages.JAVA_AWT_COLOR_NAMESPACE).getField(backgroundColourNode.getText().toLowerCase()); + backgroundColour = (Color) field.get(null); + } + } catch (ReflectiveOperationException roe) { + throw new BuildException("An error occured while trying to resolve the background colour! If no background is to be used, do not include a \"backgroundcolour\" node. Should it be present, the colours need to mirror the java.awt.Color fields!", roe); //$NON-NLS-1$ + } + + try { + Element imageNode = rootElement.getChild(Messages.IMAGE); + if (null != imageNode) { + backgroundImage = ImageIO.read(new File(imageNode.getText())); + } + } catch (NullPointerException npe) { + throw new BuildException("The provided background image path may not be empty. To add no image, remove the \"image\" element!", npe); //$NON-NLS-1$ + } catch (IllegalArgumentException iae) { + throw new BuildException("The image could not be read from the provided location. The location should be given as absolute path, i.e.: \"C:\\My Image\\image.jpeg\"!", iae); //$NON-NLS-1$ + } catch (IOException ioe) { + throw new BuildException("The image could not be read!", ioe); //$NON-NLS-1$ + } + + try { + Element borderThicknessNode = rootElement.getChild(Messages.BORDER_THICKNESS); + if (null != borderThicknessNode) { + borderThickness = Float.parseFloat(borderThicknessNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided border thickness must be a floating point value!", nfe); //$NON-NLS-1$ } + } + + Element drawBorderNode = rootElement.getChild(Messages.DRAW_BORDER); + if (null != drawBorderNode) { + drawBorder = Boolean.parseBoolean(drawBorderNode.getText()); + } + + try { + Element radiusNode = rootElement.getChild(Messages.RADIUS); + if (null != radiusNode) { + borderThickness = Float.parseFloat(radiusNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided radius must be a floating point value!", nfe); //$NON-NLS-1$ } + } + } + /** * Method for setting the radius the ring should have. This method will also instantiate the * corresponding ellipse {@link Shape}. diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShadowBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShadowBuilder.java index e62c125..eb9a211 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShadowBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseShadowBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,20 +17,24 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Shadow; +import org.jdom2.Element; + /** * {@link CoronaBuilder} extension building {@link Shadow} coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @NonNullByDefault public abstract class BaseShadowBuilder> extends CoronaBuilder { + /** * Constructor setting the centre of the corona. * @@ -41,6 +45,21 @@ public abstract class BaseShadowBuilder> extends super(centre); } + /** + * Constructor initializing all fields from a given element node. + * + * @param rootNode + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public BaseShadowBuilder(Element rootNode) throws BuildException { + super(rootNode); + } + /** {@inheritDoc} */ @Override public abstract Shadow build(); 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 index cf764b1..a736a50 100644 --- 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 @@ -16,18 +16,23 @@ */ package lu.list.itis.dkd.tui.widget.corona.builder; +import lu.list.itis.dkd.tui.bootstrapping.Messages; +import lu.list.itis.dkd.tui.exception.BuildException; 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 org.jdom2.Element; + import java.awt.Color; +import java.lang.reflect.Field; /** * {@link CoronaBuilder} extension building {@link ShapeCorona} coronas. * * @author Eric Tobias [eric.tobias@list.lu] * @since 2.1 - * @version 2.1.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -47,6 +52,42 @@ public abstract class BaseShapeCoronaBuilder super(centre); } + /** + * Constructor initializing all fields from a given element node. Non-present and non-nullable + * fields will use their default values instead. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + protected BaseShapeCoronaBuilder(Element rootElement) throws BuildException { + super(rootElement); + + try { + Element colourNode = rootElement.getChild(Messages.COLOUR); + if (null != colourNode) { + + Field field = Class.forName(Messages.JAVA_AWT_COLOR_NAMESPACE).getField(colourNode.getText().toLowerCase()); + colour = (Color) field.get(null); + } + } catch (ReflectiveOperationException roe) { + throw new BuildException("An error occured while trying to resolve the colour! The colour needs to mirror the java.awt.Color fields!", roe); //$NON-NLS-1$ + } + + try { + Element borderWidthNode = rootElement.getChild(Messages.BORDER_WIDTH); + if (null != borderWidthNode) { + borderWidth = Integer.parseInt(borderWidthNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided border width must be an integer value!", nfe); //$NON-NLS-1$ + } + } + /** * Method for setting the colour of the shape drawn for this {@link Corona}. diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseTextBoxBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseTextBoxBuilder.java index fd46573..6045c52 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseTextBoxBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseTextBoxBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -18,19 +18,26 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; import lu.list.itis.dkd.tui.content.InformationProvider; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.TextBox; +import com.google.common.base.Strings; + +import org.jdom2.Element; + import java.awt.Color; import java.awt.Font; +import java.lang.reflect.Field; /** * {@link CoronaBuilder} extension building {@link TextBox} coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -58,10 +65,71 @@ public abstract class BaseTextBoxBuilder> extend * @param centre * The centre of the corona, usually the centre of the handle. */ - public BaseTextBoxBuilder(Point centre) { + protected BaseTextBoxBuilder(Point centre) { super(centre); } + /** + * Constructor initializing all fields from a given element node. Non-present and non-nullable + * fields will use their default values instead. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + protected BaseTextBoxBuilder(Element rootElement) throws BuildException { + super(rootElement); + + Element centredNode = rootElement.getChild(Messages.CENTRED); + if (null != centredNode) { + centred = Boolean.parseBoolean(centredNode.getText()); + } + + try { + Element colourNode = rootElement.getChild(Messages.COLOUR); + if (null != colourNode) { + + Field field = Class.forName(Messages.JAVA_AWT_COLOR_NAMESPACE).getField(colourNode.getText().toLowerCase()); + colour = (Color) field.get(null); + } + } catch (ReflectiveOperationException roe) { + throw new BuildException("An error occured while trying to resolve the colour! The colour needs to mirror the java.awt.Color fields!", roe); //$NON-NLS-1$ + } + + + Element fontNode = rootElement.getChild(Messages.FONT); + if (null != fontNode) { + font = Font.decode(fontNode.getText()); + } + + try { + Element fontSizeNode = rootElement.getChild(Messages.FONT_SIZE); + if (null != fontSizeNode) { + fontSize = Integer.parseInt(fontSizeNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided font size must be an integer value!", nfe); //$NON-NLS-1$ + } + + // TODO the addition of an information provider per bootstrapping is not supported at this + // moment. + + try { + Element lineWidthNode = rootElement.getChild(Messages.LINE_WIDTH); + if (null != lineWidthNode) { + lineWidth = Integer.parseInt(lineWidthNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided line width must be an integer value!", nfe); //$NON-NLS-1$ + } + + text = Strings.nullToEmpty(rootElement.getChildText(Messages.TEXT)); + } + /** * Method invoked to set the text that the corona will display. * diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseWedgeBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseWedgeBuilder.java index d8fb5ca..8f5eddd 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseWedgeBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/BaseWedgeBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -18,17 +18,22 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Wedge; +import org.jdom2.Element; + import java.awt.Color; +import java.lang.reflect.Field; /** * {@link CoronaBuilder} extension building {@link Wedge} coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 * @param * The concrete builder. */ @@ -63,13 +68,78 @@ public abstract class BaseWedgeBuilder> extends Co * @param arcLength * The extend of the arc as measured by an angle. */ - public BaseWedgeBuilder(Point centre, float arcRadiusRatio, int arcStartAngle, int arcLength) { + protected BaseWedgeBuilder(Point centre, float arcRadiusRatio, int arcStartAngle, int arcLength) { super(centre); radius = arcRadiusRatio; start = arcStartAngle; length = arcLength; } + /** + * Constructor initializing all fields from a given element node. Non-present and non-nullable + * fields will use their default values instead. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + protected BaseWedgeBuilder(Element rootElement) throws BuildException { + super(rootElement); + + try { + Element edgeColourNode = rootElement.getChild(Messages.EDGE_COLOUR); + if (null != edgeColourNode) { + + Field field = Class.forName(Messages.JAVA_AWT_COLOR_NAMESPACE).getField(edgeColourNode.getText().toLowerCase()); + edgeColour = (Color) field.get(null); + } + } catch (ReflectiveOperationException roe) { + throw new BuildException("An error occured while trying to resolve the edge colour! The colour needs to mirror the java.awt.Color fields if present. To add no colour, simply remove the node!", roe); //$NON-NLS-1$ + } + + try { + Element fillColourNode = rootElement.getChild(Messages.FILL_COLOUR); + if (null != fillColourNode) { + + Field field = Class.forName(Messages.JAVA_AWT_COLOR_NAMESPACE).getField(fillColourNode.getText().toLowerCase()); + fillColour = (Color) field.get(null); + } + } catch (ReflectiveOperationException roe) { + throw new BuildException("An error occured while trying to resolve the fill colour! The colour needs to mirror the java.awt.Color fields if present. To add no colour, simply remove the node!", roe); //$NON-NLS-1$ + } + + try { + Element lengthNode = rootElement.getChild(Messages.LENGTH); + if (null != lengthNode) { + length = Integer.parseInt(lengthNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided arc length must be an integer value!", nfe); //$NON-NLS-1$ + } + + try { + Element radiusNode = rootElement.getChild(Messages.RADIUS); + if (null != radiusNode) { + radius = Float.parseFloat(radiusNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided radius must be a floating point value!", nfe); //$NON-NLS-1$ + } + + try { + Element startNode = rootElement.getChild(Messages.START); + if (null != startNode) { + start = Integer.parseInt(startNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The provided arc start index must be an integer value!", nfe); //$NON-NLS-1$ + } + } + /** * Method for setting the colour to be used as background for this corona. * diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/CoronaBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/CoronaBuilder.java index 018fadc..0d0f92e 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/CoronaBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/CoronaBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -18,18 +18,22 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; import lu.list.itis.dkd.dbc.annotation.Nullable; +import lu.list.itis.dkd.tui.bootstrapping.Messages; +import lu.list.itis.dkd.tui.bootstrapping.ShapeBootstrapper; import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Corona; +import org.jdom2.Element; + import java.awt.Shape; /** * Base builder class for constructing coronas. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 2.0.1 + * @version 2.2.0 * @param * The concrete builder. */ @@ -47,11 +51,6 @@ public abstract class CoronaBuilder> { public boolean rotateWithHandle = true; /** Field indicating whether the corona is to initial rotation on its centre or origin. */ public boolean spinOnCoronaCentre = false; - /** - * Field indicating whether the corona is to persist after the handle has been lifted from the - * surface. Default: false - */ - public boolean persisting = false; /** * Field indicating when a corona is to be drawn; what type of corona it is. Default: * false @@ -65,8 +64,6 @@ public abstract class CoronaBuilder> { /** Field holding the shape representing the corona. */ @Nullable public Shape shape; - /** Field indicating whether the corona is part of the background. Default: false. */ - public boolean background = false; /** Field holding the initial rotation value in radians. Default: 0; */ public double initialRotation = 0; @@ -80,6 +77,61 @@ public abstract class CoronaBuilder> { this.centre = centre; } + /** + * Constructor initializing all fields from an {@link Element} containing as child elements all + * the information on fields to initialize. Note that fields that are not mirrored in the + * bootstrapping configuration file will default. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public CoronaBuilder(Element rootElement) throws BuildException { + Element centreNode = rootElement.getChild(Messages.CENTRE_NODE); + if (null != centreNode) { + centre = new Point(centreNode); + } + + try { + Element drawPriorityNode = rootElement.getChild(Messages.DRAW_PRIORITY_NODE); + if (null != drawPriorityNode) { + drawPriority = Integer.parseInt(drawPriorityNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The drawPriority could not be set, check the entry in the XML!", nfe); //$NON-NLS-1$ + } + + try { + Element initialRotationNode = rootElement.getChild(Messages.INITIAL_ROTATION_NODE); + if (null != initialRotationNode) { + initialRotation = Double.parseDouble(initialRotationNode.getText()); + } + } catch (NumberFormatException nfe) { + throw new BuildException("The initialRotation could not be set, check the entry in the XML!", nfe); //$NON-NLS-1$ + } + + Element initialTranslationNode = rootElement.getChild(Messages.INITIAL_TRANSLATION_NODE); + if (null != initialTranslationNode) { + initialTranslation = new Point(initialTranslationNode); + } + + Element rotateWithHandleNode = rootElement.getChild(Messages.ROTATE_WITH_HANDLE_NODE); + if (null != rotateWithHandleNode) { + rotateWithHandle = Boolean.parseBoolean(rotateWithHandleNode.getText()); + } + + shape = ShapeBootstrapper.getShape(rootElement.getChildText(Messages.SHAPE_NODE)); + + Element spinOnCoronaCentreNode = rootElement.getChild(Messages.SPIN_ON_CORONA_CENTRE_NODE); + if (null != spinOnCoronaCentreNode) { + rotateWithHandle = Boolean.parseBoolean(spinOnCoronaCentreNode.getText()); + } + } + /** * Method used to set the initialTranslation of the corona from its centre. * @@ -121,49 +173,6 @@ public abstract class CoronaBuilder> { return (B) this; } - /** - * Method for setting if the corona should always be considered active. - * - * @param alwaysActive - * True if the corona is to be set to always be active, false - * otherwise. - * @return An instance of the builder for chain calling. - */ - @SuppressWarnings("unchecked") - public B isAlwaysActive(boolean alwaysActive) { - active = alwaysActive; - return (B) this; - } - - /** - * Method for setting whether the corona is part of what is considered the background. - * - * @param inBackground - * True if the corona is to be considered part of the background, - * false otherwise. - * @return An instance of the builder for chain calling. - */ - @SuppressWarnings("unchecked") - public B partOfBackground(boolean inBackground) { - background = inBackground; - return (B) this; - } - - /** - * Method for setting whether the corona is to persists after the handle it is bound to is - * lifted. - * - * @param persistOnLift - * True if the corona is to persist, that is, if it should still be drawn - * when the handle is is bound to is lifted, false otherwise. - * @return An instance of the builder for chain calling. - */ - @SuppressWarnings("unchecked") - public B persistsWhenLifted(boolean persistOnLift) { - persisting = persistOnLift; - return (B) this; - } - /** * Method for setting the draw priority. Lower priorities are drawn first and hence fade into * the background as more may be drawn onto the canvas. @@ -209,9 +218,6 @@ public abstract class CoronaBuilder> { * * @return An instance of the underlying {@link Corona} instance as defined by the concrete * builder class. - * @throws BuildException - * Exception raised when the building of a corona instance cannot complete successfully - * due to the violation of one or more contracts associated with the instance. */ - public abstract Corona build() throws BuildException; + public abstract Corona build(); } \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ImageBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ImageBuilder.java index a4d06d5..7e891c7 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ImageBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ImageBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -21,13 +21,15 @@ import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Image; +import org.jdom2.Element; + /** * {@link ImageBuilder} class used to construct an {@link Image} corona by providing methods to set * all parameters and permutations thereof. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public final class ImageBuilder extends BaseImageBuilder { @@ -41,9 +43,25 @@ public final class ImageBuilder extends BaseImageBuilder { super(centre); } + /** + * Constructor initializing the centre of the corona as well as a possible image and information + * provider as given by the children of a provided element. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public ImageBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** {@inheritDoc} */ @Override - public Image build() throws BuildException { + public Image build() { return new Image(this); } } \ No newline at end of file diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/InfoBoxBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/InfoBoxBuilder.java index 5c7a081..3875e43 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/InfoBoxBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/InfoBoxBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,16 +17,19 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.InfoBox; +import org.jdom2.Element; + /** * {@link InfoBoxBuilder} class used to construct an {@link InfoBox} corona by providing methods to * set all parameters and permutations thereof. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public final class InfoBoxBuilder extends BaseInfoBoxBuilder { @@ -40,6 +43,22 @@ public final class InfoBoxBuilder extends BaseInfoBoxBuilder { super(centre); } + /** + * Constructor initializing the centre of the corona as well as a possible text and the + * appropriate font size and line height ratio. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof + */ + public InfoBoxBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** {@inheritDoc} */ @Override public InfoBox build() { diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/PointerBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/PointerBuilder.java index e621794..0887021 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/PointerBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/PointerBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,16 +17,19 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Pointer; +import org.jdom2.Element; + /** * {@link PointerBuilder} class used to construct a {@link Pointer} corona by providing methods to * set all parameters and permutations thereof. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public final class PointerBuilder extends BasePointerBuilder { @@ -40,6 +43,21 @@ public final class PointerBuilder extends BasePointerBuilder { super(centre); } + /** + * Constructor initializing the centre of the corona. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof + */ + public PointerBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** {@inheritDoc} */ @Override public Pointer build() { diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/RadiusBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/RadiusBuilder.java index 206079e..207de6f 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/RadiusBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/RadiusBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,19 +17,23 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Radius; +import org.jdom2.Element; + /** * {@link RadiusBuilder} class used to construct an {@link Radius} corona by providing methods to * set all parameters and permutations thereof. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public final class RadiusBuilder extends BaseRadiusBuilder { + /** * Constructor setting the centre of the corona. * @@ -40,6 +44,21 @@ public final class RadiusBuilder extends BaseRadiusBuilder { super(centre); } + /** + * Constructor initializing all fields from a given element node. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public RadiusBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** {@inheritDoc} */ @Override public Radius build() { diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShadowBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShadowBuilder.java index 61471b9..c091e83 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShadowBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/ShadowBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,9 +17,12 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Shadow; +import org.jdom2.Element; + /** * {@link ShadowBuilder} class used to construct a {@link Shadow} corona by providing methods to set * all parameters and permutations thereof. @@ -40,6 +43,21 @@ public final class ShadowBuilder extends BaseShadowBuilder { super(centre); } + /** + * Constructor initializing all fields from a given element node. + * + * @param rootNode + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. * + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public ShadowBuilder(Element rootNode) throws BuildException { + super(rootNode); + } + /** {@inheritDoc} */ @Override public Shadow build() { 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 index 4a8afcf..1fae470 100644 --- 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 @@ -16,16 +16,19 @@ */ package lu.list.itis.dkd.tui.widget.corona.builder; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.ShapeCorona; +import org.jdom2.Element; + /** * {@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 + * @version 2.2.0 */ public class ShapeCoronaBuilder extends BaseShapeCoronaBuilder { @@ -39,6 +42,22 @@ public class ShapeCoronaBuilder extends BaseShapeCoronaBuilder { + /** * Constructor setting the centre of the corona. * @@ -40,6 +44,22 @@ public final class TextBoxBuilder extends BaseTextBoxBuilder { super(centre); } + /** + * Constructor initializing all fields from a given element node. Non-present and non-nullable + * fields will use their default values instead. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public TextBoxBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** {@inheritDoc} */ @Override public TextBox build() { diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/WedgeBuilder.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/WedgeBuilder.java index ee703fe..e8c5bc9 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/WedgeBuilder.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/builder/WedgeBuilder.java @@ -4,8 +4,8 @@ * 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. + * 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 @@ -17,19 +17,23 @@ package lu.list.itis.dkd.tui.widget.corona.builder; import lu.list.itis.dkd.dbc.annotation.NonNullByDefault; +import lu.list.itis.dkd.tui.exception.BuildException; import lu.list.itis.dkd.tui.utility.Point; import lu.list.itis.dkd.tui.widget.corona.Wedge; +import org.jdom2.Element; + /** * {@link WedgeBuilder} class used to construct a {@link Wedge} corona by providing methods to set * all parameters and permutations thereof. * - * @author Eric TOBIAS [eric.tobias@list.lu] + * @author Eric Tobias [eric.tobias@list.lu] * @since 1.0 - * @version 1.0.2 + * @version 2.2.0 */ @NonNullByDefault public final class WedgeBuilder extends BaseWedgeBuilder { + /** * Constructor setting the centre of the corona as well as an initialTranslation. * @@ -46,6 +50,22 @@ public final class WedgeBuilder extends BaseWedgeBuilder { super(centre, arcRadiusRatio, arcStartAngle, arcLength); } + /** + * Constructor initializing all fields from a given element node. Non-present and non-nullable + * fields will use their default values instead. + * + * @param rootElement + * The element harbouring, on child nodes, the necessary information to initialize all + * fields of the builder. + * @throws BuildException + * Exception raised when the building of a corona instance cannot complete successfully + * due to the violation of one or more contracts associated with the instance, including + * missing, incomplete, or erroneous parameters or values thereof. + */ + public WedgeBuilder(Element rootElement) throws BuildException { + super(rootElement); + } + /** {@inheritDoc} */ @Override public Wedge build() { diff --git a/TULIP/test/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapperTest.java b/TULIP/test/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapperTest.java new file mode 100644 index 0000000..5e8ae79 --- /dev/null +++ b/TULIP/test/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapperTest.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.bootstrapping; + +import static org.junit.Assert.fail; + +import lu.list.itis.dkd.tui.exception.BuildException; + +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * @author Eric Tobias [eric.tobias@list.lu] + * @since 2.2 + * @version 2.2.0 + */ +public class TangibleObjectBootstrapperTest { + + /** + * @throws java.lang.Exception + */ + @BeforeClass + public static void setUpBeforeClass() throws Exception {} + + /** + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception {} + + /** + * Test method for + * {@link lu.list.itis.dkd.tui.bootstrapping.TangibleObjectBootstrapper#TangibleObjectBootstrapper(org.jdom2.Document)} + * . + */ + @Test + public void testTangibleObjectBootstrapperDocument() { + fail("Not yet implemented"); + } + + /** + * Test method for + * {@link lu.list.itis.dkd.tui.bootstrapping.TangibleObjectBootstrapper#TangibleObjectBootstrapper(java.lang.String)} + * . + * + * @throws BuildException + */ + @Test + public void testTangibleObjectBootstrapperString() throws BuildException { + TangibleObjectBootstrapper bootstrapper = new TangibleObjectBootstrapper("config/test_bootstrapping.xml"); + + bootstrapper.bootstrap(); + } + + /** + * Test method for + * {@link lu.list.itis.dkd.tui.bootstrapping.TangibleObjectBootstrapper#bootstrap()}. + */ + @Test + public void testBootstrap() { + fail("Not yet implemented"); + } + +} diff --git a/TULIP/test/lu/list/itis/dkd/tui/event/PositionChangeListenerTest.java b/TULIP/test/lu/list/itis/dkd/tui/event/PositionChangeListenerTest.java index adc9d37..e6dfff7 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/event/PositionChangeListenerTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/event/PositionChangeListenerTest.java @@ -177,23 +177,23 @@ public class PositionChangeListenerTest { BaseWidget baseWidget = new BaseWidgetBuilder() .withHandle(0, new Point(0, 0, 0)) .build(); - objectList.put(0, baseWidget); + objectMap.put(0, baseWidget); BaseWidget baseWidget_1 = new BaseWidgetBuilder() .withHandle(1, new Point(10, 10, 10)) .build(); - objectList.put(1, baseWidget_1); + objectMap.put(1, baseWidget_1); BaseWidget baseWidget_2 = new BaseWidgetBuilder() .withHandle(2, new Point(20, 20, 20)) .build(); - objectList.put(2, baseWidget_2); + objectMap.put(2, baseWidget_2); BaseWidget baseWidget_3 = new BaseWidgetBuilder() .withHandle(3, new Point(30, 30, 30)) .build(); - objectList.put(3, baseWidget_3); + objectMap.put(3, baseWidget_3); BaseWidget baseWidget_4 = new BaseWidgetBuilder() .withHandle(4, new Point(40, 40, 40)) .build(); - objectList.put(4, baseWidget_4); + objectMap.put(4, baseWidget_4); } } diff --git a/TULIP/test/lu/list/itis/dkd/tui/space/SpatialMatrixTest.java b/TULIP/test/lu/list/itis/dkd/tui/space/SpatialMatrixTest.java index eabd550..95e2771 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/space/SpatialMatrixTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/space/SpatialMatrixTest.java @@ -134,23 +134,23 @@ public class SpatialMatrixTest { BaseWidget baseWidget = new BaseWidgetBuilder() .withHandle(0, new Point(0, 0, 0)) .build(); - objectList.put(0, baseWidget); + objectMap.put(0, baseWidget); BaseWidget baseWidget_1 = new BaseWidgetBuilder() .withHandle(1, new Point(10, 10, 10)) .build(); - objectList.put(1, baseWidget_1); + objectMap.put(1, baseWidget_1); BaseWidget baseWidget_2 = new BaseWidgetBuilder() .withHandle(2, new Point(20, 20, 20)) .build(); - objectList.put(2, baseWidget_2); + objectMap.put(2, baseWidget_2); BaseWidget baseWidget_3 = new BaseWidgetBuilder() .withHandle(3, new Point(30, 30, 30)) .build(); - objectList.put(3, baseWidget_3); + objectMap.put(3, baseWidget_3); BaseWidget baseWidget_4 = new BaseWidgetBuilder() .withHandle(4, new Point(40, 40, 40)) .build(); - objectList.put(4, baseWidget_4); + objectMap.put(4, baseWidget_4); } } diff --git a/TULIP/test/lu/list/itis/dkd/tui/utility/CameraCoordinatesTest.java b/TULIP/test/lu/list/itis/dkd/tui/utility/CameraCoordinatesTest.java index a09e7f6..53255f0 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/utility/CameraCoordinatesTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/utility/CameraCoordinatesTest.java @@ -53,9 +53,9 @@ public class CameraCoordinatesTest { point.toTableCoordinates(); Point control = new Point(1, 1, 1f); control.setState(new TableCoordinates(control, Calibration.cameraToTableX(1), Calibration.cameraToTableY(1))); - assertFalse(Point.testForEqualPosition(point, new Point(1, 1, 1f))); + assertFalse(Point.areEqual(point, new Point(1, 1, 1f))); assertEquals(TableCoordinates.class, point.getState().getClass()); - assertTrue(Point.testForEqualPosition(point, control)); + assertTrue(Point.areEqual(point, control)); } /** @@ -69,9 +69,9 @@ public class CameraCoordinatesTest { point.toScreenCoordinates(); Point control = new Point(1, 1, 1f); control.setState(new ScreenCoordinates(control, Calibration.cameraToScreenX(1), Calibration.cameraToScreenY(1))); - assertFalse(Point.testForEqualPosition(point, new Point(1, 1, 1f))); + assertFalse(Point.areEqual(point, new Point(1, 1, 1f))); assertEquals(ScreenCoordinates.class, point.getState().getClass()); - assertTrue(Point.testForEqualPosition(point, control)); + assertTrue(Point.areEqual(point, control)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/utility/PointTest.java b/TULIP/test/lu/list/itis/dkd/tui/utility/PointTest.java index 5b752ac..30bfe5a 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/utility/PointTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/utility/PointTest.java @@ -87,19 +87,19 @@ public class PointTest { } /** - * Test method for {@link lu.list.itis.dkd.tui.utility.Point#testForEqualPosition(Point, Point)} + * Test method for {@link lu.list.itis.dkd.tui.utility.Point#areEqual(Point, Point)} * . */ @Test public void testForEquality() { Point point = new Point(1, 2, 1f); Point two = new Point(1, 1, 1f); - assertFalse(Point.testForEqualPosition(point, two)); - assertTrue(Point.testForEqualPosition(point, point)); - assertTrue(Point.testForEqualPosition(point, new Point(1, 2, 1f))); + assertFalse(Point.areEqual(point, two)); + assertTrue(Point.areEqual(point, point)); + assertTrue(Point.areEqual(point, new Point(1, 2, 1f))); point.setState(new TableCoordinates(point, point.x, point.y)); - assertFalse(Point.testForEqualPosition(point, new Point(1, 2, 1f))); + assertFalse(Point.areEqual(point, new Point(1, 2, 1f))); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/utility/ScreenCoordinatesTest.java b/TULIP/test/lu/list/itis/dkd/tui/utility/ScreenCoordinatesTest.java index 7c2c418..4ffb797 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/utility/ScreenCoordinatesTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/utility/ScreenCoordinatesTest.java @@ -58,9 +58,9 @@ public class ScreenCoordinatesTest { point.toTableCoordinates(); - assertFalse(Point.testForEqualPosition(point, base)); + assertFalse(Point.areEqual(point, base)); assertEquals(TableCoordinates.class, point.getState().getClass()); - assertTrue(Point.testForEqualPosition(point, control)); + assertTrue(Point.areEqual(point, control)); } /** @@ -94,9 +94,9 @@ public class ScreenCoordinatesTest { point.toCameraCoordinates(); - assertFalse(Point.testForEqualPosition(point, base)); + assertFalse(Point.areEqual(point, base)); assertEquals(CameraCoordinates.class, point.getState().getClass()); - assertTrue(Point.testForEqualPosition(point, control)); + assertTrue(Point.areEqual(point, control)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/utility/TableCoordinatesTest.java b/TULIP/test/lu/list/itis/dkd/tui/utility/TableCoordinatesTest.java index e59a0f2..77a088c 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/utility/TableCoordinatesTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/utility/TableCoordinatesTest.java @@ -73,9 +73,9 @@ public class TableCoordinatesTest { point.toScreenCoordinates(); - assertFalse(Point.testForEqualPosition(point, base)); + assertFalse(Point.areEqual(point, base)); assertEquals(ScreenCoordinates.class, point.getState().getClass()); - assertTrue(Point.testForEqualPosition(point, control)); + assertTrue(Point.areEqual(point, control)); } /** @@ -94,9 +94,9 @@ public class TableCoordinatesTest { point.toCameraCoordinates(); - assertFalse(Point.testForEqualPosition(point, base)); + assertFalse(Point.areEqual(point, base)); assertEquals(CameraCoordinates.class, point.getState().getClass()); - assertTrue(Point.testForEqualPosition(point, control)); + assertTrue(Point.areEqual(point, control)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/widget/state/FunctionStateTest.java b/TULIP/test/lu/list/itis/dkd/tui/widget/state/FunctionStateTest.java index abf7581..0797b74 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/widget/state/FunctionStateTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/widget/state/FunctionStateTest.java @@ -68,7 +68,7 @@ public class FunctionStateTest { @Test public void testDrop() { assertNull(func.lift(point)); - assertTrue(Point.testForEqualPosition(func.getBase(), point)); + assertTrue(Point.areEqual(func.getBase(), point)); } /** @@ -79,7 +79,7 @@ public class FunctionStateTest { @Test public void testLift() { assertNull(func.lift(point)); - assertTrue(Point.testForEqualPosition(func.getBase(), point)); + assertTrue(Point.areEqual(func.getBase(), point)); } /** @@ -90,7 +90,7 @@ public class FunctionStateTest { @Test public void testMove() { assertNull(func.move(point)); - assertTrue(Point.testForEqualPosition(func.getBase(), point)); + assertTrue(Point.areEqual(func.getBase(), point)); } /** @@ -101,7 +101,7 @@ public class FunctionStateTest { @Test public void testRotate() { assertNull(func.rotate(point)); - assertTrue(Point.testForEqualPosition(func.getBase(), point)); + assertTrue(Point.areEqual(func.getBase(), point)); } /** @@ -112,7 +112,7 @@ public class FunctionStateTest { @Test public void testFunction() { assertNull(func.function(point)); - assertTrue(Point.testForEqualPosition(func.getBase(), point)); + assertTrue(Point.areEqual(func.getBase(), point)); } /** @@ -123,7 +123,7 @@ public class FunctionStateTest { @Test public void testFunctionState() { assertNull(func.lift(point)); - assertTrue(Point.testForEqualPosition(func.getBase(), point)); + assertTrue(Point.areEqual(func.getBase(), point)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/widget/state/LimboStateTest.java b/TULIP/test/lu/list/itis/dkd/tui/widget/state/LimboStateTest.java index e0146af..5e3686f 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/widget/state/LimboStateTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/widget/state/LimboStateTest.java @@ -70,13 +70,13 @@ public class LimboStateTest { assertNotNull(transition); assertEquals(limbo, transition.getFrom()); assertTrue(transition.getTo() instanceof StillState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = limbo.drop(pointToLittle); assertNotNull(transition); assertEquals(limbo, transition.getFrom()); assertTrue(transition.getTo() instanceof StillState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); } /** @@ -120,22 +120,22 @@ public class LimboStateTest { assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = limbo.function(pointToLittle); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = limbo.function(pointEnough); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(limbo); - assertTrue(Point.testForEqualPosition(limbo.base, point)); + assertTrue(Point.areEqual(limbo.base, point)); } /** @@ -146,7 +146,7 @@ public class LimboStateTest { @Test public void testLimboState() { assertNotNull(limbo); - assertTrue(Point.testForEqualPosition(limbo.base, point)); + assertTrue(Point.areEqual(limbo.base, point)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/widget/state/MovementStateTest.java b/TULIP/test/lu/list/itis/dkd/tui/widget/state/MovementStateTest.java index f55f22b..cb852cd 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/widget/state/MovementStateTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/widget/state/MovementStateTest.java @@ -67,7 +67,7 @@ public class MovementStateTest { @Test public void testDrop() { assertNull(movement.drop(point)); - assertTrue(Point.testForEqualPosition(movement.getBase(), point)); + assertTrue(Point.areEqual(movement.getBase(), point)); } /** @@ -81,22 +81,22 @@ public class MovementStateTest { assertNotNull(transition); assertEquals(movement, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = movement.lift(pointToLittle); assertNotNull(transition); assertEquals(movement, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = movement.lift(pointEnough); assertNotNull(transition); assertEquals(movement, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); } /** @@ -109,21 +109,21 @@ public class MovementStateTest { Transition transition = movement.move(point); assertNull(transition); assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); transition = movement.move(pointToLittle); assertNull(transition); assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); transition = movement.move(pointEnough); assertNotNull(transition); assertEquals(movement, transition.getFrom()); assertTrue(transition.getTo() instanceof MovementState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); } /** @@ -137,22 +137,22 @@ public class MovementStateTest { assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof RotationState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = movement.rotate(pointToLittle); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof RotationState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = movement.rotate(pointEnough); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof RotationState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); } /** @@ -166,22 +166,22 @@ public class MovementStateTest { assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = movement.function(pointToLittle); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = movement.function(pointEnough); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); } /** @@ -192,7 +192,7 @@ public class MovementStateTest { @Test public void testMovementState() { assertNotNull(movement); - assertTrue(Point.testForEqualPosition(movement.base, point)); + assertTrue(Point.areEqual(movement.base, point)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/widget/state/RotationStateTest.java b/TULIP/test/lu/list/itis/dkd/tui/widget/state/RotationStateTest.java index afea7e3..b9d7d10 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/widget/state/RotationStateTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/widget/state/RotationStateTest.java @@ -67,7 +67,7 @@ public class RotationStateTest { @Test public void testDrop() { assertNull(rotation.drop(point)); - assertTrue(Point.testForEqualPosition(rotation.getBase(), point)); + assertTrue(Point.areEqual(rotation.getBase(), point)); } /** @@ -81,22 +81,22 @@ public class RotationStateTest { assertNotNull(transition); assertEquals(rotation, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = rotation.lift(pointToLittle); assertNotNull(transition); assertEquals(rotation, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = rotation.lift(pointEnough); assertNotNull(transition); assertEquals(rotation, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); } /** @@ -110,22 +110,22 @@ public class RotationStateTest { assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof MovementState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = rotation.move(pointToLittle); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof MovementState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = rotation.move(pointEnough); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof MovementState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); } /** @@ -138,21 +138,21 @@ public class RotationStateTest { Transition transition = rotation.rotate(point); assertNull(transition); assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); transition = rotation.rotate(pointToLittle); assertNull(transition); assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); transition = rotation.rotate(pointEnough); assertNotNull(transition); assertEquals(rotation, transition.getFrom()); assertTrue(transition.getTo() instanceof RotationState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); } /** @@ -166,22 +166,22 @@ public class RotationStateTest { assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = rotation.function(pointToLittle); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = rotation.function(pointEnough); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); } /** @@ -192,7 +192,7 @@ public class RotationStateTest { @Test public void testRotationState() { assertNotNull(rotation); - assertTrue(Point.testForEqualPosition(rotation.base, point)); + assertTrue(Point.areEqual(rotation.base, point)); } /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/widget/state/StateManagerTest.java b/TULIP/test/lu/list/itis/dkd/tui/widget/state/StateManagerTest.java index 14c6743..297c633 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/widget/state/StateManagerTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/widget/state/StateManagerTest.java @@ -508,9 +508,9 @@ public class StateManagerTest { } assertTrue(manager.isFunctioning()); - assertFalse(Point.testForEqualPosition(functionsStates.get(0).getBase(), functionsStates.get(1).getBase())); - assertTrue(Point.testForEqualPosition(points.get(0), functionsStates.get(0).getBase()) || Point.testForEqualPosition(points.get(1), functionsStates.get(0).getBase())); - assertTrue(Point.testForEqualPosition(points.get(0), functionsStates.get(1).getBase()) || Point.testForEqualPosition(points.get(1), functionsStates.get(1).getBase())); + assertFalse(Point.areEqual(functionsStates.get(0).getBase(), functionsStates.get(1).getBase())); + assertTrue(Point.areEqual(points.get(0), functionsStates.get(0).getBase()) || Point.areEqual(points.get(1), functionsStates.get(0).getBase())); + assertTrue(Point.areEqual(points.get(0), functionsStates.get(1).getBase()) || Point.areEqual(points.get(1), functionsStates.get(1).getBase())); } // /** diff --git a/TULIP/test/lu/list/itis/dkd/tui/widget/state/StillStateTest.java b/TULIP/test/lu/list/itis/dkd/tui/widget/state/StillStateTest.java index 8582830..9c74e30 100644 --- a/TULIP/test/lu/list/itis/dkd/tui/widget/state/StillStateTest.java +++ b/TULIP/test/lu/list/itis/dkd/tui/widget/state/StillStateTest.java @@ -67,7 +67,7 @@ public class StillStateTest { @Test public void testDrop() { assertNull(still.drop(point)); - assertTrue(Point.testForEqualPosition(still.getBase(), point)); + assertTrue(Point.areEqual(still.getBase(), point)); } /** @@ -81,22 +81,22 @@ public class StillStateTest { assertNotNull(transition); assertEquals(still, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = still.lift(pointToLittle); assertNotNull(transition); assertEquals(still, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = still.lift(pointEnough); assertNotNull(transition); assertEquals(still, transition.getFrom()); assertTrue(transition.getTo() instanceof LimboState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); } /** @@ -109,21 +109,21 @@ public class StillStateTest { Transition transition = still.move(point); assertNull(transition); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.getBase(), point)); + assertTrue(Point.areEqual(still.getBase(), point)); transition = still.move(pointToLittle); assertNull(transition); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.getBase(), point)); + assertTrue(Point.areEqual(still.getBase(), point)); transition = still.move(pointEnough); assertNotNull(transition); assertEquals(still, transition.getFrom()); assertTrue(transition.getTo() instanceof MovementState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); } /** @@ -136,21 +136,21 @@ public class StillStateTest { Transition transition = still.rotate(point); assertNull(transition); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); transition = still.rotate(pointToLittle); assertNull(transition); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); transition = still.rotate(pointEnough); assertNotNull(transition); assertEquals(still, transition.getFrom()); assertTrue(transition.getTo() instanceof RotationState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); } /** @@ -164,22 +164,22 @@ public class StillStateTest { assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), point)); + assertTrue(Point.areEqual(transition.getTo().getBase(), point)); transition = still.function(pointToLittle); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointToLittle)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointToLittle)); transition = still.function(pointEnough); assertNotNull(transition); assertNull(transition.getFrom()); assertTrue(transition.getTo() instanceof FunctionState); - assertTrue(Point.testForEqualPosition(transition.getTo().getBase(), pointEnough)); + assertTrue(Point.areEqual(transition.getTo().getBase(), pointEnough)); assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); } /** @@ -190,7 +190,7 @@ public class StillStateTest { @Test public void testStillState() { assertNotNull(still); - assertTrue(Point.testForEqualPosition(still.base, point)); + assertTrue(Point.areEqual(still.base, point)); } /** -- GitLab