public Time(double d, String u) { this.value = d; this.unit = UnitsTime.valueOf(u); }
@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((unit == null) ? 0 : unit.hashCode()); long temp; temp = Double.doubleToLongBits(value); result = prime * result + (int) (temp ^ (temp >>> 32)); return result; }
/** * FIXME: this should likely take a default so that locations which don't * want an exception can have * * log.warn("Using new PositiveFloat(1.0)!", e); return new * PositiveFloat(1.0); * * or similar. */ public static ome.units.quantity.Time convert(Time t) { if (t == null) { return null; } Double v = t.getValue(); // Use the code/symbol-mapping in the ome.model.enums files // to convert to the specification value. String u = ome.model.enums.UnitsTime.valueOf( t.getUnit().toString()).getSymbol(); ome.xml.model.enums.UnitsTime units = makeXMLUnit(u); ome.units.unit.Unit<ome.units.quantity.Time> units2 = ome.xml.model.enums.handlers.UnitsTimeEnumHandler .getBaseUnit(units); return new ome.units.quantity.Time(v, units2); }
public TimeI(double d, Unit<ome.units.quantity.Time> unit) { this(d, ome.model.enums.UnitsTime.bySymbol(unit.getSymbol())); }
/** * Copy constructor that converts the given {@link omero.model.Time} * based on the given ome.model enum */ public TimeI(double d, ome.model.enums.UnitsTime ul) { this(d, UnitsTime.valueOf(ul.toString())); }
public Time(double d, Unit<ome.units.quantity.Time> unit) { this(d, UnitsTime.bySymbol(unit.getSymbol())); }
/** * FIXME: this should likely take a default so that locations which don't * want an exception can have * * log.warn("Using new PositiveFloat(1.0)!", e); return new * PositiveFloat(1.0); * * or similar. */ public static ome.units.quantity.Time convertTime(Time t) { if (t == null) { return null; } Double v = t.getValue(); String u = t.getUnit().getSymbol(); ome.xml.model.enums.UnitsTime units = makeTimeUnitXML(u); ome.units.unit.Unit<ome.units.quantity.Time> units2 = ome.xml.model.enums.handlers.UnitsTimeEnumHandler .getBaseUnit(units); return new ome.units.quantity.Time(v, units2); }
@Override public void copyObject(Filterable model, ModelMapper mapper) { if (model instanceof ome.model.units.Time) { ome.model.units.Time t = (ome.model.units.Time) model; this.value = t.getValue(); this.unit = UnitsTime.valueOf(t.getUnit().toString()); } else { throw new IllegalArgumentException( "Time cannot copy from " + (model==null ? "null" : model.getClass().getName())); } }
public Time(ome.units.quantity.Time value) { this(value.value().doubleValue(), UnitsTime.bySymbol(value.unit().getSymbol())); }
@Override public Filterable fillObject(ReverseModelMapper mapper) { ome.model.enums.UnitsTime ut = ome.model.enums.UnitsTime.valueOf(getUnit().toString()); ome.model.units.Time t = new ome.model.units.Time(getValue(), ut); return t; }
/** * Convert a Bio-Formats {@link Length} to an OMERO Length. */ public TimeI(ome.units.quantity.Time value) { ome.model.enums.UnitsTime internal = ome.model.enums.UnitsTime.bySymbol(value.unit().getSymbol()); UnitsTime ul = UnitsTime.valueOf(internal.toString()); setValue(value.value().doubleValue()); setUnit(ul); }
private omero.model.Time toRType(Time timeIncrement) { if (timeIncrement == null) return null; ome.model.enums.UnitsTime internal = ome.model.enums.UnitsTime.bySymbol( timeIncrement.unit().getSymbol()); omero.model.enums.UnitsTime ut = omero.model.enums.UnitsTime.valueOf( internal.toString()); omero.model.Time t = new omero.model.TimeI(); t.setValue(timeIncrement.value().doubleValue()); t.setUnit(ut); return t; }