Source Code Cross Referenced for AbstractLight.java in  » Graphic-Library » batik » org » apache » batik » ext » awt » image » 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 » Graphic Library » batik » org.apache.batik.ext.awt.image 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Licensed to the Apache Software Foundation (ASF) under one or more
004:           contributor license agreements.  See the NOTICE file distributed with
005:           this work for additional information regarding copyright ownership.
006:           The ASF licenses this file to You under the Apache License, Version 2.0
007:           (the "License"); you may not use this file except in compliance with
008:           the License.  You may obtain a copy of the License at
009:
010:               http://www.apache.org/licenses/LICENSE-2.0
011:
012:           Unless required by applicable law or agreed to in writing, software
013:           distributed under the License is distributed on an "AS IS" BASIS,
014:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:           See the License for the specific language governing permissions and
016:           limitations under the License.
017:
018:         */
019:        package org.apache.batik.ext.awt.image;
020:
021:        import java.awt.Color;
022:
023:        /**
024:         * An abstract implementation of the Light interface.
025:         *
026:         * @author <a href="mailto:deweese@apache.org">Thomas DeWeese</a>
027:         * @version $Id: AbstractLight.java 475477 2006-11-15 22:44:28Z cam $
028:         */
029:        public abstract class AbstractLight implements  Light {
030:            /**
031:             * Conversion function for light values.
032:             */
033:            public static final double sRGBToLsRGB(double value) {
034:                if (value <= 0.003928)
035:                    return value / 12.92;
036:                return Math.pow((value + 0.055) / 1.055, 2.4);
037:            }
038:
039:            /**
040:             * Light color in linear sRGB
041:             */
042:            private double[] color;
043:
044:            /**
045:             * @param  linear if true the color is returned in the Linear sRGB
046:             *                colorspace otherwise the color is in the gamma
047:             *                corrected sRGB color space.
048:             * @return the light's color 
049:             */
050:            public double[] getColor(boolean linear) {
051:                double[] ret = new double[3];
052:                if (linear) {
053:                    ret[0] = sRGBToLsRGB(color[0]);
054:                    ret[1] = sRGBToLsRGB(color[1]);
055:                    ret[2] = sRGBToLsRGB(color[2]);
056:                } else {
057:                    ret[0] = color[0];
058:                    ret[1] = color[1];
059:                    ret[2] = color[2];
060:                }
061:                return ret;
062:            }
063:
064:            public AbstractLight(Color color) {
065:                setColor(color);
066:            }
067:
068:            /**
069:             * Sets the new light color, <tt>newColor</tt> should be in sRGB.
070:             */
071:            public void setColor(Color newColor) {
072:                color = new double[3];
073:                color[0] = newColor.getRed() / 255.;
074:                color[1] = newColor.getGreen() / 255.;
075:                color[2] = newColor.getBlue() / 255.;
076:            }
077:
078:            /**
079:             * @return true if the light is constant over the whole surface
080:             */
081:            public boolean isConstant() {
082:                return true;
083:            }
084:
085:            /**
086:             * Returns a light map, starting in (x, y) with dx, dy increments, a given
087:             * width and height, and z elevations stored in the fourth component on the 
088:             * N array.
089:             *
090:             * @param x x-axis coordinate where the light should be computed
091:             * @param y y-axis coordinate where the light should be computed
092:             * @param dx delta x for computing light vectors in user space
093:             * @param dy delta y for computing light vectors in user space
094:             * @param width number of samples to compute on the x axis
095:             * @param height number of samples to compute on the y axis
096:             * @param z array containing the z elevation for all the points
097:             */
098:            public double[][][] getLightMap(double x, double y,
099:                    final double dx, final double dy, final int width,
100:                    final int height, final double[][][] z) {
101:                double[][][] L = new double[height][][];
102:
103:                for (int i = 0; i < height; i++) {
104:                    L[i] = getLightRow(x, y, dx, width, z[i], null);
105:                    y += dy;
106:                }
107:
108:                return L;
109:            }
110:
111:            /**
112:             * Returns a row of the light map, starting at (x, y) with dx
113:             * increments, a given width, and z elevations stored in the
114:             * fourth component on the N array.
115:             *
116:             * @param x x-axis coordinate where the light should be computed
117:             * @param y y-axis coordinate where the light should be computed
118:             * @param dx delta x for computing light vectors in user space
119:             * @param width number of samples to compute on the x axis
120:             * @param z array containing the z elevation for all the points
121:             * @param lightRow array to store the light info to, if null it will
122:             *                 be allocated for you and returned.
123:             *
124:             * @return an array width columns where each element
125:             *         is an array of three components representing the x, y and z
126:             *         components of the light vector.  */
127:            public double[][] getLightRow(double x, double y, final double dx,
128:                    final int width, final double[][] z,
129:                    final double[][] lightRow) {
130:                double[][] ret = lightRow;
131:                if (ret == null)
132:                    ret = new double[width][3];
133:
134:                for (int i = 0; i < width; i++) {
135:                    getLight(x, y, z[i][3], ret[i]);
136:                    x += dx;
137:                }
138:
139:                return ret;
140:            }
141:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.