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 c5dea413 authored by Eric Tobias's avatar Eric Tobias

Changed how the ConditionalCorona is handed its triggers by splitting...

Changed how the ConditionalCorona is handed its triggers by splitting declaration and initialization phases.
parent 7cc71b5c
......@@ -62,9 +62,6 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
private final double baseValue;
/** Whether the value held by the widget is to be modified on a rotation of a handle. */
private boolean modifyValueOnRotation = false;
/** Whether the value is dynamic, that is if it changes and is not simply triggered. */
private boolean dynamic = true;
private double stepAngle;
private double steps;
......@@ -87,7 +84,6 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
this.stepSize = builder.stepSize;
this.variable = builder.variable;
this.modifyValueOnRotation = builder.modifyValueOnRotation;
// this.dynamic = builder.dynamic;
/**
* Remember the base value of the variable and then set it to 0d as the value should be nill
......@@ -111,11 +107,9 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
public void actionDrop(TangibleObject tangibleObject) {
super.actionDrop(tangibleObject);
// if (!dynamic) {
if (!modifyValueOnRotation) {
getVariable().setValue(baseValue);
}
// }
}
@Override
......
......@@ -55,6 +55,7 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
/** Whether the value held by the widget is to be modified on a rotation of a handle. */
public boolean modifyValueOnRotation = false;
/** Whether the value is dynamic, that is if it changes and is not simply triggered. */
@Deprecated
public boolean dynamic;
/**
......
......@@ -27,34 +27,25 @@ import java.util.LinkedHashSet;
/**
* @author Eric Tobias [eric.tobias@list.lu]
* @since 1.3
* @version 1.3.1
* @version 1.3.2
*/
@NonNullByDefault
public class ConditionalCorona extends Corona {
/** The equation that will evaluate the trigger condition. */
private Equation trigger;
/** All variables that will be needed to evaluate the trigger condition. */
private LinkedHashSet<Variable> variables = new LinkedHashSet<>();
private LinkedHashSet<Variable> variables;
/** Variable used to easily gather the output from the trigger equation. */
private BooleanVariable triggerVariable = new BooleanVariable("Trigger", false); //$NON-NLS-1$
/**
* The list of trigger variables by their name. These are placeholders and will be used to
* populate the list of variables the instance will react to once the overarching equation
* system has been initialized, thus making the variable instances globally available.
*/
private LinkedHashSet<String> triggers = new LinkedHashSet<>();
private java.awt.Image image;
// /**
// * Predicate used to filter variables and check whether they contain <code>true</code> as a
// * value if they are {@link BooleanVariable} instances in the first place. If the variable
// does
// * not contain true or isn't a {@link BooleanVariable} instance, the predicate will return
// * <code>false</code>.
// */
// private Predicate<Variable> triggerPredicate = new Predicate<Variable>() {
// @Override
// public boolean apply(Variable variable) {
// return variable instanceof BooleanVariable ? ((BooleanVariable) variable).getValue() : false;
// }
// };
/**
* @param builder
*
......@@ -64,6 +55,7 @@ public class ConditionalCorona extends Corona {
this.trigger = builder.trigger;
this.triggerVariable = builder.triggerVariable;
this.triggers = builder.triggers;
this.variables = builder.variables;
this.image = builder.image;
}
......@@ -116,4 +108,13 @@ public class ConditionalCorona extends Corona {
public void addVariable(Variable variable) {
variables.add(variable);
}
/**
* Method used to retrieve the set of triggers the corona will react to.
*
* @return The set of triggers, respectively their name.
*/
public LinkedHashSet<String> getTriggers() {
return triggers;
}
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ import javax.script.ScriptEngineManager;
*
* @author Eric Tobias [eric.tobias@list.lu]
* @since 1.3
* @version 1.3.1
* @version 1.3.2
* @param <B>
* The concrete builder.
*/
......@@ -52,6 +52,12 @@ public abstract class BaseConditionalCoronaBuilder<B extends BaseConditionalCoro
public java.awt.Image image;
public int width;
public int height;
/**
* The list of trigger variables by their name. These are placeholders and will be used to
* populate the list of variables the instance will react to once the overarching equation
* system has been initialized, thus making the variable instances globally available.
*/
public LinkedHashSet<String> triggers = new LinkedHashSet<>();
/**
* Constructor initializing all local fields.
......@@ -68,6 +74,11 @@ public abstract class BaseConditionalCoronaBuilder<B extends BaseConditionalCoro
super(element);
final String triggerCondition = element.getChildText(Externalization.TRIGGER_CONDITION_NODE);
if (null != element.getChild(Externalization.TRIGGERS_NODE)) {
element.getChild(Externalization.TRIGGERS_NODE).getChildren().forEach(c -> triggers.add(c.getText()));
}
trigger = new Equation(new Mapping(variables, triggerVariable), triggerCondition);
trigger.setScriptEngine(new ScriptEngineManager().getEngineByName("js")); //$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