Source Code Cross Referenced for PaletteSuitability.java in  » GIS » GeoTools-2.4.1 » org » geotools » brewer » color » 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.brewer.color 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2005-2006, GeoTools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.brewer.color;
017:
018:        import java.io.IOException;
019:
020:        /**
021:         * Contains the suitability information for a single palette with several colour schemes.
022:         *
023:         * @author Cory Horner, Refractions Research Inc.
024:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/brewer/src/main/java/org/geotools/brewer/color/PaletteSuitability.java $
025:         */
026:        public class PaletteSuitability {
027:            /** Suitability = GOOD */
028:            public static final int QUALITY_GOOD = 3;
029:
030:            /** Suitability = UNKNOWN */
031:            public static final int QUALITY_UNKNOWN = 2;
032:
033:            /** Suitability = DOUBTFUL */
034:            public static final int QUALITY_DOUBTFUL = 1;
035:
036:            /** Suitability = BAD */
037:            public static final int QUALITY_BAD = 0;
038:
039:            /** ViewerType = Suitable for the colorblind? */
040:            public static final int VIEWER_COLORBLIND = 0;
041:
042:            /** ViewerType = Suitable for photocopiers? */
043:            public static final int VIEWER_PHOTOCOPY = 1;
044:
045:            /** ViewerType = Suitable for overhead projectors (lcd)? */
046:            public static final int VIEWER_PROJECTOR = 2;
047:
048:            /** ViewerType = Suitable for LCD monitors? */
049:            public static final int VIEWER_LCD = 3;
050:
051:            /** ViewerType = Suitable for CRT monitors? */
052:            public static final int VIEWER_CRT = 4;
053:
054:            /** ViewerType = Suitable for colour printing? */
055:            public static final int VIEWER_PRINT = 5;
056:
057:            /**
058:             * Contains the suitability data for this palette.  First index is the
059:             * number of colors - 2.  Second index is the viewer type. Values are the
060:             * suitability value.
061:             *
062:             * <p>
063:             * Viewer Types: PaletteSuitability.COLORBLIND, PHOTOCOPY, PROJECTOR, LCD,
064:             * CRT, or PRINT
065:             * </p>
066:             *
067:             * <p>
068:             * Suitability: PaletteSuitability.GOOD, UNKNOWN, DOUBTFUL, or BAD
069:             * </p>
070:             */
071:            private int[][] paletteSuitability = new int[11][6];
072:
073:            /**
074:             * The maximum number of colors this palette can support (minimum is
075:             * assumed to be 2).
076:             */
077:            private int maxColors = 0;
078:
079:            public PaletteSuitability() {
080:            }
081:
082:            /**
083:             * Indexed getter for property paletteSuitability. For this palette, this
084:             * returns an array containing the integer values for all 6 suitabilities.
085:             *
086:             * @param numClasses
087:             *            The number of colors to determine the suitability for
088:             *
089:             * @return int array; index = PaletteSuitability.VIEWER_COLORBLIND,
090:             *         VIEWER_PHOTOCOPY, VIEWER_PROJECTOR, VIEWER_LCD, VIEWER_CRT, or
091:             *         VIEWER_PRINT; values = PaletteSuitability.QUALITY_GOOD,
092:             *         QUALITY_UNKNOWN, QUALITY_DOUBTFUL, or QUALITY_BAD.
093:             */
094:            public int[] getSuitability(int numClasses) {
095:                return paletteSuitability[numClasses - 2];
096:            }
097:
098:            /**
099:             * Indexed getter for the property paletteSuitability. For the selected
100:             * palette and viewerType, this returns the integer value of the
101:             *
102:             * @param numClasses
103:             *            number of colours in this palette
104:             * @param viewerType
105:             *            PaletteSuitability.VIEWER_COLORBLIND, VIEWER_PHOTOCOPY,
106:             *            VIEWER_PROJECTOR, VIEWER_LCD, VIEWER_CRT, or VIEWER_PRINT.
107:             *
108:             * @return PaletteSuitability.QUALITY_GOOD, QUALITY_UNKNOWN,
109:             *         QUALITY_DOUBTFUL, or QUALITY_BAD.
110:             */
111:            public int getSuitability(int numClasses, int viewerType) {
112:                return paletteSuitability[numClasses - 2][viewerType];
113:            }
114:
115:            /**
116:             *
117:             *
118:             * @param numClasses Index of the property.
119:             * @param suitability New value of the property at<CODE>index</CODE>.
120:             *
121:             * @throws IOException
122:             */
123:            public void setSuitability(int numClasses, String[] suitability)
124:                    throws IOException {
125:                //update max number of classes
126:                if (numClasses > maxColors) {
127:                    maxColors = numClasses;
128:                }
129:
130:                //convert G,D,B,? --> int
131:                if (suitability.length == 6) {
132:                    for (int i = 0; i < 6; i++) {
133:                        if (suitability[i].equals("G")) {
134:                            paletteSuitability[numClasses - 2][i] = QUALITY_GOOD;
135:                        } else if (suitability[i].equals("D")) {
136:                            paletteSuitability[numClasses - 2][i] = QUALITY_DOUBTFUL;
137:                        } else if (suitability[i].equals("B")) {
138:                            paletteSuitability[numClasses - 2][i] = QUALITY_BAD;
139:                        } else {
140:                            paletteSuitability[numClasses - 2][i] = QUALITY_UNKNOWN;
141:                        }
142:                    }
143:                } else {
144:                    throw new IOException(
145:                            "wrong number of items in suitability list");
146:                }
147:            }
148:
149:            public int getMaxColors() {
150:                return maxColors;
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.