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

drawing priority works also with same values

parent ad878059
Pipeline #593 skipped
......@@ -2,18 +2,17 @@
<scenario>
<scenes>
<scene>
<name>Background</name>
<image>assets/correct.png</image>
<name>Test1</name>
<image>assets/test1.png</image>
<triggerCondition>true</triggerCondition>
<drawPriority>1</drawPriority>
</scene>
<scene>
<name>Background</name>
<image>assets/checkered_tablecloth.jpg</image>
<name>Test2</name>
<image>assets/test2.png</image>
<triggerCondition>true</triggerCondition>
<drawPriority>1</drawPriority>
</scene>
</scenes>
<objects>
......
......@@ -36,9 +36,9 @@ import lu.list.itis.dkd.tui.widget.BaseWidget;
import lu.list.itis.dkd.tui.widget.ValueWidget;
import com.google.common.base.Preconditions;
import com.google.common.collect.Multimap;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
/**
......@@ -51,7 +51,7 @@ import java.util.concurrent.ConcurrentHashMap;
*/
@NonNullByDefault
public class Scenario {
private Multimap<Integer, Scene> scenes;
private Map<String, Scene> scenes;
private static ConcurrentHashMap<String, Variable> inputs;
private static ConcurrentHashMap<String, Variable> outputs;
......
......@@ -25,10 +25,10 @@ import lu.list.itis.dkd.tui.TangibleContentManager;
import lu.list.itis.dkd.tui.content.Content;
import lu.list.itis.dkd.tui.event.ContentEvent;
import com.google.common.collect.Multimap;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
......@@ -41,7 +41,7 @@ import javax.script.ScriptEngineManager;
@NonNullByDefault
public class StageManager extends TangibleContentManager {
private static final StageManager INSTANCE = new StageManager();
private static Multimap<Integer, Scene> scenes;
private static Map<String, Scene> scenes;
private static ScriptEngine scriptEngine;
private StageManager() {
......@@ -60,7 +60,7 @@ public class StageManager extends TangibleContentManager {
/**
* @param _scenes
*/
public static void setScenes(Multimap<Integer, Scene> _scenes) {
public static void setScenes(Map<String, Scene> _scenes) {
scenes = _scenes;
scenes.values().forEach(scene -> scene.getTrigger().setScriptEngine(scriptEngine));
......@@ -79,14 +79,15 @@ public class StageManager extends TangibleContentManager {
@Override
public Collection<Content> getDrawableContents() {
final ArrayList<Content> drawableContents = new ArrayList<>();
for (final Integer key : scenes.keySet()) {
for (final Scene scene : scenes.get(key)) {
if (scene.evaluateTrigger()) {
drawableContents.add(scene);
}
for (final Scene scene : scenes.values()) {
if (scene.evaluateTrigger()) {
drawableContents.add(scene);
}
}
Collections.sort(drawableContents);
return drawableContents;
}
}
\ No newline at end of file
......@@ -25,9 +25,6 @@ import lu.list.itis.dkd.tui.scenario.Scene;
import lu.list.itis.dkd.tui.scenario.utility.Externalization;
import lu.list.itis.dkd.tui.utility.PropertiesFetcher;
import com.google.common.collect.Multimap;
import com.google.common.collect.TreeMultimap;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
......@@ -35,6 +32,8 @@ import org.jdom2.input.SAXBuilder;
import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -49,7 +48,7 @@ public class SceneBootstrapper {
private static final Logger logger = Logger.getLogger(SceneBootstrapper.class.getSimpleName());
private static Multimap<Integer, Scene> scenes = TreeMultimap.create();
private static Map<String, Scene> scenes = new TreeMap<>();
private static Document scenarioDescription;
/**
......@@ -76,7 +75,7 @@ public class SceneBootstrapper {
* @throws BuildException
* Thrown when the scenario description document could not be build.
*/
public static Multimap<Integer, Scene> getScenes() throws BuildException {
public static Map<String, Scene> getScenes() throws BuildException {
final SAXBuilder builder = new SAXBuilder();
final File xmlFile = new File(PropertiesFetcher.fetchProperties().getProperty(Externalization.SCENARIO_DESCRIPTION_PROPERTY));
......@@ -102,7 +101,8 @@ public class SceneBootstrapper {
private static void buildScene(Element element) {
try {
final Scene scene = new Scene(element);
scenes.put(scene.getDrawPriority(), scene);
scenes.put(scene.getIdentifier(), scene);
} catch (final BuildException e) {
Logger.getLogger(SceneBootstrapper.class.getSimpleName()).log(Level.SEVERE, "Could not build scene!", e); //$NON-NLS-1$
}
......
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