if (values.length == 4) {
if (values[0] instanceof Number && values[1] instanceof Number
&& values[2] instanceof Number
&& values[3] instanceof Style.Units) {
return new Values((Style.Units) values[3],
((Number) values[0]).floatValue(),
((Number) values[1]).floatValue(),
((Number) values[2]).floatValue());
} else {
logger.warning("Cannot parse values[4] for sprite position.");
}
} else if (values.length == 3) {
if (values[0] instanceof Number && values[1] instanceof Number
&& values[2] instanceof Number) {
return new Values(Units.GU,
((Number) values[0]).floatValue(),
((Number) values[1]).floatValue(),
((Number) values[2]).floatValue());
} else {
logger.warning("Cannot parse values[3] for sprite position.");
}
} else if (values.length == 1) {
if (values[0] instanceof Number) {
return new Values(Units.GU,
((Number) values[0]).floatValue());
} else {
logger.warning(String.format("Sprite position percent is not a number."));
}
} else {
logger.warning(String.format("Cannot transform value '%s' (length=%d) into a position.", Arrays.toString(values), values.length));
}
} else if (value instanceof Number) {
return new Values(Units.GU, ((Number) value).floatValue());
} else if (value instanceof Value) {
return new Values((Value) value);
} else if (value instanceof Values) {
return new Values((Values) value);
} else {
System.err
.printf("GraphicGraph : cannot place sprite with posiiton '%s' (instance of %s)%n",
value, value.getClass().getName());
}