Commit ff3be322 authored by Nico Mack's avatar Nico Mack

Added optional unit (deg/rad) attribute to angle nodes

parent 4054df5e
......@@ -112,6 +112,7 @@ public class BootstrappingUtils {
private static final String NON_BOOLEAN_ATTRIBUTE_TEMPLATE = "Value provide for {} attribute must be a boolean. Specified value {} could not be interpreted as such!"; //$NON-NLS-1$
private static final String NON_ANGLE_NODE_TEMPLATE = "Value provide for {} node must be an angle matching the pattern {}. Specified value {} could not be interpreted as such!"; //$NON-NLS-1$
private static final String UNKOWN_UNIT_TEMPLATE = "{} is not a know unit value!"; //$NON-NLS-1$
private static final Map<String, Integer> FONT_STYLES = new HashMap<>();
......@@ -325,7 +326,14 @@ public class BootstrappingUtils {
if (angleMatcher.matches()) {
String angle = angleMatcher.group(1);
String unit = angleMatcher.group(2);
unit = (Strings.isNullOrEmpty(unit)) ? targetUnit : unit.toLowerCase(); // $NON-NLS-1$
if (Strings.isNullOrEmpty(unit)) {
Element angleElement = rootElement.getChild(childName);
if (angleElement != null) {
unit = getAttributeAsString(angleElement, Externalization.UNIT_NODE, OPTIONAL, targetUnit);
}
} else {
unit = unit.toLowerCase();
}
try {
value = parseDouble(angle);
} catch (NumberFormatException exception) {
......@@ -340,6 +348,8 @@ public class BootstrappingUtils {
case RADIANS:
value = Math.toDegrees(value);
break;
default:
logAndThrowBuildException(new BuildException(StringUtils.build(UNKOWN_UNIT_TEMPLATE, unit)), rootElement, childName);
}
}
} else {
......
......@@ -55,6 +55,7 @@ public class StatefulWidget extends BaseWidget {
/** The coalesced NuiState instances per handle. */
protected ConcurrentHashMap<Integer, StateManager> objectStates;
protected ConcurrentHashMap<Integer, StateManager> cursorStates;
protected boolean isPersistent;
// ***************************************************************************
// * Constants
......@@ -78,6 +79,7 @@ public class StatefulWidget extends BaseWidget {
Preconditions.checkState(builder.objectStates != null);
objectStates = builder.objectStates;
cursorStates = builder.cursorStates;
isPersistent = builder.isPersistent;
}
// ---------------------------------------------------------------------------
......@@ -93,6 +95,7 @@ public class StatefulWidget extends BaseWidget {
super(original);
objectStates = new ConcurrentHashMap<>();
this.isPersistent = original.isPersistent;
for (Entry<Integer, StateManager> entry : original.objectStates.entrySet()) {
boolean isPersistent = entry.getValue().isPersistent();
objectStates.putIfAbsent(entry.getKey(), new StateManager(isPersistent));
......
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