private Length getStart(Hashtable<String, Object> attrs) { Double start = Double.parseDouble(attrs.get("start").toString()); String units = attrs.get("units").toString(); return FormatTools.getStagePosition(start, units); }
private Length getStart(Hashtable<String, Object> attrs) { Double start = Double.parseDouble(attrs.get("start").toString()); String units = attrs.get("units").toString(); return FormatTools.getStagePosition(start, units); }
@Test(dataProvider = "stagePositionUnit") public void testGetStagePositionUnit(Double value, Unit<Length> unit, Length length) { assertEquals(length, FormatTools.getStagePosition(value, unit)); } }
/** * Formats the input value for the stage position into a length of the given * unit. * * @param value the value of the stage position * @param unit the unit of the stage position. If the string cannot be * converted into a base length unit, the stage position length * will be constructure using the default reference frame unit. * * @return the stage position formatted as a {@link Length}. Returns * {@code null} under the same conditions as * {@link #getStagePosition(Double, String)}. */ public static Length getStagePosition(Double value, String unit) { Unit<Length> baseunit = null; try { baseunit = UnitsLengthEnumHandler.getBaseUnit( UnitsLength.fromString(unit)); } catch (EnumerationException e) { LOGGER.warn("Invalid base unit: using default reference frame unit"); LOGGER.debug(e.getMessage()); baseunit = UNITS.REFERENCEFRAME; } return getStagePosition(value, baseunit); }
/** * Formats the input value for the stage position into a length of the given * unit. * * @param value the value of the stage position * @param unit the unit of the stage position. If the string cannot be * converted into a base length unit, the stage position length * will be constructure using the default reference frame unit. * * @return the stage position formatted as a {@link Length}. Returns * {@code null} under the same conditions as * {@link #getStagePosition(Double, String)}. */ public static Length getStagePosition(Double value, String unit) { Unit<Length> baseunit = null; try { baseunit = UnitsLengthEnumHandler.getBaseUnit( UnitsLength.fromString(unit)); } catch (EnumerationException e) { LOGGER.warn("Invalid base unit: using default reference frame unit"); LOGGER.debug(e.getMessage()); baseunit = UNITS.REFERENCEFRAME; } return getStagePosition(value, baseunit); }
@Test(dataProvider = "stagePositionStringUnit") public void testGetStagePositionStringUnit(Double value, String unit, Length length) { assertEquals(length, FormatTools.getStagePosition(value, unit)); }