001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2002, Centre for Computational Geography
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * Created on 13 November 2002, 13:52
018: */
019: package org.geotools.styling;
020:
021: import org.geotools.event.AbstractGTComponent;
022: import org.geotools.factory.CommonFactoryFinder;
023: import org.geotools.factory.GeoTools;
024: import org.opengis.filter.FilterFactory;
025: import org.opengis.filter.expression.Expression;
026:
027: /**
028: * The ContrastEnhancement object defines contrast enhancement for a channel of
029: * a false-color image or for a color image. Its format is:
030: * <pre>
031: * <xs:element name="ContrastEnhancement">
032: * <xs:complexType>
033: * <xs:sequence>
034: * <xs:choice minOccurs="0">
035: * <xs:element ref="sld:Normalize"/>
036: * <xs:element ref="sld:Histogram"/>
037: * </xs:choice>
038: * <xs:element ref="sld:GammaValue" minOccurs="0"/>
039: * </xs:sequence>
040: * </xs:complexType>
041: * </xs:element>
042: * <xs:element name="Normalize">
043: * <xs:complexType/>
044: * </xs:element>
045: * <xs:element name="Histogram">
046: * <xs:complexType/>
047: * </xs:element>
048: * <xs:element name="GammaValue" type="xs:double"/>
049: * </pre>
050: * In the case of a color image, the relative grayscale brightness of a pixel
051: * color is used. ?Normalize? means to stretch the contrast so that the
052: * dimmest color is stretched to black and the brightest color is stretched to
053: * white, with all colors in between stretched out linearly. ?Histogram? means
054: * to stretch the contrast based on a histogram of how many colors are at each
055: * brightness level on input, with the goal of producing equal number of
056: * pixels in the image at each brightness level on output. This has the
057: * effect of revealing many subtle ground features. A ?GammaValue? tells how
058: * much to brighten (value greater than 1.0) or dim (value less than 1.0) an
059: * image. The default GammaValue is 1.0 (no change). If none of Normalize,
060: * Histogram, or GammaValue are selected in a ContrastEnhancement, then no
061: * enhancement is performed.
062: *
063: * @author iant
064: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/main/src/main/java/org/geotools/styling/ContrastEnhancementImpl.java $
065: */
066: public class ContrastEnhancementImpl extends AbstractGTComponent
067: implements ContrastEnhancement {
068:
069: private static final java.util.logging.Logger LOGGER = org.geotools.util.logging.Logging
070: .getLogger("org.geotools.core");
071: private FilterFactory filterFactory;
072: private Expression gamma;
073: private Expression type;
074:
075: public ContrastEnhancementImpl() {
076: this (CommonFactoryFinder.getFilterFactory(GeoTools
077: .getDefaultHints()));
078: }
079:
080: public ContrastEnhancementImpl(FilterFactory factory) {
081: filterFactory = factory;
082: }
083:
084: public void setFilterFactory(FilterFactory factory) {
085: filterFactory = factory;
086: }
087:
088: public Expression getGammaValue() {
089: return gamma;
090: }
091:
092: public Expression getType() {
093: return type;
094: }
095:
096: public void setGammaValue(Expression gamma) {
097: this .gamma = gamma;
098: fireChanged();
099: }
100:
101: public void setHistogram() {
102: type = filterFactory.literal("HISTOGRAM");
103: fireChanged();
104: }
105:
106: public void setNormalize() {
107: type = filterFactory.literal("NORMALIZE");
108: fireChanged();
109: }
110:
111: public void setType(Expression type) {
112: this.type = type;
113: fireChanged();
114: }
115: }
|