Dear users, Please note that, from Monday, August 16, 2019, RSA keys shorter than 2048bit will no longer be accepted for security reasons. Please update your keys as needed before this date. If you need assistance with regard to this process, please contact sia@list.lu

Thank you for your understanding.

Commit d012f19c authored by Nico Mack's avatar Nico Mack

Activated Interactions support for widgets

parent 264c6d34
......@@ -42,8 +42,8 @@ CURSORS_NODE=cursors
DEFAULT_NODE=default
DEFINING_SHAPE_NODE=definingShape
DELAY_NODE=delay
DELEGATE=delegate
DELEGATES=delegates
DELEGATE_NODE=delegate
DELEGATES_NODE=delegates
DELEGATE_BUILDER_NAMESPACE=lu.list.itis.dkd.tui.event.interaction.delegate.builder
DESCRIPTION_NODE=description
DESELECTED_ELEMENT=deselected
......
......@@ -170,7 +170,7 @@ public class InteractionBootstrapper {
Element delegatesNode = interactionNode.getChild(Externalization.DELEGATES_NODE);
if (delegatesNode != null) {
List<Element> delegateNodes = templateNode.getChildren(Externalization.DELEGATE_NODE);
List<Element> delegateNodes = delegatesNode.getChildren(Externalization.DELEGATE_NODE);
List<Delegate> delegates = new ArrayList<>();
for (Element delegateNode : delegateNodes) {
delegates.add(buildDelegateFromElement(delegateNode, bootstrapContext, callback));
......
......@@ -23,8 +23,8 @@ import lu.list.itis.dkd.tui.event.interaction.delegate.builder.BaseMediaDelegate
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import javax.media.Controller;
import javax.media.Format;
......@@ -90,9 +90,11 @@ public class AudioDelegate extends MediaDelegate implements Playable {
// ---------------------------------------------------------------------------
private void setupFromProperties() {
File mediaFile = new File(this.baseUrl.toString(), this.media);
StringBuilder urlBuilder = new StringBuilder(this.baseUrl.toString());
urlBuilder.append(this.media);
try {
MediaLocator locator = new MediaLocator(mediaFile.toURI().toURL());
URL mediaUrl = new URL(urlBuilder.toString());
MediaLocator locator = new MediaLocator(mediaUrl);
this.player = Manager.createPlayer(locator);
this.player.realize();
} catch (NoPlayerException | IOException e) {
......@@ -117,7 +119,7 @@ public class AudioDelegate extends MediaDelegate implements Playable {
@Override
public void play() {
if ((this.player != null) && (player.getState() == Controller.Realized)) {
if (this.player != null) {
this.player.setMediaTime(BEGIN);
this.player.start();
}
......
......@@ -27,6 +27,7 @@ import lu.list.itis.dkd.tui.event.interaction.Handler;
import lu.list.itis.dkd.tui.event.interaction.Interaction;
import lu.list.itis.dkd.tui.event.interaction.InteractionManager;
import lu.list.itis.dkd.tui.event.interaction.Interactive;
import lu.list.itis.dkd.tui.event.interaction.delegate.Delegate;
import lu.list.itis.dkd.tui.network.adapter.NetworkAdapter;
import lu.list.itis.dkd.tui.utility.CoronaComparator;
import lu.list.itis.dkd.tui.utility.Point;
......@@ -123,8 +124,9 @@ public class BaseWidget implements Positionable, Touchable, Interactive {
coronas = builder.coronas;
positions = builder.positions;
this.setupInteractions(builder.interactions);
clippingRegion = new Area();
interactionManager = new InteractionManager();
onStage = false;
}
......@@ -271,6 +273,18 @@ public class BaseWidget implements Positionable, Touchable, Interactive {
}
}
// ---------------------------------------------------------------------------
private void setupInteractions(Multimap<Interaction, Delegate> interactions) {
interactionManager = new InteractionManager();
if ((interactions != null) && !interactions.isEmpty()) {
for (Entry<Interaction, Delegate> entry : interactions.entries()) {
interactionManager.registerHandlerFor(entry.getValue(), entry.getKey());
}
}
}
// ---------------------------------------------------------------------------
// ***************************************************************************
// * Class Body
......
......@@ -26,8 +26,11 @@ 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.CoronaBootstrapper;
import lu.list.itis.dkd.tui.bootstrapping.InteractionBootstrapper;
import lu.list.itis.dkd.tui.bootstrapping.NetworkAdapterBootstrapper;
import lu.list.itis.dkd.tui.bootstrapping.ShapeBootstrapper;
import lu.list.itis.dkd.tui.event.interaction.Interaction;
import lu.list.itis.dkd.tui.event.interaction.delegate.Delegate;
import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.network.adapter.NetworkAdapter;
import lu.list.itis.dkd.tui.utility.Externalization;
......@@ -71,6 +74,9 @@ public abstract class BaseBuilder<B extends BaseBuilder<B>> {
/** The {@link NetworkAdapter} the widget will use to communicate. */
@Nullable
public NetworkAdapter networkAdapter;
@Nullable
public Multimap<Interaction, Delegate> interactions;
/**
* The shape used to define the dimensions this widget uses to base all spatial computations on.
*/
......@@ -147,6 +153,11 @@ public abstract class BaseBuilder<B extends BaseBuilder<B>> {
networkAdapter = NetworkAdapterBootstrapper.getNetworkAdapter(rootElement.getChild(Externalization.NETWORK_ADAPTER_NODE));
coronas = CoronaBootstrapper.getCoronas(rootElement.getChild(Externalization.CORONAS_NODE), context, callback);
Element interactionsNode = rootElement.getChild(Externalization.INTERACTIONS_NODE);
if (interactionsNode != null) {
interactions = InteractionBootstrapper.buildInteractionFromTemplate(interactionsNode, context, callback);
}
}
/**
......
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