001    /*
002     *    GeoAPI - Java interfaces for OGC/ISO standards
003     *    http://www.geoapi.org
004     *
005     *    Copyright (C) 2008-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.style;
033    
034    import java.util.List;
035    import java.util.ArrayList;
036    import org.opengis.util.CodeList;
037    
038    import org.opengis.annotation.XmlElement;
039    
040    
041    /**
042     * The ContrastEnhancement element defines contrast enhancement for a channel of a
043     * false-color image or for a color image.
044     *
045     * In the case of a color image, the relative grayscale brightness of a pixel color is used.
046     * “Normalize” means to stretch the contrast so that the dimmest color is stretched to black
047     * and the brightest color is stretched to white, with all colors in between stretched out
048     * linearly. “Histogram” means to stretch the contrast based on a histogram of how many
049     * colors are at each brightness level on input, with the goal of producing equal number of
050     * pixels in the image at each brightness level on output. This has the effect of revealing
051     * many subtle ground features.
052     *
053     * @version <A HREF="http://www.opengeospatial.org/standards/symbol">Symbology Encoding Implementation Specification 1.1.0</A>
054     * @author Open Geospatial Consortium
055     * @author Johann Sorel (Geomatys)
056     * @since GeoAPI 2.2
057     */
058    @XmlElement("ContrastEnchancement:type")
059    public final class ContrastMethod extends CodeList<ContrastMethod> {
060        /**
061         * Serial number for compatibility with different versions.
062         */
063        private static final long serialVersionUID = -7328502367911363577L;
064    
065        /**
066         * List of all enumerations of this type.
067         * Must be declared before any enum declaration.
068         */
069        private static final List<ContrastMethod> VALUES = new ArrayList<ContrastMethod>(3);
070    
071        /**
072         * Normalize enchancement.
073         * “Normalize” means to stretch the contrast so that the dimmest color is stretched to black
074         * and the brightest color is stretched to white, with all colors in between stretched out
075         * linearly.
076         */
077        @XmlElement("Normalize")
078        public static final ContrastMethod NORMALIZE = new ContrastMethod("NORMALIZE");
079    
080        /**
081         * Histogram enchancement.
082         * “Histogram” means to stretch the contrast based on a histogram of how many
083         * colors are at each brightness level on input, with the goal of producing equal number of
084         * pixels in the image at each brightness level on output.
085         */
086        @XmlElement("Histogram")
087        public static final ContrastMethod HISTOGRAM = new ContrastMethod("HISTOGRAM");
088    
089        /**
090         * No enchancement.
091         * this is the default value.
092         */
093        public static final ContrastMethod NONE = new ContrastMethod("NONE");
094    
095        /**
096         * Constructs an enum with the given name. The new enum is
097         * automatically added to the list returned by {@link #values}.
098         *
099         * @param name The enum name. This name must not be in use by an other enum of this type.
100         */
101        private ContrastMethod(final String name) {
102            super(name, VALUES);
103        }
104    
105        /**
106         * Returns the list of {@code ContrastType}s.
107         *
108         * @return The list of codes declared in the current JVM.
109         */
110        public static ContrastMethod[] values() {
111            synchronized (VALUES) {
112                return VALUES.toArray(new ContrastMethod[VALUES.size()]);
113            }
114        }
115    
116        /**
117         * Returns the list of enumerations of the same kind than this enum.
118         */
119        public ContrastMethod[] family() {
120            return values();
121        }
122    
123        /**
124         * Returns the contrast type that matches the given string, or returns a
125         * new one if none match it. More specifically, this methods returns the first instance for
126         * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
127         * returns {@code true}. If no existing instance is found, then a new one is created for
128         * the given name.
129         *
130         * @param code The name of the code to fetch or to create.
131         * @return A code matching the given name.
132         */
133        public static ContrastMethod valueOf(String code) {
134            return valueOf(ContrastMethod.class, code);
135        }
136    }