Commit ae913517 authored by Nico Mack's avatar Nico Mack

Implemented TravelingShape Tether

parent b963d0f7
......@@ -118,6 +118,8 @@ ORIGIN_NODE=origin
OUTER_RADIUS_NODE=outerRadius
PAGE_NODE=page
PATH_NODE=path
PATH_WIDTH_NODE=pathWidth
PATH_COLOUR_NODE=pathColour
PERSISTENT_NODE=persistent
POINTING_OFFSET_NODE=pointingOffset
PREFETCH_NODE=prefetch
......
......@@ -116,6 +116,12 @@
<groupId>eu.hansolo</groupId>
<artifactId>SteelSeries</artifactId>
<version>3.9.30</version>
<exclusions>
<exclusion>
<groupId>com.github.insubstantial</groupId>
<artifactId>trident</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
......@@ -181,6 +187,11 @@
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
<dependency>
<groupId>org.pushingpixels</groupId>
<artifactId>trident</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
<repositories>
......
......@@ -153,6 +153,8 @@ public class Externalization extends NLS {
public static String OUTER_RADIUS_NODE;
public static String PAGE_NODE;
public static String PATH_NODE;
public static String PATH_WIDTH_NODE;
public static String PATH_COLOUR_NODE;
public static String PERSISTENT_NODE;
public static String POINTING_OFFSET_NODE;
public static String PREFETCH_NODE;
......
......@@ -22,9 +22,11 @@ package lu.list.itis.dkd.tui.widget;
import lu.list.itis.dkd.dbc.annotation.NonNullByDefault;
import lu.list.itis.dkd.tui.content.InformationProvider;
import lu.list.itis.dkd.tui.content.InformationReceiver;
import lu.list.itis.dkd.tui.widget.builder.BaseInfoBuilder;
import lu.list.itis.dkd.tui.widget.builder.InfoWidgetBuilder;
import lu.list.itis.dkd.tui.widget.corona.HtmlBox;
import lu.list.itis.dkd.tui.widget.tether.Tether;
import lu.list.itis.dkd.tui.widget.tether.Tetherable;
import lu.list.itis.dkd.tui.widget.tether.listener.TetherEvent;
import lu.list.itis.dkd.tui.widget.tether.listener.TetherListener;
......@@ -102,6 +104,11 @@ public class InfoWidget extends TetherableWidget implements TetherListener {
if (target instanceof InformationProvider) {
Object info = ((InformationProvider<?>) target).getInformation();
if (info != null) {
Tether tether = this.getTetherFor(target);
if (tether instanceof InformationReceiver) {
((InformationReceiver) tether).setInformation(info);
}
for (HtmlBox corona : getCoronas(HtmlBox.class)) {
corona.setInformation(info.toString());
corona.setActive(true);
......
......@@ -19,7 +19,9 @@ package lu.list.itis.dkd.tui.widget.animation;
import org.pushingpixels.trident.Timeline;
import org.pushingpixels.trident.Timeline.RepeatBehavior;
import org.pushingpixels.trident.Timeline.TimelineState;
import org.pushingpixels.trident.TimelinePropertyBuilder;
import org.pushingpixels.trident.callback.TimelineCallback;
import org.pushingpixels.trident.interpolator.PropertyInterpolator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -51,6 +53,7 @@ public class AnimationProperty<T> implements TimelineCallback {
private ListIterator<Integer> keyFrameIterator;
private Integer nextKeyFrame;
private Direction direction;
private PropertyInterpolator<T> interpolator;
// ***************************************************************************
// * Constants *
......@@ -98,6 +101,29 @@ public class AnimationProperty<T> implements TimelineCallback {
direction = Direction.NONE;
}
// ---------------------------------------------------------------------------
/**
* Creates a new AnimationProperty instance
*
* @param property
* specifies the name of the property to animate
* @param start
* specifies the start (initial) value for the animated property
* @param end
* specifies the end (target) value for the animated property
* @param interpolator
*/
// ---------------------------------------------------------------------------
public AnimationProperty(String property, T start, T end, PropertyInterpolator<T> interpolator) {
this.setProperty(property);
this.setStart(start);
this.setEnd(end);
this.listeners = new AnimationEventSource();
this.direction = Direction.NONE;
this.interpolator = interpolator;
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
......@@ -325,9 +351,17 @@ public class AnimationProperty<T> implements TimelineCallback {
*/
// ---------------------------------------------------------------------------
@SuppressWarnings("unchecked")
public void setAnimatedObject(Object animated) {
timeline = new Timeline(animated);
timeline.addPropertyToInterpolate(property, start, end);
TimelinePropertyBuilder<Object> timelineProperty = Timeline.property(property).from(start).to(end);
if (this.interpolator != null) {
timelineProperty.interpolatedWith((PropertyInterpolator<Object>) this.interpolator);
}
timeline.addPropertyToInterpolate(timelineProperty);
timeline.setDuration(duration);
timeline.setInitialDelay(delay);
timeline.addCallback(this);
......
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. 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.widget.animation;
import lu.list.itis.dkd.tui.utility.Point;
import org.pushingpixels.trident.interpolator.PropertyInterpolator;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class PointInterpolator implements PropertyInterpolator<Point> {
/** {@inheritDoc} */
@Override
public Class getBasePropertyClass() {
return Point.class;
}
/** {@inheritDoc} */
@Override
public Point interpolate(Point from, Point to, float timelinePosition) {
float x = from.x + (to.x - from.x) * timelinePosition;
float y = from.y + (to.y - from.y) * timelinePosition;
return new Point(x, y, from.getAngle(), from.getState().getClass());
}
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. 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.widget.tether.builder;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapContext;
import lu.list.itis.dkd.tui.bootstrapping.BootstrappingUtils;
import lu.list.itis.dkd.tui.bootstrapping.ShapeBootstrapper;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Externalization;
import lu.list.itis.dkd.tui.widget.tether.TravelingShape;
import org.jdom2.Element;
import java.awt.Color;
import java.awt.Shape;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
* @param <B>
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public abstract class BaseTravelingShapeBuilder<B extends BaseTravelingShapeBuilder<B>> extends InformationFeedBuilder<B> {
public int pathWidth;
public Color pathColour;
public Shape shape;
public Color fillColour;
public Color strokeColour;
public int strokeWidth;
public long duration;
public boolean reversing;
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* 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 BaseTravelingShapeBuilder(Element rootElement) throws BuildException {
super(rootElement);
this.buildFromBootstrap(rootElement, null, null);
}
// ---------------------------------------------------------------------------
/**
* 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.
* @param context
* @param callback
* @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 BaseTravelingShapeBuilder(Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
super(rootElement, context, callback);
this.buildFromBootstrap(rootElement, context, callback);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Primitives *
// ***************************************************************************
// ---------------------------------------------------------------------------
private void buildFromBootstrap(Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
shape = ShapeBootstrapper.getShape(rootElement.getChild(Externalization.SHAPE_NODE), context, callback);
pathWidth = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.PATH_WIDTH_NODE, BootstrappingUtils.OPTIONAL, 0, context);
pathColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.PATH_COLOUR_NODE, BootstrappingUtils.OPTIONAL, null, context);
fillColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.FILL_COLOUR_NODE, BootstrappingUtils.OPTIONAL, Color.GRAY, context);
strokeWidth = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.STROKE_WIDTH_NODE, BootstrappingUtils.OPTIONAL, 0, context);
strokeColour = BootstrappingUtils.getContentAsColour(rootElement, Externalization.STROKE_COLOUR_ELEMENT, BootstrappingUtils.OPTIONAL, null, context);
duration = BootstrappingUtils.getContentAsInteger(rootElement, Externalization.DURATION_NODE, BootstrappingUtils.OPTIONAL, 1000, context);
reversing = BootstrappingUtils.getContentAsBoolean(rootElement, Externalization.REVERSING_NODE, BootstrappingUtils.OPTIONAL, Boolean.FALSE, context);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body *
// ***************************************************************************
// ---------------------------------------------------------------------------
@Override
public abstract TravelingShape<?> build() throws BuildException;
}
/**
* Copyright Luxembourg Institute of Science and Technology, 2018. 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.widget.tether.builder;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapCallback;
import lu.list.itis.dkd.tui.bootstrapping.BootstrapContext;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.widget.tether.TravelingShape;
import org.jdom2.Element;
/**
* @author mack
* @since [major].[minor]
* @version [major].[minor].[micro]
*/
// ***************************************************************************
// * Class Definition and Members *
// ***************************************************************************
public class TravelingShapeBuilder extends BaseTravelingShapeBuilder<TravelingShapeBuilder> {
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Constructor(s) *
// ***************************************************************************
// ---------------------------------------------------------------------------
/**
* @param rootElement
* @throws BuildException
*/
// ---------------------------------------------------------------------------
public TravelingShapeBuilder(Element rootElement) throws BuildException {
super(rootElement);
}
// ---------------------------------------------------------------------------
/**
* @param rootElement
* @param context
* @param callback
* @throws BuildException
*/
// ---------------------------------------------------------------------------
public TravelingShapeBuilder(Element rootElement, BootstrapContext context, BootstrapCallback callback) throws BuildException {
super(rootElement, context, callback);
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Bodx *
// ***************************************************************************
// ---------------------------------------------------------------------------
/** {@inheritDoc} */
@Override
public TravelingShape<?> build() throws BuildException {
return new TravelingShape<>(this);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment