001    /*
002     *    GeoAPI - Java interfaces for OGC/ISO standards
003     *    http://www.geoapi.org
004     *
005     *    Copyright (C) 2004-2012 Open Geospatial Consortium, Inc.
006     *    All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007     *
008     *    Permission to use, copy, and modify this software and its documentation, with
009     *    or without modification, for any purpose and without fee or royalty is hereby
010     *    granted, provided that you include the following on ALL copies of the software
011     *    and documentation or portions thereof, including modifications, that you make:
012     *
013     *    1. The full text of this NOTICE in a location viewable to users of the
014     *       redistributed or derivative work.
015     *    2. Notice of any changes or modifications to the OGC files, including the
016     *       date changes were made.
017     *
018     *    THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019     *    NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020     *    TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021     *    THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022     *    PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023     *
024     *    COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025     *    CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026     *
027     *    The name and trademarks of copyright holders may NOT be used in advertising or
028     *    publicity pertaining to the software without specific, written prior permission.
029     *    Title to copyright in this software and any associated documentation will at all
030     *    times remain with copyright holders.
031     */
032    package org.opengis.coverage;
033    
034    import java.util.List;
035    import java.util.ArrayList;
036    import java.awt.image.DataBuffer;
037    
038    import org.opengis.util.CodeList;
039    import org.opengis.annotation.UML;
040    
041    import static org.opengis.annotation.Obligation.*;
042    import static org.opengis.annotation.Specification.*;
043    
044    
045    /**
046     * Specifies the various dimension types for coverage values.
047     * For grid coverages, these correspond to band types.
048     *
049     * <P>&nbsp;</P>
050     * <TABLE WIDTH="80%" ALIGN="center" CELLPADDING="18" BORDER="4" BGCOLOR="#FFE0B0">
051     *   <TR><TD>
052     *     <P align="justify"><STRONG>WARNING: THIS CLASS WILL CHANGE.</STRONG> Current API is derived from OGC
053     *     <A HREF="http://www.opengis.org/docs/01-004.pdf">Grid Coverages Implementation specification 1.0</A>.
054     *     We plan to replace it by new interfaces derived from ISO 19123 (<CITE>Schema for coverage geometry
055     *     and functions</CITE>). Current interfaces should be considered as legacy and are included in this
056     *     distribution only because they were part of GeoAPI 1.0 release. We will try to preserve as much
057     *     compatibility as possible, but no migration plan has been determined yet.</P>
058     *   </TD></TR>
059     * </TABLE>
060     *
061     * @version <A HREF="http://www.opengis.org/docs/01-004.pdf">Grid Coverage specification 1.0</A>
062     * @author  Martin Desruisseaux (IRD)
063     * @since   GeoAPI 1.0
064     *
065     * @see SampleDimension
066     */
067    @UML(identifier="CV_SampleDimensionType", specification=OGC_01004)
068    public final class SampleDimensionType extends CodeList<SampleDimensionType> {
069        /**
070         * Serial number for compatibility with different versions.
071         */
072        private static final long serialVersionUID = -4153433145134818506L;
073    
074        /**
075         * List of all enumerations of this type.
076         * Must be declared before any enum declaration.
077         */
078        private static final List<SampleDimensionType> VALUES = new ArrayList<SampleDimensionType>(11);
079    
080        /**
081         * Unsigned 1 bit integers.
082         *
083         * @rename Renamed {@code CV_1BIT} as {@code UNSIGNED_1BIT} since we
084         *         drop the prefix, but can't get a name starting with a digit.
085         */
086        @UML(identifier="CV_1BIT", obligation=CONDITIONAL, specification=OGC_01004)
087        public static final SampleDimensionType UNSIGNED_1BIT = new SampleDimensionType("UNSIGNED_1BIT");
088    
089        /**
090         * Unsigned 2 bits integers.
091         *
092         * @rename Renamed {@code CV_2BIT} as {@code UNSIGNED_2BITS} since we
093         *         drop the prefix, but can't get a name starting with a digit.
094         */
095        @UML(identifier="CV_2BIT", obligation=CONDITIONAL, specification=OGC_01004)
096        public static final SampleDimensionType UNSIGNED_2BITS = new SampleDimensionType("UNSIGNED_2BITS");
097    
098        /**
099         * Unsigned 4 bits integers.
100         *
101         * @rename Renamed {@code CV_4BIT} as {@code UNSIGNED_4BITS} since we
102         *         drop the prefix, but can't get a name starting with a digit.
103         */
104        @UML(identifier="CV_4BIT", obligation=CONDITIONAL, specification=OGC_01004)
105        public static final SampleDimensionType UNSIGNED_4BITS = new SampleDimensionType("UNSIGNED_4BITS");
106    
107        /**
108         * Unsigned 8 bits integers.
109         *
110         * @rename Renamed {@code CV_8BIT_U} as {@code UNSIGNED_8BITS} since we
111         *         drop the prefix, but can't get a name starting with a digit.
112         *
113         * @see #SIGNED_8BITS
114         * @see DataBuffer#TYPE_BYTE
115         */
116        @UML(identifier="CV_8BIT_U", obligation=CONDITIONAL, specification=OGC_01004)
117        public static final SampleDimensionType UNSIGNED_8BITS = new SampleDimensionType("UNSIGNED_8BITS");
118    
119        /**
120         * Signed 8 bits integers.
121         *
122         * @rename Renamed {@code CV_8BIT_S} as {@code SIGNED_8BITS} since we
123         *         drop the prefix, but can't get a name starting with a digit.
124         *
125         * @see #UNSIGNED_8BITS
126         */
127        @UML(identifier="CV_8BIT_S", obligation=CONDITIONAL, specification=OGC_01004)
128        public static final SampleDimensionType SIGNED_8BITS = new SampleDimensionType("SIGNED_8BITS");
129    
130        /**
131         * Unsigned 16 bits integers.
132         *
133         * @rename Renamed {@code CV_16BIT_U} as {@code UNSIGNED_16BITS} since we
134         *         drop the prefix, but can't get a name starting with a digit.
135         *
136         * @see #SIGNED_16BITS
137         * @see DataBuffer#TYPE_USHORT
138         */
139        @UML(identifier="CV_16BIT_U", obligation=CONDITIONAL, specification=OGC_01004)
140        public static final SampleDimensionType UNSIGNED_16BITS = new SampleDimensionType("UNSIGNED_16BITS");
141    
142        /**
143         * Signed 16 bits integers.
144         *
145         * @rename Renamed {@code CV_16BIT_S} as {@code SIGNED_16BITS} since we
146         *         drop the prefix, but can't get a name starting with a digit.
147         *
148         * @see #UNSIGNED_16BITS
149         * @see DataBuffer#TYPE_SHORT
150         */
151        @UML(identifier="CV_16BIT_S", obligation=CONDITIONAL, specification=OGC_01004)
152        public static final SampleDimensionType SIGNED_16BITS = new SampleDimensionType("SIGNED_16BITS");
153    
154        /**
155         * Unsigned 32 bits integers.
156         *
157         * @rename Renamed {@code CV_32BIT_U} as {@code UNSIGNED_32BITS} since we
158         *         drop the prefix, but can't get a name starting with a digit.
159         *
160         * @see #SIGNED_32BITS
161         */
162        @UML(identifier="CV_32BIT_U", obligation=CONDITIONAL, specification=OGC_01004)
163        public static final SampleDimensionType UNSIGNED_32BITS = new SampleDimensionType("UNSIGNED_32BITS");
164    
165        /**
166         * Signed 32 bits integers.
167         *
168         * @rename Renamed {@code CV_32BIT_S} as {@code SIGNED_32BITS} since we
169         *         drop the prefix, but can't get a name starting with a digit.
170         *
171         * @see #UNSIGNED_32BITS
172         * @see DataBuffer#TYPE_INT
173         */
174        @UML(identifier="CV_32BIT_S", obligation=CONDITIONAL, specification=OGC_01004)
175        public static final SampleDimensionType SIGNED_32BITS = new SampleDimensionType("SIGNED_32BITS");
176    
177        /**
178         * Simple precision floating point numbers.
179         *
180         * @rename Renamed {@code CV_32BIT_REAL} as {@code REAL_32BITS} since we
181         *         drop the prefix, but can't get a name starting with a digit.
182         *
183         * @see #REAL_64BITS
184         * @see DataBuffer#TYPE_FLOAT
185         */
186        @UML(identifier="CV_32BIT_REAL", obligation=CONDITIONAL, specification=OGC_01004)
187        public static final SampleDimensionType REAL_32BITS = new SampleDimensionType("REAL_32BITS");
188    
189        /**
190         * Double precision floating point numbers.
191         *
192         * @rename Renamed {@code CV_64BIT_REAL} as {@code REAL_64BITS} since we
193         *         drop the prefix, but can't get a name starting with a digit.
194         *
195         * @see #REAL_32BITS
196         * @see DataBuffer#TYPE_DOUBLE
197         */
198        @UML(identifier="CV_64BIT_REAL", obligation=CONDITIONAL, specification=OGC_01004)
199        public static final SampleDimensionType REAL_64BITS = new SampleDimensionType("REAL_64BITS");
200    
201        /**
202         * Constructs an enum with the given name. The new enum is
203         * automatically added to the list returned by {@link #values}.
204         *
205         * @param name The enum name. This name must not be in use by an other enum of this type.
206         */
207        private SampleDimensionType(final String name) {
208            super(name, VALUES);
209        }
210    
211        /**
212         * Returns the list of {@code SampleDimensionType}s.
213         *
214         * @return The list of codes declared in the current JVM.
215         */
216        public static SampleDimensionType[] values() {
217            synchronized (VALUES) {
218                return VALUES.toArray(new SampleDimensionType[VALUES.size()]);
219            }
220        }
221    
222        /**
223         * Returns the list of enumerations of the same kind than this enum.
224         */
225        @Override
226        public SampleDimensionType[] family() {
227            return values();
228        }
229    
230        /**
231         * Returns the sample dimension type that matches the given string, or returns a
232         * new one if none match it. More specifically, this methods returns the first instance for
233         * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
234         * returns {@code true}. If no existing instance is found, then a new one is created for
235         * the given name.
236         *
237         * @param code The name of the code to fetch or to create.
238         * @return A code matching the given name.
239         */
240        public static SampleDimensionType valueOf(String code) {
241            return valueOf(SampleDimensionType.class, code);
242        }
243    }