Example #1
0
 /**
  * Return the minimum value of a non-modal range property value scaled to a given unit. Throws an
  * exception if no property value exists or an error occurs.
  *
  * @param ph The property holder from which to retrieve the property value.
  * @param pd The property to retrieve.
  * @param unit The unit to scale the value to.
  * @return The minimum of the range value scaled to the given unit.
  * @throws InvalidModelException Thrown if the property value cannot be retrieved because the
  *     model is incomplete or otherwise invalid.
  * @throws PropertyNotPresentException Thrown if the property is undefined for ph.
  * @throws PropertyIsModalException Thrown if ph is modal and declarative.
  * @throws IllegalStateException Thrown if the lookup encounters a cycle of property reference
  *     dependencies.
  * @throws IllegalArgumentException Thrown if the given unit literal is not from the property's
  *     unit type or if ph, pd, or unit is null.
  * @throws PropertyDoesNotApplyToHolderException Thrown if pd does not apply to ph.
  * @throws PropertyIsListException Thrown if the property is not scalar.
  * @throws ClassCastException Thrown if the retrieved value is not a range value.
  */
 public static double getScaledRangeMinimum(
     final NamedElement ph, final Property pd, final UnitLiteral unit)
     throws InvalidModelException, PropertyNotPresentException, PropertyIsModalException,
         IllegalStateException, IllegalArgumentException, PropertyDoesNotApplyToHolderException,
         PropertyIsListException, ClassCastException {
   final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ph, pd, unit);
   RangeValue rv = (RangeValue) pv;
   return rv.getMinimumValue().getScaledValue(unit);
 }
Example #2
0
 /**
  * Return the minimum value of a non-modal range property value scaled to a given unit. Returns a
  * given default value if no property value exists. Throws an exception if an error occurs.
  *
  * @param ph The property holder from which to retrieve the property value.
  * @param pd The property to retrieve.
  * @param unit The unit to scale the value to.
  * @param defaultVal The value to return if the property has no value.
  * @return The minimum of the range value scaled to the given unit.
  */
 public static double getScaledRangeMinimum(
     final NamedElement ph, final Property pd, final UnitLiteral unit, final double defaultVal) {
   try {
     final PropertyExpression pv = checkUnitsAndGetSimplePropertyValue(ph, pd, unit);
     final RangeValue rv = (RangeValue) pv;
     return rv.getMinimumValue().getScaledValue(unit);
   } catch (PropertyLookupException e) {
     return defaultVal;
   }
 }