Source Code Cross Referenced for ColorMap.java in  » Database-Client » prefuse » prefuse » util » 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 » Database Client » prefuse » prefuse.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.util;
002:
003:        /**
004:         * A color map provides a mapping from numeric values to specific colors.
005:         * This useful for assigning colors to visualized items. The numeric values
006:         * may represent different categories (i.e. nominal variables) or run along
007:         * a spectrum of values (i.e. quantitative variables).
008:         *
009:         * @author <a href="http://jheer.org">jeffrey heer</a>
010:         */
011:        public class ColorMap {
012:
013:            private int[] palette;
014:            private double minValue, maxValue;
015:
016:            /**
017:             * Creates a new ColorMap instance using the given internal color map
018:             * array and minimum and maximum index values.
019:             * @param map the color palette, an int array of color values
020:             * @param min the minimum value in the color map
021:             * @param max the maximum value in the color map
022:             */
023:            public ColorMap(int[] map, double min, double max) {
024:                palette = map;
025:                minValue = min;
026:                maxValue = max;
027:            }
028:
029:            /**
030:             * Returns the color associated with the given value. If the value
031:             * is outside the range defined by this map's minimum or maximum
032:             * values, a endpoint value is returned (i.e. the first entry
033:             * in the color map for values below the minimum, the last enty
034:             * for value above the maximum).
035:             * @param val the value for which to retrieve the color
036:             * @return the color corresponding the given value
037:             */
038:            public int getColor(double val) {
039:                if (val < minValue) {
040:                    return palette[0];
041:                } else if (val >= maxValue) {
042:                    return palette[palette.length - 1];
043:                } else {
044:                    int idx = (int) (palette.length * (val - minValue) / (maxValue - minValue));
045:                    return palette[idx];
046:                }
047:            }
048:
049:            /**
050:             * Gets the internal color palette, an int array of color values.
051:             * @return returns the color palette.
052:             */
053:            public int[] getColorPalette() {
054:                return palette;
055:            }
056:
057:            /**
058:             * Sets the internal color palette, an int array of color values.
059:             * @param palette the new palette.
060:             */
061:            public void setColorPalette(int[] palette) {
062:                this .palette = palette;
063:            }
064:
065:            /**
066:             * Gets the maximum value that corresponds to the last
067:             * color in the color map.
068:             * @return returns the max index value into the color map.
069:             */
070:            public double getMaxValue() {
071:                return maxValue;
072:            }
073:
074:            /**
075:             * Sets the maximum value that corresponds to the last
076:             * color in the color map.
077:             * @param maxValue the new max index value.
078:             */
079:            public void setMaxValue(double maxValue) {
080:                this .maxValue = maxValue;
081:            }
082:
083:            /**
084:             * Gets the minimum value that corresponds to the first
085:             * color in the color map.
086:             * @return Returns the min index value.
087:             */
088:            public double getMinValue() {
089:                return minValue;
090:            }
091:
092:            /**
093:             * Sets the minimum value that corresponds to the first
094:             * color in the color map.
095:             * @param minValue the new min index value.
096:             */
097:            public void setMinValue(double minValue) {
098:                this .minValue = minValue;
099:            }
100:
101:        } // end of class ColorMap
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.