/** * Returns the floating point values of the parameter identified by the given descriptor. * See {@link #getValue(ParameterDescriptor)} for more information about how this method * uses the given {@code parameter} argument. * * <p>If the given descriptor supplies a {@linkplain DefaultParameterDescriptor#getUnit() * unit of measurement}, then the returned values will be converted into that unit.</p> * * @param parameter the name or alias of the parameter to look for. * @return the requested parameter values if they exists, or the <strong>non-null</strong> * {@linkplain DefaultParameterDescriptor#getDefaultValue() default value} otherwise. * @throws ParameterNotFoundException if the given {@code parameter} name or alias is not legal for this group. * @throws IllegalStateException if the value is not defined and there is no default value. * * @see DefaultParameterValue#doubleValueList(Unit) * * @since 0.6 */ public double[] doubleValueList(final ParameterDescriptor<double[]> parameter) throws ParameterNotFoundException { final ParameterValue<?> value = getParameter(parameter); if (value != null) { final Unit<?> unit = parameter.getUnit(); return (unit != null) ? value.doubleValueList(unit) : value.doubleValueList(); } else { return defaultValue(parameter); } }
/** * Returns the floating point values of the parameter identified by the given descriptor. * See {@link #getValue(ParameterDescriptor)} for more information about how this method * uses the given {@code parameter} argument. * * <p>If the given descriptor supplies a {@linkplain DefaultParameterDescriptor#getUnit() * unit of measurement}, then the returned values will be converted into that unit.</p> * * @param parameter the name or alias of the parameter to look for. * @return the requested parameter values if they exists, or the <strong>non-null</strong> * {@linkplain DefaultParameterDescriptor#getDefaultValue() default value} otherwise. * @throws ParameterNotFoundException if the given {@code parameter} name or alias is not legal for this group. * @throws IllegalStateException if the value is not defined and there is no default value. * * @see DefaultParameterValue#doubleValueList(Unit) * * @since 0.6 */ public double[] doubleValueList(final ParameterDescriptor<double[]> parameter) throws ParameterNotFoundException { final ParameterValue<?> value = getParameter(parameter); if (value != null) { final Unit<?> unit = parameter.getUnit(); return (unit != null) ? value.doubleValueList(unit) : value.doubleValueList(); } else { return defaultValue(parameter); } }
values.parameter("constants").doubleValueList(), (double[]) values.parameters.getObjectParameter("constants"))); assertSame(before, values.parameter("constants"));
value = p.getValue(); } else if (type.isArray()) { value = p.doubleValueList(unit); } else { value = p.doubleValue(unit);
if (unit != null) { if (type.isArray()) { value = p.doubleValueList(unit); } else { value = p.doubleValue(unit);
value = p.getValue(); } else if (type.isArray()) { value = p.doubleValueList(unit); } else { value = p.doubleValue(unit);
/** * Tests the standard parallel dynamic parameter. */ @Test public void testStandardParallel() { final MapProjectionDescriptor descriptor = createDescriptor(2); final ParameterValueGroup parameters = descriptor.createValue(); final ParameterValue<?> p = parameters.parameter(STANDARD_PARALLEL); final ParameterValue<?> p1 = parameters.parameter(STANDARD_PARALLEL_1); final ParameterValue<?> p2 = parameters.parameter(STANDARD_PARALLEL_2); assertSame(p, parameters.parameter(STANDARD_PARALLEL)); assertSame(p1, parameters.parameter(STANDARD_PARALLEL_1)); assertSame(p2, parameters.parameter(STANDARD_PARALLEL_2)); assertNotSame(p1, p2); assertNotSame(p1, p); assertNotSame(p2, p); /* Empty */ assertArrayEquals(new double[] { }, p.doubleValueList(), 0.0); p1.setValue(40); assertArrayEquals(new double[] {40 }, p.doubleValueList(), 0.0); p2.setValue(60); assertArrayEquals(new double[] {40,60}, p.doubleValueList(), 0.0); p.setValue(new double[] {30,40}); assertEquals(30, p1.doubleValue(), 0.0); assertEquals(40, p2.doubleValue(), 0.0); p.setValue(new double[] {45}); assertEquals(45, p1.doubleValue(), 0.0); assertEquals(Double.NaN, p2.doubleValue(), 0.0); } }