/** * Copies parameter values from the specified {@link ParameterValueGroup} to the {@link * ParameterBlockJAI}, except the sources. * * <p><b>Note:</b> it would be possible to use {@link ImagingParameters#parameters} directly in * some occasions. However, we perform an unconditional copy instead because some operations may * change the values. * * @param parameters The {@link ParameterValueGroup} to be copied. * @return A copy of the provided {@link ParameterValueGroup} as a JAI block. * @since 2.4 */ protected ParameterBlockJAI prepareParameters(final ParameterValueGroup parameters) { final ImagingParameters copy = (ImagingParameters) descriptor.createValue(); final ParameterBlockJAI block = (ParameterBlockJAI) copy.parameters; org.geotools.parameter.Parameters.copy(parameters, copy); handleJAIEXTParams(block, parameters); return block; }
final ParameterValueGroup group = (ParameterValueGroup) parameters; for (final GeneralParameterValue value : group.values()) { destination = toNameValueMap(value, destination);
/** * Constructs default values for the specified {@linkplain MatrixParameterDescriptors matrix * parameter descriptors}. * * @param descriptor The descriptor for this group of parameters. */ public MatrixParameters(final MatrixParameterDescriptors descriptor) { super(descriptor); numRow = Parameters.cast((ParameterValue) parameter(0), Integer.class); numCol = Parameters.cast((ParameterValue) parameter(1), Integer.class); }
final GeneralParameterValue param, final String name, int maxDepth) { final List<Object> list = new ArrayList<Object>(); search(param, name, maxDepth, list); return list;
if (!isValidValue(Array.get(value, i), descriptor)) { return false; if (!isValidValue(element, descriptor)) { return false; if (!isValidValue(value, descriptor)) { return false;
/** A filter for the set of available operations. */ private static final class MethodFilter implements Predicate<MathTransformProvider> { /** The expected type ({@code Projection.class}) for projections). */ private final Class<? extends Operation> type; /** Constructs a filter for the set of math operations methods. */ public MethodFilter(final Class<? extends Operation> type) { this.type = type; } /** * Returns {@code true} if the specified element should be included. If the type is unknown, * conservatively returns {@code true}. */ @Override public boolean test(MathTransformProvider element) { if (element instanceof MathTransformProvider) { final Class<? extends Operation> t = ((MathTransformProvider) element).getOperationType(); if (t != null && !type.isAssignableFrom(t)) { return false; } } return true; } }
/** Implementation of the search algorithm. The result is stored in the supplied set. */ private static void search( final GeneralParameterValue param, final String name, final int maxDepth, final Collection<Object> list) { if (maxDepth >= 0) { if (AbstractIdentifiedObject.nameMatches(param.getDescriptor(), name)) { list.add(param); } if ((maxDepth != 0) && (param instanceof ParameterValueGroup)) { for (final GeneralParameterValue value : ((ParameterValueGroup) param).values()) { search(value, name, maxDepth - 1, list); } } } }
/** * Copies all parameter values from {@code source} to {@code target}. A typical usage of this * method is for transfering values from an arbitrary implementation to some specific * implementation (e.g. a parameter group implementation backed by a {@link * java.awt.image.renderable.ParameterBlock} for image processing operations). * * @param source The parameters to copy. * @param target Where to copy the source parameters. * @since 2.2 */ public static void copy(final ParameterValueGroup source, final ParameterValueGroup target) { for (final GeneralParameterValue param : source.values()) { final String name = param.getDescriptor().getName().getCode(); if (param instanceof ParameterValueGroup) { copy((ParameterValueGroup) param, target.addGroup(name)); } else { target.parameter(name).setValue(((ParameterValue) param).getValue()); } } }
/** * Constructs a new key for the specified operation and parameters. * * @param operation The operation to apply on grid coverages. * @param parameters The parameters, including source grid coverages. */ CachedOperation(final Operation operation, final ParameterValueGroup parameters) { this.operation = operation; int hashCode = operation.hashCode(); final Map param = Parameters.toNameValueMap(parameters, new TreeMap()); this.names = new String[param.size()]; this.values = new Object[names.length]; int index = 0; for (final Iterator it=param.entrySet().iterator(); it.hasNext(); index++) { final Map.Entry entry = (Map.Entry) it.next(); names[index] = ((String) entry.getKey()).toLowerCase(); Object value = entry.getValue(); if (value instanceof Coverage) { value = CoverageCache.DEFAULT.reference((Coverage) value); } if (value != null) { hashCode = 37*hashCode + value.hashCode(); } values[index] = value; } this.hashCode = hashCode; }
/** * Constructs a parameter group. The properties map is given unchanged to the {@linkplain * AbstractIdentifiedObject#AbstractIdentifiedObject(Map) super-class constructor}. The {@code * parameters} array should contains parameters <strong>other</strong> than matrix elements. The * first parameter is assumed to be the number of rows, and the second parameter the number of * columns. All extra parameters are ignored. * * @param properties Set of properties. Should contains at least {@code "name"}. * @param parameters The {@code "num_row"} and {@code "num_col"} parameters. * @param prefix The prefix to insert in front of parameter name for each matrix elements. * @param separator The separator between the row and the column index in parameter names. */ public MatrixParameterDescriptors( final Map<String, ?> properties, ParameterDescriptor<?>[] parameters, final String prefix, final char separator) { super(properties, parameters); if (parameters.length < 2) { // TODO: provide a localized message throw new IllegalArgumentException(); } numRow = Parameters.cast(parameters[0], Integer.class); numCol = Parameters.cast(parameters[1], Integer.class); ensureNonNull("prefix", prefix); this.prefix = prefix; this.separator = separator; }
org.geotools.parameter.Parameters.copy(parameters, copy); final ParameterBlockJAI block = (ParameterBlockJAI) copy.parameters; try {
/** * Copies parameter values from the specified {@link ParameterValueGroup} to the * {@link ParameterBlockJAI}, except the sources. * <p> * <b>Note:</b> it would be possible to use {@link ImagingParameters#parameters} * directly in some occasions. However, we perform an unconditional copy instead * because some operations (e.g. "GradientMagnitude") may change the values. * * @param parameters The {@link ParameterValueGroup} to be copied. * @return A copy of the provided {@link ParameterValueGroup} as a JAI block. * * @since 2.4 */ protected ParameterBlockJAI prepareParameters(final ParameterValueGroup parameters) { final ImagingParameters copy = (ImagingParameters) descriptor.createValue(); final ParameterBlockJAI block = (ParameterBlockJAI) copy.parameters; org.geotools.parameter.Parameters.copy(parameters, copy); return block; }
/** * Copies parameter values from the specified {@link ParameterValueGroup} to the * {@link ParameterBlockJAI}, except the sources. * <p> * <b>Note:</b> it would be possible to use {@link ImagingParameters#parameters} * directly in some occasions. However, we perform an unconditional copy instead * because some operations (e.g. "GradientMagnitude") may change the values. * * @param parameters The {@link ParameterValueGroup} to be copied. * @return A copy of the provided {@link ParameterValueGroup} as a JAI block. * * @since 2.4 */ protected ParameterBlockJAI prepareParameters(final ParameterValueGroup parameters) { final ImagingParameters copy = (ImagingParameters) descriptor.createValue(); final ParameterBlockJAI block = (ParameterBlockJAI) copy.parameters; org.geotools.parameter.Parameters.copy(parameters, copy); return block; }