From 0a1f88a2ab354f598ea28139ae047f84d3564e03 Mon Sep 17 00:00:00 2001 From: Nico Mack Date: Thu, 14 Dec 2017 15:12:05 +0100 Subject: [PATCH] Minor code cleanup --- .../TangibleObjectBootstrapper.java | 51 +++++++++--------- .../widget/corona/AnimatedShapeCorona.java | 8 +-- .../itis/dkd/tui/widget/corona/HtmlBox.java | 54 +++++++++++-------- .../itis/dkd/tui/widget/corona/TextBox.java | 19 ------- .../list/itis/dkd/tui/widget/tether/Line.java | 8 --- .../dkd/tui/widget/touch/TouchManager.java | 18 +++++-- 6 files changed, 74 insertions(+), 84 deletions(-) diff --git a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java index b7b4b60..4af0842 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java +++ b/TULIP/src/lu/list/itis/dkd/tui/bootstrapping/TangibleObjectBootstrapper.java @@ -93,8 +93,8 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { } /** - * Method called to initialize bootstrapping from a previously provided XML file. The method - * will create all objects, cursors, and blobs. + * 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. @@ -109,10 +109,10 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { } /** - * Method called to create a new instance of a cursor object. New cursor object will be created - * from template specified in bootstrap file. In case multiple cursor templates are encountered, - * only the first one will taken into account. This may change in future release, allowing to - * assign different cursor templates depending on the cursor ID. + * Method called to create a new instance of a cursor object. New cursor object will be created from + * template specified in bootstrap file. In case multiple cursor templates are encountered, only the + * first one will taken into account. This may change in future release, allowing to assign + * different cursor templates depending on the cursor ID. * * @param cursorId * specifies the ID of the cursor object to create. @@ -154,29 +154,27 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { Element rootNode = bootstrap.getRootElement(); List connectionsRootNodes = rootNode.getChildren(Externalization.CONNECTIONS_NODE); // $NON-NLS-1$ if (connectionsRootNodes != null) { - for (Element connectionsNode : connectionsRootNodes) + for (Element connectionsNode : connectionsRootNodes) { if (connectionsNode != null) { for (Element connectionNode : connectionsNode.getChildren()) { - switch (connectionNode.getName()) { - case "tethers": //$NON-NLS-1$ - this.loadTethers(connectionNode); - break; - default: - throw new BuildException(StringUtils.build("Unrecognized connection type {} !", connectionsNode.getName())); //$NON-NLS-1$ //$NON-NLS-2$ + if (Externalization.TETHERS_NODE.equals(connectionNode.getName())) { + this.loadTethers(connectionNode); + } else { + throw new BuildException(StringUtils.build("Unrecognized connection type {} !", connectionsNode.getName())); //$NON-NLS-1$ } } } + } } } /** - * Note: When this method encounters an exception, it clears all previously loaded objects from - * the list. + * 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 loadTethers(Element tetherRootNode) throws BuildException { List tetherNodes = tetherRootNode.getChildren(Externalization.TETHER_NODE); @@ -192,14 +190,14 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { LOGGER.error("One of the desired tethers could not be build!", e); //$NON-NLS-1$ tetherMap.clear(); - throw new BuildException("One of the desired tethers could not be build! " + e.getMessage(), e); //$NON-NLS-1$ + throw new BuildException("One of the desired tethers could not be build!", e); //$NON-NLS-1$ } } /** * builds a cursor from the specified template node. A second parameter allows specifying the - * bootstrapping context, a map holding the names and the values of variables for interpolation - * of variable properties in template definition. + * bootstrapping context, a map holding the names and the values of variables for interpolation of + * variable properties in template definition. * * @param templateNode * specifies the template node to build the cursor from @@ -231,8 +229,8 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { /** * builds a widget from the specified template node. A second parameter allows specifying the - * bootstrapping context, a map holding the names and the values of variables for interpolation - * of variable properties in template definition. + * bootstrapping context, a map holding the names and the values of variables for interpolation of + * variable properties in template definition. * * @param templateNode * specifies the template node to build the widget from @@ -263,8 +261,8 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { /** - * Note: When this method encounters an exception, it clears all previously loaded objects from - * the list. + * 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). @@ -290,12 +288,11 @@ public class TangibleObjectBootstrapper extends TangibleObjectManager { } /** - * Method used to determine the appropriate builder for a given object and then issue a build - * call. + * 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. + * The node from a larger document that contains, as children, all the necessary information + * to resolve the correct builder and build the final widget. * @param context * @param callback * @return The final widget as defined by the children of the element node. diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/AnimatedShapeCorona.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/AnimatedShapeCorona.java index ce42b07..9afe52e 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/AnimatedShapeCorona.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/AnimatedShapeCorona.java @@ -56,8 +56,8 @@ public class AnimatedShapeCorona extends AnimatedCorona { // * Constants * // *************************************************************************** - private static final String OPACITY = "opacity"; //$NON-NLS-1$ - private static final String SCALE = "scale"; //$NON-NLS-1$ + private static final String PROPERTY_OPACITY = "opacity"; //$NON-NLS-1$ + private static final String PROPERTY_SCALE = "scale"; //$NON-NLS-1$ // --------------------------------------------------------------------------- // *************************************************************************** @@ -117,9 +117,9 @@ public class AnimatedShapeCorona extends AnimatedCorona { List> properties = this.getAnimationProperties(); for (AnimationProperty property : properties) { - if (OPACITY.equals(property.getProperty())) { + if (PROPERTY_OPACITY.equals(property.getProperty())) { this.setOpacity((double) property.getStart()); - } else if (SCALE.equals(property.getProperty())) { + } else if (PROPERTY_SCALE.equals(property.getProperty())) { this.setScale((double) property.getStart()); } } diff --git a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/HtmlBox.java b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/HtmlBox.java index 75ded38..ee30b59 100644 --- a/TULIP/src/lu/list/itis/dkd/tui/widget/corona/HtmlBox.java +++ b/TULIP/src/lu/list/itis/dkd/tui/widget/corona/HtmlBox.java @@ -33,6 +33,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.RenderingHints; +import java.awt.Shape; import java.awt.Stroke; import java.awt.geom.AffineTransform; import java.awt.geom.Rectangle2D; @@ -159,6 +160,36 @@ public class HtmlBox extends SelectableCorona implements InformationReceiver [{}]", oldState, event, newState); //$NON-NLS-1$ - + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("State Change [{}] =[{}]=> [{}]", oldState, event, newState); //$NON-NLS-1$ + } return newState; } @@ -215,6 +218,9 @@ public class TouchManager { this.touchStates.put(touchId, newState); if (touched) { this.touchPositions.put(touchId, event.getPosition()); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Cursor {} touched @ Position [{}]", touchId, event.getPosition()); //$NON-NLS-1$ + } } return touched; @@ -280,6 +286,10 @@ public class TouchManager { if (released) { this.touchStates.remove(touchId); this.touchPositions.remove(touchId); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Cursor {} released @ Position [{}]", touchId, event.getPosition()); //$NON-NLS-1$ + } + } else { this.touchStates.put(touchId, newState); this.touchPositions.put(touchId, event.getPosition()); -- GitLab