01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or (at your option) any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.coverage.processing;
17:
18: // J2SE dependencies
19: import java.awt.Color;
20: import java.io.Writer;
21:
22: // JAI dependencies
23: import javax.media.jai.EnumeratedParameter;
24: import javax.media.jai.Interpolation;
25: import javax.media.jai.KernelJAI;
26:
27: // Geotools dependencies
28: import org.geotools.coverage.AbstractCoverage;
29: import org.geotools.parameter.ParameterWriter;
30: import org.geotools.resources.image.ImageUtilities;
31:
32: /**
33: * Format grid coverage operation parameters in a tabular format.
34: *
35: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/processing/CoverageParameterWriter.java $
36: * @version $Id: CoverageParameterWriter.java 20970 2006-08-11 07:53:22Z jgarnett $
37: * @author Martin Desruisseaux
38: *
39: * @since 2.1
40: */
41: final class CoverageParameterWriter extends ParameterWriter {
42: /**
43: * Creates a new formatter writting parameters to the specified output stream.
44: */
45: public CoverageParameterWriter(final Writer out) {
46: super (out);
47: }
48:
49: /**
50: * Format the specified value as a string.
51: */
52: protected String formatValue(final Object value) {
53: if (KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL.equals(value)) {
54: return "GRADIENT_MASK_SOBEL_HORIZONTAL";
55: }
56: if (KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL.equals(value)) {
57: return "GRADIENT_MASK_SOBEL_VERTICAL";
58: }
59: if (value instanceof AbstractCoverage) {
60: return ((AbstractCoverage) value).getName().toString(
61: getLocale());
62: }
63: if (value instanceof Interpolation) {
64: return ImageUtilities
65: .getInterpolationName((Interpolation) value);
66: }
67: if (value instanceof EnumeratedParameter) {
68: return ((EnumeratedParameter) value).getName();
69: }
70: if (value instanceof Color) {
71: final Color c = (Color) value;
72: return "RGB[" + c.getRed() + ',' + c.getGreen() + ','
73: + c.getBlue() + ']';
74: }
75: return super.formatValue(value);
76: }
77: }
|