Commit 5629b924 authored by Nico Mack's avatar Nico Mack

Implement Touch Functionality.

Merged IndexedCorona into SelectableCorona
parent a572c9d6
ABOVE_ELEMENT=above
ACTIVATE_WITH_HANDLE_NODE=activateWithHandle
ALPHA_NODE=alpha
ANIMATED_PROPERTIES_ELEMENT=animatedProperties
ANIMATED_PROPERTY_ELEMENT=animatedProperty
ARC_SPAN_NODE=arcSpan
ASSET_ELEMENT=asset
ASSIGNABLE_NODE=assignable
BACKGROUND_COLOUR_NODE=backgroundColour
BASE_VALUE_NODE=baseValue
BEGIN_NODE=begin
BELOW_ELEMENT=below
BEZEL_COLOUR_ELEMENT=bezelColour
BLOBS_NODE=blobs
BORDER_THICKNESS_NODE=borderThickness
BORDER_WIDTH_NODE=borderWidth
BOUNDS_NODE=bounds
BUILDER_CLASS_POSTFIX=Builder
CENTER_ON_ZOOM_NODE=centerOnZoom
CENTRE_NODE=centre
CENTRED_NODE=centred
CIRCLE_SIZE_NODE=circleSize
COLOUR_NODE=colour
COLOURSC_NODE=colourscheme
CONNECTIONS_NODE=connections
CORNER_RADIUS_NODE=cornerRadius
CORONA_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.corona.builder
CORONA_NODE=corona
CORONAS_NODE=coronas
COUNT_ATTRIBUTE=count
CURSOR_NODE=cursor
CURSORS_NODE=cursors
DEFINING_SHAPE_NODE=definingShape
DELAY_NODE=delay
DESELECTED_ELEMENT=deselected
DISPLAY_TIME_NODE=displayTime
DISTANCE_NODE=distance
DRAGGABLE_NODE=draggable
DRAW_BORDER_NODE=drawBorder
DRAW_PRIORITY_NODE=drawPriority
DURATION_NODE=duration
DYNAMIC_NODE=variableIsDynamic
EDGE_COLOUR_NODE=edgeColour
EMPTY_STRING=
END_NODE=end
ENDING_NODE=ending
EXCLUSIVE_NODE=exclusive
FACE_COLOUR_ELEMENT=faceColour
FADE_IN_TIME_NODE=fadeInTime
FADE_OUT_TIME_NODE=fadeOutTime
FADE_WITH_HANDLE_NODE=fadeWithHandle
FILL_COLOUR_ELEMENT=fillColour
FILL_COLOUR_NODE=fillColour
FONT_NODE=font
FONT_SIZE_NODE=fontSize
FULLSCREEN_NODE=fullScreen
GAP_NODE=gap
GLOBAL_STATE_LISTENER_NODE=globalStateListener
HANDLE_NODE=handle
HANDLES_NODE=handles
HEIGHT_NODE=height
IMAGE_ELEMENT=image
IMAGE_BASE64_ELEMENT=imageBase64
IMAGE_ELEMENT=image
IMAGES_ELEMENT=images
INDEX_ATTRIBUTE=index
INDEX_NODE=index
INFORMATION=information
INITIAL_ROTATION_NODE=initialRotation
INITIAL_TRANSLATION_NODE=initialTranslation
INNER_RADIUS_NODE=innerRadius
JAVA_AWT_COLOR_NAMESPACE=java.awt.Color
LABEL_COLOUR_ELEMENT=labelColour
LABEL_SHAPE_NODE=labelShape
LATCHING_NODE=latching
LENGTH_NODE=length
LINE_NODE=line
LINE_HEIGHT_RATIO_NODE=lineHeightRatio
LINE_NODE=line
LINE_WIDTH_NODE=lineWidth
LOCATION_NODE=location
LOOPING_NODE=looping
LOWER_BOUND_NODE=lowerBound
LOWER_BOUND_VARIABLE_NODE=lowerBoundVariable
LOWER_STOP_ANGLE_NODE=lowerStopAngle
MAGNIFICATION_NODE=magnification
MAGNIFIER_SHAPE_NODE=magnifierShape
MARKER_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.marker.builder
MARKER_NODE=marker
MARKERS_NODE=markers
MAXIMUM_VALUE_NODE=maximumValue
MEDIA_NODE=media
MINIMUM_VALUE_NODE=minimumValue
MODIFY_VALUE_ON_ROTATION_NODE=modifyValueOnRotation
MULTIPLE_INSTANCES_NODE=multipleInstances
NAME_ATTRIBUTE=name
NAME_NODE=name
NAMESPACE_NODE=namespace
NAMESPACE_SEPARATOR=.
NETWORK_ADAPTER_NODE=networkAdapter
OBJECT_NODE=object
OBJECTS_NODE=objects
OPACITY_NODE=opacity
ORIGIN_NODE=origin
OUTER_RADIUS_NODE=outerRadius
PAGE_NODE=page
PATH_NODE=path
PERSISTENT_NODE=persistent
POINTING_OFFSET_NODE=pointingOffset
PREFETCH_NODE=prefetch
PRESELECT_NODE=preselect
PROPERTY_NODE=property
PROVIDER_NODE=provider
PROVIDERS_NODE=providers
RADIUS_NODE=radius
ACTIVATE_WITH_HANDLE_NODE=activateWithHandle
RAMPING_TIME_NODE=rampingTime
RECEIVER_NODE=receiver
RECEIVERS_NODE=receivers
REFERENCE_NODE=reference
RELATIVE_NODE=relative
REPEAT_ATTRIBUTE=repeat
REVERSING_NODE=reversing
RGB_COLOUR_NODE=rgb
ROTATE_WITH_HANDLE_NODE=rotateWithHandle
ROTATE_WITH_TETHER_NODE=rotateWithTether
ROTATION_DIRECTION_NODE=rotationDirection
SCALE_NODE=scale
SCREEN_ID_NODE=screenId
SECTION_NODE=section
SECTIONS_NODE=sections
SELECTED_ELEMENT=selected
SHADE_ATTRIBUTE=shade
SHADE_BRIGHTER_VALUE=brighter
SHADE_DARKER_VALUE=darker
SHAPE_NODE=shape
SOUND_NODE=sound
SOUND_BASE64_NODE=soundBase64
SOUND_NODE=sound
SPACE=\
SPIN_ON_CORONA_CENTRE_NODE=spinOnCoronaCentre
SQUARE_SIZE_NODE=squareSize
STAGE_ID_NODE=stageId
STAGE_NODE=stage
STAGE_POSITION_NODE=stagePosition
STAGESET_NODE=stageSet
START_ANGLE_NODE=startAngle
START_NODE=start
STATE_NODE=state
STEP_SIZE_NODE=stepSize
STOP_NODE=stop
STROKE_COLOUR_ELEMENT=strokeColour
STROKE_WIDTH_NODE=strokeWidth
STYLE_NODE=style
TEXT_NODE=text
TITLE_NODE=title
BEGIN_NODE=begin
END_NODE=end
STYLERULE_NODE=rule
STYLESHEET_NODE=styleSheet
SYNCHRONOUS_ZOOM_NODE=synchronousZoom
TANGIBLE_NODE=tangible
TEMPLATE_NODE=template
TEMPLATES_NODE=templates
TETHER_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.tether.builder
CONNECTIONS_NODE=connections
TETHERS_NODE=tethers
TETHER_NODE=tether
TETHERABLE_NODE=tetherable
ORIGIN_NODE=origin
ENDING_NODE=ending
DISTANCE_NODE=distance
DRAGGABLE_NODE=draggable
EXCLUSIVE_NODE=exclusive
ROTATE_WITH_TETHER_NODE=rotateWithTether
PROVIDERS_NODE=providers
PROVIDER_NODE=provider
RECEIVERS_NODE=receivers
RECEIVER_NODE=receiver
DISPLAY_TIME_NODE=displayTime
FADE_IN_TIME_NODE=fadeInTime
FADE_OUT_TIME_NODE=fadeOutTime
FADE_WITH_HANDLE_NODE=fadeWithHandle
INDEX_NODE=index
INNER_RADIUS_NODE=innerRadius
OUTER_RADIUS_NODE=outerRadius
START_ANGLE_NODE=startAngle
ARC_SPAN_NODE=arcSpan
GAP_NODE=gap
RELATIVE_NODE=relative
REFERENCE_NODE=reference
STROKE_WIDTH_NODE=strokeWidth
FILL_COLOUR_ELEMENT=fillColour
TETHERS_NODE=tethers
TEXT_COLOUR_ELEMENT=textColour
STROKE_COLOUR_ELEMENT=strokeColour
LABEL_COLOUR_ELEMENT=labelColour
FACE_COLOUR_ELEMENT=faceColour
BEZEL_COLOUR_ELEMENT=bezelColour
TEXT_NODE=text
TICKMARK_COLOUR_NODE=tickMarkColour
SELECTED_ELEMENT=selected
DESELECTED_ELEMENT=deselected
ABOVE_ELEMENT=above
BELOW_ELEMENT=below
RGB_COLOUR_NODE=rgb
PERSISTENT_NODE=persistent
PRESELECT_NODE=preselect
TEMPLATES_NODE=templates
TEMPLATE_NODE=template
TITLE_NODE=title
TOUCHABLE_NODE=touchable
TRIANGLE_SIZE_NODE=triangleSize
TRIGGER_CONDITION_NODE=triggerCondition
TRIGGER_ELEMENT=trigger
TRIGGERS_NODE=triggers
TYPE_NODE=type
UNIT_NODE=unit
UPPER_BOUND_NODE=upperBound
UPPER_BOUND_VARIABLE_NODE=upperBoundVariable
UPPER_STOP_ANGLE_NODE=upperStopAngle
VARIABLE_NODE=variable
VARIABLES_NODE=variables
VOLUME_NODE=volume
WIDGET_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.widget.builder
WIDTH_NODE=width
X_NODE=x
Y_NODE=y
Z_NODE=z
ZOOM_LEVEL_NODE=zoomLevel
SYNCHRONOUS_ZOOM_NODE=synchronousZoom
CENTER_ON_ZOOM_NODE=centerOnZoom
ASSIGNABLE_NODE=assignable
CORNER_RADIUS_NODE=cornerRadius
CIRCLE_SIZE_NODE=circleSize
SQUARE_SIZE_NODE=squareSize
TRIANGLE_SIZE_NODE=triangleSize
OPACITY_NODE=opacity
LABEL_SHAPE_NODE=labelShape
NAME_ATTRIBUTE=name
REPEAT_ATTRIBUTE=repeat
INDEX_ATTRIBUTE=index
COUNT_ATTRIBUTE=count
SHADE_ATTRIBUTE=shade
SHADE_DARKER_VALUE=darker
SHADE_BRIGHTER_VALUE=brighter
MAGNIFIER_SHAPE_NODE=magnifierShape
MAGNIFICATION_NODE=magnification
ANIMATED_PROPERTIES_ELEMENT=animatedProperties
ANIMATED_PROPERTY_ELEMENT=animatedProperty
PROPERTY_NODE=property
LOOPING_NODE=looping
REVERSING_NODE=reversing
DURATION_NODE=duration
DELAY_NODE=delay
MARKER_NODE=marker
MARKERS_NODE=markers
MARKER_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.marker.builder
POINTING_OFFSET_NODE=pointingOffset
STYLESHEET_NODE=styleSheet
STYLERULE_NODE=rule
PATH_NODE=path
PAGE_NODE=page
MEDIA_NODE=media
LOCATION_NODE=location
VOLUME_NODE=volume
PREFETCH_NODE=prefetch
STAGESET_NODE=stageSet
STAGE_NODE=stage
STAGE_ID_NODE=stageId
SCREEN_ID_NODE=screenId
BOUNDS_NODE=bounds
FULLSCREEN_NODE=fullScreen
STAGE_POSITION_NODE=stagePosition
TANGIBLE_NODE=tangible
MULTIPLE_INSTANCES_NODE=multipleInstances
ZOOM_LEVEL_NODE=zoomLevel
\ No newline at end of file
......@@ -8,6 +8,7 @@ PRESELECT_ID_PROPERTY=PreselectId
NUMBER_OF_VARIABLES_PROPERTY=NumberOfVariables
VARIABLE_ID_PROPERTY=VariableId
VARIABLE_NAME_PROPERTY=VariableName
VARIABLE_DISPLAY_NAME_PROPERTY=VariableDisplayName
VARIABLE_UNIT_PROPERTY=VariableUnit;
VARIABLE_MINVALUE_PROPERTY=VariableMinValue;
VARIABLE_MAXVALUE_PROPERTY=VariableMaxValue;
......
......@@ -16,7 +16,6 @@
*/
package lu.list.itis.dkd.tui.bootstrapping;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Externalization;
import org.jdom2.Document;
......@@ -29,20 +28,38 @@ import java.util.List;
import java.util.Map;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class TemplateBootstrapper {
private static final Logger logger = LoggerFactory.getLogger(TemplateBootstrapper.class.getSimpleName());
private static final Logger LOGGER = LoggerFactory.getLogger(TemplateBootstrapper.class.getSimpleName());
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
// ***************************************************************************
// ---------------------------------------------------------------------------
private TemplateBootstrapper() {}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param document
* @return
* @throws BuildException
*/
public static Map<String, Element> loadTemplates(Document document) throws BuildException {
// ---------------------------------------------------------------------------
public static Map<String, Element> loadTemplates(Document document) {
Element rootNode = document.getRootElement();
Map<String, Element> loadedTemplates = new HashMap<>();
List<Element> templatesNodes = rootNode.getChildren(Externalization.TEMPLATES_NODE);
......
......@@ -14,21 +14,23 @@
* You should have received a copy of the GNU Lesser General Public License along with TULIP. If
* not, see <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.widget.corona;
package lu.list.itis.dkd.tui.event;
import lu.list.itis.dkd.tui.widget.corona.builder.BaseIndexedCoronaBuilder;
import lu.list.itis.dkd.tui.widget.corona.SelectableCorona;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
* @author Nico Mack [nico.mack@list.lu]
* @since 2.5
* @version 2.5.0
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public abstract class IndexedCorona extends SelectableCorona {
protected int index;
public class SelectionEvent {
private SelectableCorona source;
private boolean selected;
// ---------------------------------------------------------------------------
// ***************************************************************************
......@@ -36,47 +38,42 @@ public abstract class IndexedCorona extends SelectableCorona {
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param builder
* @param source
* @param selectionState
*/
// ---------------------------------------------------------------------------
public IndexedCorona(BaseIndexedCoronaBuilder<?> builder) {
super(builder);
index = builder.index;
public SelectionEvent(SelectableCorona source, boolean selectionState) {
this.source = source;
this.selected = selectionState;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* Copy constructor to clone corona.
* Simple getter method for source.
*
* @param original
* specifies the original corona to create an exact copy from.
* @return The value of source.
*/
// ---------------------------------------------------------------------------
public IndexedCorona(IndexedCorona original) {
super(original);
index = original.index;
public SelectableCorona getSource() {
return source;
}
// ---------------------------------------------------------------------------
/**
* Getter for the unique index assigned to this sector
* Simple getter method for selected.
*
* @return the unique index assigned to this sector
* @return The value of selected.
*/
// ---------------------------------------------------------------------------
public int getIndex() {
return index;
public boolean isSelected() {
return selected;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * End of Class
// ***************************************************************************
// ---------------------------------------------------------------------------
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. 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 <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.event;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
public interface SelectionListener {
public void selectionStateChanged(SelectionEvent event);
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2017. 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 <http://www.gnu.org/licenses/lgpl-3.0.html>.
*/
package lu.list.itis.dkd.tui.utility;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
@Retention(RUNTIME)
@Target(METHOD)
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
public @interface AnimatedProperty {
String property() default "";
}
\ No newline at end of file
......@@ -55,6 +55,14 @@ public class Point extends Float implements KdComparator<Point> {
private float angle;
private float rotationDirection;
// ***************************************************************************
// * Constants *
// ***************************************************************************
protected static final double PI_HALF = Math.PI / 2;
protected static final double THREE_PI_HALF = 1.5 * Math.PI;
protected static final double TWO_PI = 2 * Math.PI;
private static final Logger logger = LoggerFactory.getLogger(Point.class.getSimpleName());
......@@ -321,6 +329,21 @@ public class Point extends Float implements KdComparator<Point> {
this.state = state;
}
/**
* @param rawAngle
* @return
*/
public static float moduloTwoPi(float rawAngle) {
double angle = rawAngle % TWO_PI;
if (angle < 0)
angle += TWO_PI;
return (float) angle;
}
/**
* 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
......@@ -516,15 +539,27 @@ public class Point extends Float implements KdComparator<Point> {
}
double lastRotation = angle - point.getAngle();
if (lastRotation > 1.5 * Math.PI) {
lastRotation -= 2 * Math.PI;
} else if (lastRotation < -1.5 * Math.PI) {
lastRotation += 2 * Math.PI;
if (lastRotation > THREE_PI_HALF) {
lastRotation -= TWO_PI;
} else if (lastRotation < -THREE_PI_HALF) {
lastRotation += TWO_PI;
}
return new Point((float) (getX() - point.getX()), (float) (getY() - point.getY()), (float) lastRotation, rotationDirection);
}
/**
* computes the relative angle between this point and the specified one.
*
* @param point
* specifies the point to determine the relative angle from.
* @return
*/
public double relativeAngle(Point point) {
double reference = Math.atan2(this.y, this.x);
return Math.atan2(point.y, point.x) - reference;
}
/** {@inheritDoc} */
@Override
public int getDimensions() {
......
......@@ -16,6 +16,7 @@ public class Templating extends NLS {
public static String NUMBER_OF_VARIABLES_PROPERTY;
public static String VARIABLE_ID_PROPERTY;
public static String VARIABLE_NAME_PROPERTY;
public static String VARIABLE_DISPLAY_NAME_PROPERTY;
public static String VARIABLE_UNIT_PROPERTY;
public static String VARIABLE_MINVALUE_PROPERTY;
public static String VARIABLE_MAXVALUE_PROPERTY;
......
......@@ -27,6 +27,8 @@ import lu.list.itis.dkd.tui.network.adapter.NetworkAdapter;
import lu.list.itis.dkd.tui.utility.Point;
import lu.list.itis.dkd.tui.widget.builder.BaseBuilder;
import lu.list.itis.dkd.tui.widget.corona.Corona;
import lu.list.itis.dkd.tui.widget.touch.TouchEvent;
import lu.list.itis.dkd.tui.widget.touch.Touchable;
import com.google.common.collect.Multimap;
import com.google.common.collect.Ordering;
......@@ -58,7 +60,7 @@ import java.util.Set;
// ***************************************************************************
@NonNullByDefault
public class BaseWidget {
public class BaseWidget implements Touchable {
/** Specifies the ID of the stage the widget is to be presented on. */
protected int stageId;
/** The visual components to display as part of the widget. It's background. */
......@@ -84,6 +86,8 @@ public class BaseWidget {
@Nullable
protected Area clippingRegion;
protected Boolean isTouchable = null;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s)
......@@ -497,17 +501,83 @@ public class BaseWidget {
return this.clippingRegion;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public boolean isTouchable() {
boolean touchableCoronaFound = false;
if (this.isTouchable == null) {
List<Touchable> touchables = this.getCoronas(Touchable.class);
for (Touchable touchable : touchables) {
touchableCoronaFound |= touchable.isTouchable();
}
this.isTouchable = Boolean.valueOf(touchableCoronaFound);
}
return isTouchable;
}
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
// ---------------------------------------------------------------------------
@Override
public boolean touched(TouchEvent event) {
boolean touched = false;
if (this.isTouchable()) {
List<Touchable> touchables = this.getCoronas(Touchable.class);
for (Touchable touchable : touchables) {
touched |= touchable.touched(event);
}
}
return touched;
}
// ---------------------------------------------------------------------------