Source Code Cross Referenced for ScaledColorSpace.java in  » GIS » GeoTools-2.4.1 » org » geotools » coverage » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoTools 2.4.1 » org.geotools.coverage 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2003-2006, Geotools Project Management Committee (PMC)
005:         *    (C) 2001, Institut de Recherche pour le Développement
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; either
010:         *    version 2.1 of the License, or (at your option) any later version.
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:        package org.geotools.coverage;
018:
019:        // J2SE dependencies
020:        import java.awt.color.ColorSpace;
021:
022:        // Geotools dependencies
023:        import org.geotools.resources.Utilities;
024:
025:        /**
026:         * Color space for raster backed by floating point numbers ranging between two arbitrary values.
027:         *
028:         * <strong>NOTE:</strong>
029:         *       Current implementation is a copy of {@code org.geotools.image.io.ScaledColorSpace}.
030:         *       Future implementation will be differents (interpolate in a color table instead of
031:         *       computing grayscales).
032:         *
033:         * @since 2.1
034:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/coverage/src/main/java/org/geotools/coverage/ScaledColorSpace.java $
035:         * @version $Id: ScaledColorSpace.java 22817 2006-11-17 17:24:55Z desruisseaux $
036:         * @author Martin Desruisseaux
037:         *
038:         * @todo Consider extending {@link javax.media.jai.ColorSpaceJAI}.
039:         */
040:        final class ScaledColorSpace extends ColorSpace {
041:            /**
042:             * Minimal normalized RGB value.
043:             */
044:            private static final float MIN_VALUE = 0f;
045:
046:            /**
047:             * Maximal normalized RGB value.
048:             */
049:            private static final float MAX_VALUE = 1f;
050:
051:            /**
052:             * The band to make visible (usually 0).
053:             */
054:            private final int band;
055:
056:            /**
057:             * Facteur par lequel multiplier les pixels.
058:             */
059:            private final float scale;
060:
061:            /**
062:             * Nombre à aditionner aux pixels après
063:             * les avoir multiplier par {@link #scale}.
064:             */
065:            private final float offset;
066:
067:            /**
068:             * Construit un modèle de couleurs.
069:             *
070:             * @param band La bande à rendre visible (habituellement 0).
071:             * @param numComponents Nombre de composante (seule la première sera prise en compte).
072:             * @param minimum La valeur géophysique minimale.
073:             * @param maximum La valeur géophysique maximale.
074:             */
075:            public ScaledColorSpace(final int band, final int numComponents,
076:                    final double minimum, final double maximum) {
077:                super (TYPE_GRAY, numComponents);
078:                this .band = band;
079:                final double scale = (maximum - minimum)
080:                        / (MAX_VALUE - MIN_VALUE);
081:                final double offset = minimum - MIN_VALUE * scale;
082:                this .scale = (float) scale;
083:                this .offset = (float) offset;
084:            }
085:
086:            /**
087:             * Retourne une couleur RGB en tons de
088:             * gris pour le nombre réel spécifié.
089:             */
090:            public float[] toRGB(final float[] values) {
091:                float value = (values[band] - offset) / scale;
092:                if (Float.isNaN(value))
093:                    value = MIN_VALUE;
094:                return new float[] { value, value, value };
095:            }
096:
097:            /**
098:             * Retourne une valeur réelle pour
099:             * le ton de gris spécifié.
100:             */
101:            public float[] fromRGB(final float[] RGB) {
102:                final float[] values = new float[getNumComponents()];
103:                values[band] = (RGB[0] + RGB[1] + RGB[2]) / 3 * scale + offset;
104:                return values;
105:            }
106:
107:            /**
108:             * Convertit les valeurs en couleurs dans l'espace CIEXYZ.
109:             */
110:            public float[] toCIEXYZ(final float[] values) {
111:                float value = (values[band] - offset) / scale;
112:                if (Float.isNaN(value))
113:                    value = MIN_VALUE;
114:                return new float[] { value * 0.9642f, value * 1.0000f,
115:                        value * 0.8249f };
116:            }
117:
118:            /**
119:             * Convertit les couleurs de l'espace CIEXYZ en valeurs.
120:             */
121:            public float[] fromCIEXYZ(final float[] RGB) {
122:                final float[] values = new float[getNumComponents()];
123:                values[band] = (RGB[0] / 0.9642f + RGB[1] + RGB[2] / 0.8249f)
124:                        / 3 * scale + offset;
125:                return values;
126:            }
127:
128:            /**
129:             * Retourne la valeur minimale autorisée.
130:             */
131:            public float getMinValue(final int component) {
132:                return MIN_VALUE * scale + offset;
133:            }
134:
135:            /**
136:             * Retourne la valeur maximale autorisée.
137:             */
138:            public float getMaxValue(final int component) {
139:                return MAX_VALUE * scale + offset;
140:            }
141:
142:            /**
143:             * Returns a string representation of this color model.
144:             */
145:            public String toString() {
146:                return Utilities.getShortClassName(this ) + '['
147:                        + getMinValue(band) + ", " + getMaxValue(band) + ']';
148:            }
149:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.