Commit 6a0ee62f authored by Nathan Bonnemberger's avatar Nathan Bonnemberger
Browse files

Urban_planning_scenario: PositionWidget operational

parent 847d09e0
......@@ -33,6 +33,8 @@ bootstrapping.root = circuit_scenario.xml
# Properties for the equation system
executor.class = lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor
numeric.variable.class = lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
spatial.variable.class = lu.list.itis.dkd.tui.cps.variable.SpatialVariable
equation.system = circuit_scenario.xml
scenario.description = circuit_scenario.xml
......
......@@ -35,3 +35,4 @@ bootstrapping.root = light_scenario.xml
executor.class = lu.list.itis.dkd.tui.cps.system.executor.JavascriptExecutor
numeric.variable.class = lu.list.itis.dkd.tui.cps.variable.tangible.TangibleNumericalVariable
logic.variable.class = lu.list.itis.dkd.tui.cps.variable.BooleanVariable
spatial.variable.class = lu.list.itis.dkd.tui.cps.variable.SpatialVariable
......@@ -28,7 +28,7 @@ import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Valrie Maquil
* @author Valrie Maquil
*
*/
import java.io.File;
......@@ -47,7 +47,6 @@ public class FileChooser extends JPanel
implements ActionListener {
/** */
private static final long serialVersionUID = 1L;
static private final String newline = "\n"; //$NON-NLS-1$
JButton openButton, startButton;
JLabel log;
JFileChooser fc;
......
......@@ -44,6 +44,7 @@ import com.google.common.base.Preconditions;
import java.io.File;
import java.util.Map;
import java.util.Properties;
import java.util.logging.Logger;
/**
* Class used to run a tangible scenario. It uses bootstrappers to initialize all the necessary
......@@ -146,10 +147,17 @@ public class Scenario {
}
if (widget instanceof PositionWidget) {
final SpatialVariable variable = retrieveSpatialVariableByName(((PositionWidget) widget).getVariable().getName());
((PositionWidget) widget).setVariable(variable);
for (final ConditionalCorona corona : widget.getCoronas(ConditionalCorona.class)) {
corona.getTriggers().forEach(trigger -> corona.addVariable(retrieveVariableByName(trigger)));
if (variable.getValue() != null) {
((PositionWidget) widget).setVariable(variable);
for (final ConditionalCorona corona : widget.getCoronas(ConditionalCorona.class)) {
corona.getTriggers().forEach(trigger -> corona.addVariable(retrieveVariableByName(trigger)));
}
} else {
final Logger LOGGER = Logger.getLogger(Logger.class.getName());
LOGGER.info("Logger Name: " + LOGGER.getName());
LOGGER.warning("populateVariables() error :: value of SpatialVariable instance 'variable' is null");
LOGGER.info("variable " + ((PositionWidget) widget).getVariable().getName() + "is not an instance of inputs or ouputs or has null value");
((PositionWidget) widget).setVariable(variable);
}
}
}
......
......@@ -19,8 +19,8 @@
<modifyValueOnTranslation>true</modifyValueOnTranslation>
<leftMostBound>0.0</leftMostBound>
<rightMostBound>1.0</rightMostBound>
<downMostBound>0.0</downMostBound>
<upMostBound>1.0</upMostBound>
<downMostBound>1.0</downMostBound>
<upMostBound>0.0</upMostBound>
<handles>
<handle>1</handle>
</handles>
......@@ -28,29 +28,13 @@
<name>pos</name>
<type>spatial</type>
<position>
<x>0</x>
<y>0</y>
<z>0</z>
<state>ScreenCoordinates</state>
<x>0.5</x>
<y>0.5</y>
<z>10</z>
<state>CameraCoordinates</state>
</position>
</variable>
<coronas>
<!-- Template TextBox -->
<corona>
<handle>1</handle> <!-- Marker ID: needs to be the same for a same widget -->
<type>TextBox</type>
<drawPriority>275</drawPriority> <!-- needs to be different for each corona -->
<rotateWithHandle>false</rotateWithHandle> <!-- if true it rotates with the object -->
<lineWidth>200</lineWidth> <!-- width of one line in pixel -->
<font>Arial-20</font> <!-- Font and size -->
<centred>true</centred> <!-- if true is centered -->
<text></text> <!-- insert here text it should show some -->
<assignable>true</assignable> <!-- if true it shows the value of the variable, otherwise it shows the content of the "text" field -->
<initialTranslation>
<x>-2</x><y>51</y><z>0</z> <!-- in pixel -->
<state>ScreenCoordinates</state>
</initialTranslation>
</corona>
<corona>
<handle>1</handle> <!-- Marker ID: needs to be the same for a same widget -->
<type>ConditionalCorona</type>
......@@ -59,13 +43,14 @@
<image>assets/green_zone.jpg</image> <!-- The image file name -->
<spinOnCoronaCentre>true</spinOnCoronaCentre>
<triggers>
<trigger>pos</trigger> <!-- insert each variable you use for the trigger condition -->
<trigger>x</trigger> <!-- insert each variable you use for the trigger condition -->
<trigger>y</trigger> <!-- insert each variable you use for the trigger condition -->
</triggers>
<initialTranslation>
<x>-158</x><y>-141</y><z>0</z> <!-- in pixel -->
<state>ScreenCoordinates</state>
</initialTranslation>
<triggerCondition>pos &gt; 0.5</triggerCondition> <!-- Condition: &gt; &lt; == != &amp;&amp; -->
<triggerCondition>(x &gt; 0.5) &amp;&amp; (y &gt; 0.5)</triggerCondition> <!-- Condition: &gt; &lt; == != &amp;&amp; -->
</corona>
</coronas>
</object>
......@@ -75,23 +60,50 @@
<system>
<outputs>
<output> <!-- copy for each of the output variables -->
<name>all</name> <!-- insert output variable name -->
<unit>px</unit> <!-- unit of the output variable -->
<name>x</name> <!-- insert output variable name -->
<unit></unit> <!-- unit of the output variable -->
<type>numeric</type>
<initial>0</initial>
</output>
<output> <!-- copy for each of the output variables -->
<name>y</name> <!-- insert output variable name -->
<unit></unit> <!-- unit of the output variable -->
<type>numeric</type>
<initial>0</initial>
</output>
</outputs>
<equations>
<equation> <!-- copy for each equation -->
<name>all</name> <!-- name of the equation -->
<invoke>pos + 0</invoke> <!-- equation -->
<name>x</name> <!-- name of the equation -->
<invoke>pos_x + 0</invoke> <!-- equation -->
<parameters>
<parameter> <!-- copy for each of the variables needed in the equation -->
<name>pos</name> <!-- insert variable name -->
<unit></unit> <!-- unit of the variable -->
<type>spatial</type>
<initial>0,0,0</initial>
</parameter>
</parameters>
<results>
<result>
<name>x</name> <!-- insert output variable name -->
</result>
</results>
</equation>
<equation> <!-- copy for each equation -->
<name>y</name> <!-- name of the equation -->
<invoke>pos_y + 0</invoke> <!-- equation -->
<parameters>
<parameter> <!-- copy for each of the variables needed in the equation -->
<name>pos</name> <!-- insert variable name -->
<unit></unit> <!-- unit of the variable -->
<type>spatial</type>
<initial>0,0,0</initial>
</parameter>
</parameters>
<results>
<result>
<name>all</name> <!-- insert output variable name -->
<name>y</name> <!-- insert output variable name -->
</result>
</results>
</equation>
......
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