Commit b477678d authored by Nico Mack's avatar Nico Mack

Implementation of RExecutor

parent 69782303
......@@ -15,9 +15,11 @@ org.eclipse.jdt.core.compiler.annotation.nonnull=lu.tudor.ssi.kiss.dbc.annotatio
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=lu.tudor.ssi.kiss.dbc.annotation.NonNullByDefault
org.eclipse.jdt.core.compiler.annotation.nullable=lu.tudor.ssi.kiss.dbc.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
org.eclipse.jdt.core.compiler.problem.deadCode=warning
......@@ -26,6 +28,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=warning
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
......
......@@ -147,6 +147,16 @@
<version>2.26</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.lucarosellini.rJava</groupId>
<artifactId>JRI</artifactId>
<version>0.9-7</version>
</dependency>
<dependency>
<groupId>com.github.lucarosellini.rJava</groupId>
<artifactId>REngine</artifactId>
<version>0.9-7</version>
</dependency>
</dependencies>
<repositories>
......
......@@ -51,9 +51,9 @@ public class LinearEquationSystem extends System {
*
* @param lockToNesting
* Boolean indicating whether nested systems will have their inputs locked during
* computation. Doing so will result in a synchronous behaviour of the system while
* choosing <code>false</code> will have the nested systems evaluate their equations
* first, possibly propagating results to systems higher up in the nesting tree.
* computation. Doing so will result in a synchronous behaviour of the system while choosing
* <code>false</code> will have the nested systems evaluate their equations first, possibly
* propagating results to systems higher up in the nesting tree.
*/
public LinearEquationSystem(boolean lockToNesting) {
super();
......@@ -123,6 +123,26 @@ public class LinearEquationSystem extends System {
return equations;
}
/**
* Looks for an equation matching the given name.
*
* @param name
* specifies the name of the equation to look for.
* @return
*/
public Equation getEquation(String name) {
Equation matching = null;
for (Equation equation : equations.values()) {
if (name.equals(equation.getName())) {
matching = equation;
break;
}
}
return matching;
}
@Override
public String toString() {
return this.equations.toString();
......
......@@ -8,6 +8,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.CharArrayWriter;
import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.Properties;
......@@ -29,6 +31,27 @@ abstract public class Executor {
executionErrors = new CharArrayWriter();
}
protected static void addLibraryPath(String pathToAdd) throws Exception {
final Field usrPathsField = ClassLoader.class.getDeclaredField("usr_paths"); //$NON-NLS-1$
usrPathsField.setAccessible(true);
// get array of paths
final String[] paths = (String[]) usrPathsField.get(null);
// check if the path to add is already present
for (String path : paths) {
if (path.equals(pathToAdd)) {
return;
}
}
// add the new path
final String[] newPaths = Arrays.copyOf(paths, paths.length + 1);
newPaths[newPaths.length - 1] = pathToAdd;
usrPathsField.set(null, newPaths);
}
public String getExecutionErrors() {
return executionErrors.toString();
}
......
......@@ -84,6 +84,8 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
* angle.
*/
protected double dialAngle;
protected double dropAngle;
protected double initialAngle;
private double stepAngle;
private double lastAngle;
......@@ -161,12 +163,14 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
lastAngle = Double.NaN;
if (!modifyValueOnRotation) {
this.initialValue = getVariable().getValue();
getVariable().setValue(0d);
} else {
this.initialValue = getVariable().getValue();
}
// if (!modifyValueOnRotation) {
// this.initialValue = getVariable().getValue();
// getVariable().setValue(0d);
// } else {
// this.initialValue = getVariable().getValue();
// }
this.initialValue = (!Double.isNaN(variable.getInitialValue())) ? variable.getInitialValue() : 0d;
withStopAngles = !(Double.isNaN(lowerStopAngle) || Double.isNaN(upperStopAngle));
if (!multiTurn) {
......@@ -180,9 +184,12 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
private void updateFromBounds(double lower, double upper) {
if (withStopAngles) {
dialAngle = lowerStopAngle;
double steps = (upper - lower + 1) / stepSize;
stepAngle = (upperStopAngle - lowerStopAngle) / steps;
double sweep = upperStopAngle - lowerStopAngle;
double steps = 1 + (upper - lower) / stepSize;
stepAngle = sweep / steps;
initialAngle = lowerStopAngle + (sweep * (this.initialValue - lower) / (upper - lower));
dialAngle = initialAngle;
}
}
......@@ -283,52 +290,55 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
// ---------------------------------------------------------------------------
@Override
public void actionDrop(TangibleObject tangibleObject) {
super.actionDrop(tangibleObject);
public void actionDrop(TangibleObject tuioObject) {
if (!modifyValueOnRotation) {
dropAngle = AngleUtils.moduloTwoPi(tuioObject.getAngle());
dialAngle = (withStopAngles) ? this.initialAngle : dropAngle;
super.actionDrop(tuioObject);
if (!this.isPersistent(tuioObject.getObjectId())) {
getVariable().setValue(initialValue);
this.updateFromRotation(dialAngle, null);
}
}
// ---------------------------------------------------------------------------
@Override
public void actionLift(TangibleObject tangibleObject) {
super.actionLift(tangibleObject);
public void actionLift(TangibleObject tuioObject) {
super.actionLift(tuioObject);
if (!this.isPersistent(tangibleObject.getObjectId())) {
if (!modifyValueOnRotation) {
getVariable().setValue(0d);
} else {
getVariable().setValue(initialValue);
}
if (!this.isPersistent(tuioObject.getObjectId())) {
getVariable().setValue(initialValue);
}
}
// ---------------------------------------------------------------------------
@Override
public void actionMove(TangibleObject tangibleObject) {
super.actionMove(tangibleObject);
public void actionMove(TangibleObject tuioObject) {
super.actionMove(tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), (float) dialAngle)));
StateManager manager = objectStates.get(tangibleObject.getObjectId());
StateManager manager = objectStates.get(tuioObject.getObjectId());
if (withStopAngles) {
double angle = AngleUtils.moduloTwoPi(lowerStopAngle + Math.PI + tangibleObject.getAngle());
double angle = AngleUtils.moduloTwoPi(initialAngle + tuioObject.getAngle() - dropAngle);
dialAngle = Math.max(angle, lowerStopAngle);
dialAngle = Math.min(angle, upperStopAngle);
if ((angle >= lowerStopAngle) && (angle <= upperStopAngle)) {
dialAngle = angle;
}
Point position = getPosition(tangibleObject.getObjectId());
Point position = getPosition(tuioObject.getObjectId());
if (null == position) {
super.actionMove(tangibleObject.constrainedClone(new Point()));
super.actionMove(tuioObject.constrainedClone(new Point()));
} else {
super.actionMove(tangibleObject.constrainedClone(new Point(position.x, position.y, (float) dialAngle, position.getState().getClass())));
super.actionMove(tuioObject.constrainedClone(new Point(position.x, position.y, (float) dialAngle, position.getState().getClass())));
}
} else {
dialAngle = AngleUtils.moduloTwoPi(Math.PI + tangibleObject.getAngle());
dialAngle = AngleUtils.moduloTwoPi(Math.PI + tuioObject.getAngle());
super.actionMove(tuioObject.constrainedClone(new Point(tuioObject.getX(), tuioObject.getY(), (float) dialAngle)));
}
if (!modifyValueOnRotation) {
......@@ -397,23 +407,26 @@ public class ValueWidget extends TetherableWidget implements InformationProvider
public List<Variable<?>> connectWithSystemVariables(Map<String, Variable<?>> systemVariables) {
List<Variable<?>> connected = new ArrayList<>();
List<VariableBased> displays = this.getCoronas(VariableBased.class);
for (VariableBased display : displays) {
connected.addAll(display.connectWithSystemVariables(systemVariables));
}
if ((systemVariables != null) && systemVariables.containsKey(this.variable.getName())) {
NumericalVariable numeric = Variable.castTo(systemVariables.get(this.variable.getName()), NumericalVariable.class);
if (numeric != null) {
this.variable = numeric;
this.lowerBound = (Double.isNaN(lowerBound)) ? numeric.getMinValue() : lowerBound;
this.upperBound = (Double.isNaN(upperBound)) ? numeric.getMaxValue() : upperBound;
if (!Double.isNaN(numeric.getInitialValue())) {
this.initialValue = numeric.getInitialValue();
}
this.updateFromBounds(this.lowerBound, this.upperBound);
this.updateFromRotation(this.dialAngle, null);
connected.add(this.variable);
}
}
List<VariableBased> displays = this.getCoronas(VariableBased.class);
for (VariableBased display : displays) {
connected.addAll(display.connectWithSystemVariables(systemVariables));
}
return connected;
}
......
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