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 7cc71b5c authored by Valérie Maquil's avatar Valérie Maquil

added a width and a height to the image coronas

parent 180cf5bd
......@@ -87,14 +87,14 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
this.stepSize = builder.stepSize;
this.variable = builder.variable;
this.modifyValueOnRotation = builder.modifyValueOnRotation;
this.dynamic = builder.dynamic;
// this.dynamic = builder.dynamic;
/**
* Remember the base value of the variable and then set it to 0d as the value should be nill
* if the widget is not on the table (active). This should only be the case for non-dynamic
* value widgets
*/
if (!dynamic) {
if (!modifyValueOnRotation) {
this.baseValue = getVariable().getValue();
getVariable().setValue(0d);
} else {
......@@ -111,18 +111,22 @@ public final class ValueWidget extends BaseWidget implements InformationProvider
public void actionDrop(TangibleObject tangibleObject) {
super.actionDrop(tangibleObject);
if (!dynamic) {
// if (!dynamic) {
if (!modifyValueOnRotation) {
getVariable().setValue(baseValue);
}
// }
}
@Override
public void actionLift(TangibleObject tangibleObject) {
super.actionLift(tangibleObject);
if (!dynamic) {
// set to 0 only if placing widget
if (!modifyValueOnRotation) {
getVariable().setValue(0d);
}
}
@Override
......
......@@ -26,8 +26,6 @@ import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Externalization;
import lu.list.itis.dkd.tui.widget.ValueWidget;
import com.google.common.base.Strings;
import org.jdom2.Element;
/**
......@@ -87,21 +85,24 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
super(rootElement);
try {
lowerBound = Double.parseDouble(rootElement.getChildText(Externalization.LOWER_BOUND_NODE));
upperBound = Double.parseDouble(rootElement.getChildText(Externalization.UPPER_BOUND_NODE));
lowerStopAngle = Double.parseDouble(rootElement.getChildText(Externalization.LOWER_STOP_ANGLE_NODE));
upperStopAngle = Double.parseDouble(rootElement.getChildText(Externalization.UPPER_STOP_ANGLE_NODE));
stepSize = Double.parseDouble(rootElement.getChildText(Externalization.STEP_SIZE_NODE));
variable = new TangibleNumericalVariable(rootElement.getChild(Externalization.VARIABLE_NODE));
modifyValueOnRotation = Boolean.parseBoolean(rootElement.getChildText(Externalization.MODIFY_VALUE_ON_ROTATION_NODE));
String dynamicity = Strings.nullToEmpty(rootElement.getChildText(Externalization.DYNAMIC_NODE));
if (dynamicity.isEmpty()) {
dynamic = false;
} else {
dynamic = Boolean.parseBoolean(dynamicity);
if (modifyValueOnRotation) {
lowerBound = Double.parseDouble(rootElement.getChildText(Externalization.LOWER_BOUND_NODE));
upperBound = Double.parseDouble(rootElement.getChildText(Externalization.UPPER_BOUND_NODE));
lowerStopAngle = Double.parseDouble(rootElement.getChildText(Externalization.LOWER_STOP_ANGLE_NODE));
upperStopAngle = Double.parseDouble(rootElement.getChildText(Externalization.UPPER_STOP_ANGLE_NODE));
stepSize = Double.parseDouble(rootElement.getChildText(Externalization.STEP_SIZE_NODE));
}
/*
* String dynamicity =
* Strings.nullToEmpty(rootElement.getChildText(Externalization.DYNAMIC_NODE));
* java.lang.System.out.println(dynamicity); if (dynamicity.isEmpty()) { dynamic =
* false; } else { dynamic = Boolean.parseBoolean(dynamicity); }
*/
} catch (NumberFormatException nfe) {
throw new BuildException("One of the provided values could not be interpreted!", nfe); //$NON-NLS-1$
}
......@@ -167,11 +168,10 @@ public abstract class BaseValueWidgetBuilder<B extends BaseValueWidgetBuilder<B>
}
@SuppressWarnings("unchecked")
public B variableIsDynamic(boolean dynamic) {
this.dynamic = dynamic;
return (B) this;
}
/*
* @SuppressWarnings("unchecked") public B variableIsDynamic(boolean dynamic) { this.dynamic =
* dynamic; return (B) this; }
*/
/** {@inheritDoc} */
@Override
......
......@@ -21,6 +21,8 @@ import lu.list.itis.dkd.tui.exception.BuildException;
import lu.list.itis.dkd.tui.utility.Externalization;
import lu.list.itis.dkd.tui.widget.corona.ConditionalCorona;
import com.google.common.base.Strings;
import org.jdom2.Element;
import java.io.File;
......@@ -48,6 +50,8 @@ public abstract class BaseConditionalCoronaBuilder<B extends BaseConditionalCoro
public BooleanVariable triggerVariable = new BooleanVariable("Trigger", false); //$NON-NLS-1$
/** The image to show if the condition is true. */
public java.awt.Image image;
public int width;
public int height;
/**
* Constructor initializing all local fields.
......@@ -69,9 +73,25 @@ public abstract class BaseConditionalCoronaBuilder<B extends BaseConditionalCoro
try {
final Element imageNode = element.getChild(Externalization.IMAGE_ELEMENT);
if (null != imageNode) {
image = ImageIO.read(new File(imageNode.getText()));
String w = element.getChildText(Externalization.WIDTH_NODE);
String h = element.getChildText(Externalization.HEIGHT_NODE);
if (Strings.isNullOrEmpty(w) || Strings.isNullOrEmpty(h)) {
image = ImageIO.read(new File(imageNode.getText()));
} else {
width = Integer.parseInt(w);
height = Integer.parseInt(h);
java.awt.Image inputImage = ImageIO.read(new File(imageNode.getText()));
image = inputImage.getScaledInstance(width, height, java.awt.Image.SCALE_AREA_AVERAGING);
}
}
} catch (NullPointerException npe) {
throw new BuildException("The provided image path may not be empty. To add no image, remove the \"image\" element!", npe); //$NON-NLS-1$
} catch (IllegalArgumentException iae) {
......
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