Commit b11c7280 authored by Valérie Maquil's avatar Valérie Maquil
Browse files

Merge branch 'dev' of https://git.list.lu/nui/TULIP-Scenario into dev

parents 94376ae4 b0d1c880
......@@ -105,7 +105,7 @@
<rotateWithHandle>false</rotateWithHandle>
<centred>true</centred>
<text>Banana</text>
</corona>
</corona>
</coronas>
<name>Hair Dryer</name>
<definingShape></definingShape>
......
......@@ -30,15 +30,10 @@
<artifactId>tulip</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>lu.list.itis.dkd.tui</groupId>
<artifactId>tulip-cps</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
......@@ -39,7 +39,6 @@ import com.google.common.base.Preconditions;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
* Class used to run a tangible scenario. It uses bootstrappers to initialize all the necessary
......@@ -53,8 +52,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class Scenario {
private Map<String, Scene> scenes;
private static ConcurrentHashMap<String, Variable> inputs;
private static ConcurrentHashMap<String, Variable> outputs;
private static Map<String, Variable> inputs;
private static Map<String, Variable> outputs;
private EquationSystemBuilder equationSystemBuilder;
private TangibleApplication tangibleApplication;
......@@ -71,7 +70,7 @@ public class Scenario {
*/
public Scenario() throws BuildException {
try {
equationSystemBuilder = new EquationSystemBuilder(PropertiesFetcher.fetchProperties());
equationSystemBuilder = new EquationSystemBuilder();
equationSystemBuilder.parseEquationFile(new File(PropertiesFetcher.fetchProperties().getProperty("equation.system"))); //$NON-NLS-1$
} catch (final EquationSystemException exception) {
throw new BuildException("The equation system for this scenario could not be built!", exception); //$NON-NLS-1$
......
......@@ -58,7 +58,7 @@ import javax.swing.ImageIcon;
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 1.0
* @version 1.0.1
* @version 1.0.2
*/
@NonNullByDefault
public class Scene extends Content {
......@@ -67,7 +67,7 @@ public class Scene extends Content {
/** All variables that will be needed to evaluate the trigger condition. */
private LinkedHashSet<Variable> variables = new LinkedHashSet<>();
/** Variable used to easily gather the output from the trigger equation. */
private BooleanVariable triggerVariable = new BooleanVariable("Trigger", "", false); //$NON-NLS-1$ //$NON-NLS-2$
private BooleanVariable triggerVariable = new BooleanVariable("Trigger", false); //$NON-NLS-1$
/** The image to show when painting. */
private ImageIcon scenery;
/** The sound to play when painting. */
......@@ -107,8 +107,8 @@ public class Scene extends Content {
trigger = new Equation(new Mapping(variables, triggerVariable), triggerCondition);
try {
final Element imageNode = element.getChild(Externalization.IMAGE_NODE);
if ((null != imageNode) && (imageNode.getText() != "")) {
final Element imageNode = element.getChild(Externalization.IMAGE_ELEMENT);
if (null != imageNode) {
scenery = new ImageIcon(ImageIO.read(new File(imageNode.getText())));
}
} catch (final NullPointerException npe) {
......@@ -148,10 +148,22 @@ public class Scene extends Content {
}
/**
* Simple getter to retrieve the trigger.
*
* @return The equation that servers as a trigger for this scene.
*/
public Equation getTrigger() {
return trigger;
}
/**
* Method called to evaluate the stored trigger. Returns the result as a boolean.
*
* @return <code>true</code> if value held by the result variable of the stored trigger
* evaluates to true, <code>false</code> otherwise.
* @see Equation#evaluate()
*/
public boolean evaluateTrigger() {
trigger.evaluate();
......
This diff is collapsed.
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