mirror of
https://github.com/bancika/diy-layout-creator
synced 2026-11-13 10:42:09 +10:00
Redo unit conversion
This commit is contained in:
@@ -69,30 +69,9 @@ public class PropertyWrapper implements Cloneable {
|
||||
InvocationTargetException, SecurityException, NoSuchMethodException {
|
||||
this.ownerObject = object;
|
||||
Object value = getGetter().invoke(object);
|
||||
value = convertUnitsIfNeeded(value);
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private static Object convertUnitsIfNeeded(Object value) {
|
||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.AUTO_UNIT_CONVERSION_KEY, true)
|
||||
&& value instanceof Size sizeValue) {
|
||||
SizeUnit preferredUnit;
|
||||
if (ConfigurationManager.getInstance().readBoolean(IPlugInPort.METRIC_KEY, true)) {
|
||||
preferredUnit = SizeUnit.mm;
|
||||
}
|
||||
else {
|
||||
preferredUnit = SizeUnit.in;
|
||||
}
|
||||
if (preferredUnit.getType() != sizeValue.getUnit().getType()) {
|
||||
SizeUnit targetUnit = SizeUnit.ConversionMapping.get(sizeValue.getUnit());
|
||||
if (targetUnit != null) {
|
||||
value = sizeValue.convertToUnits(targetUnit);
|
||||
}
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// public void readUniqueFrom(IDIYComponent component)
|
||||
// throws IllegalArgumentException, IllegalAccessException,
|
||||
// InvocationTargetException {
|
||||
|
||||
Reference in New Issue
Block a user