Source Code Cross Referenced for Attr.java in  » IDE-Netbeans » cvsclient » org » netbeans » lib » terminalemulator » 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 » IDE Netbeans » cvsclient » org.netbeans.lib.terminalemulator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         *
041:         * Contributor(s): Ivan Soleimanipour.
042:         */
043:
044:        /*
045:         * "Attr.java"
046:         * Attr.java 1.7 01/07/23
047:         */
048:
049:        package org.netbeans.lib.terminalemulator;
050:
051:        class Attr {
052:            // 'f' suffix for oFfset
053:            // 'w' suffix for Width
054:            // 'm' suffix for mask
055:            private final static int BGCOLORf = 0;
056:            private final static int BGCOLORw = 5;
057:            private final static int BGCOLORm = 0xf;
058:            public final static int BGCOLOR = BGCOLORm << BGCOLORf;
059:
060:            private final static int FGCOLORf = BGCOLORf + BGCOLORw;
061:            private final static int FGCOLORw = 5;
062:            private final static int FGCOLORm = 0xf;
063:            public final static int FGCOLOR = FGCOLORm << FGCOLORf;
064:
065:            private final static int HIDDENf = FGCOLORf + FGCOLORw;
066:            private final static int HIDDENw = 1;
067:            public final static int HIDDEN = 0x1 << HIDDENf;
068:
069:            private final static int REVERSEf = HIDDENf + HIDDENw;
070:            private final static int REVERSEw = 1;
071:            public final static int REVERSE = 0x1 << REVERSEf;
072:
073:            private final static int BLINKf = REVERSEf + REVERSEw;
074:            private final static int BLINKw = 1;
075:            public final static int BLINK = 0x1 << BLINKf;
076:
077:            private final static int UNDERSCOREf = BLINKf + BLINKw;
078:            private final static int UNDERSCOREw = 1;
079:            public final static int UNDERSCORE = 0x1 << UNDERSCOREf;
080:
081:            private final static int BRIGHTf = UNDERSCOREf + UNDERSCOREw;
082:            private final static int BRIGHTw = 1;
083:            public final static int BRIGHT = 0x1 << BRIGHTf;
084:
085:            private final static int DIMf = BRIGHTf + BRIGHTw;
086:            private final static int DIMw = 1;
087:            public final static int DIM = 0x1 << DIMf;
088:
089:            private final static int ACTIVEf = DIMf + DIMw;
090:            public final static int ACTIVE = 0x1 << ACTIVEf;
091:
092:            // Since an attr value of 0 means render using default attributes
093:            // We need a value that signifies that no attribute has been set.
094:            // Can't use the highest (sign) bit since Java has no unsigned and
095:            // we get complaints from the compiler.
096:            public final static int UNSET = 0x40000000;
097:
098:            /**
099:             * attr = Attr.setBackgroundColor(attr, 7);
100:             */
101:
102:            public static int setBackgroundColor(int attr, int code) {
103:                code &= BGCOLORm; // throw all but lowest relevant bits away
104:                attr &= ~BGCOLOR; // 0 out existing bits
105:                attr |= code << BGCOLORf;
106:                return attr;
107:            }
108:
109:            /**
110:             * attr = Attr.setForegroundColor(attr, 7);
111:             */
112:
113:            public static int setForegroundColor(int attr, int code) {
114:                code &= FGCOLORm; // throw all but lowest relevant bits away
115:                attr &= ~FGCOLOR; // 0 out existing bits
116:                attr |= code << FGCOLORf;
117:                return attr;
118:            }
119:
120:            /**
121:             * Use this to get at the FG color value embedded in an attr.
122:             */
123:            public static int foregroundColor(int attr) {
124:                return (attr >> FGCOLORf) & FGCOLORm;
125:            }
126:
127:            /**
128:             * Use this to get at the BG color value embedded in an attr.
129:             */
130:            public static int backgroundColor(int attr) {
131:                return (attr >> BGCOLORf) & BGCOLORm;
132:            }
133:
134:            /*
135:             * Read-modify-write utility for setting bitfields in 'attr'.
136:             */
137:            public static int setAttribute(int attr, int value) {
138:                switch (value) {
139:                case 0:
140:                    // Reset all attributes
141:                    attr = 0;
142:                    break;
143:                case 5:
144:                    // Attr.BLINK
145:                    // FALLTHRU
146:                case 1:
147:                    attr &= ~Attr.DIM;
148:                    attr |= Attr.BRIGHT;
149:                    break;
150:                case 2:
151:                    attr &= ~Attr.BRIGHT;
152:                    attr |= Attr.DIM;
153:                    break;
154:                case 4:
155:                    attr |= Attr.UNDERSCORE;
156:                    break;
157:                case 7:
158:                    attr |= Attr.REVERSE;
159:                    break;
160:                case 8:
161:                    attr |= Attr.HIDDEN;
162:                    break;
163:
164:                case 9:
165:                    // Term specific
166:                    attr |= Attr.ACTIVE;
167:                    break;
168:
169:                // turn individual attributes off (dtterm specific?)
170:                case 25:
171:                    // blinking off
172:                    // FALLTHRU
173:                case 22:
174:                    attr &= ~Attr.DIM;
175:                    attr &= ~Attr.BRIGHT;
176:                    break;
177:                case 24:
178:                    attr &= ~Attr.UNDERSCORE;
179:                    break;
180:                case 27:
181:                    attr &= ~Attr.REVERSE;
182:                    break;
183:                case 28:
184:                    attr &= ~Attr.HIDDEN;
185:                    break;
186:
187:                case 30:
188:                case 31:
189:                case 32:
190:                case 33:
191:                case 34:
192:                case 35:
193:                case 36:
194:                case 37:
195:                    attr = Attr.setForegroundColor(attr, value - 30 + 1);
196:                    break;
197:
198:                case 39:
199:                    // revert to default (dtterm specific)
200:                    attr = Attr.setForegroundColor(attr, 0);
201:                    break;
202:
203:                case 40:
204:                case 41:
205:                case 42:
206:                case 43:
207:                case 44:
208:                case 45:
209:                case 46:
210:                case 47:
211:                    attr = Attr.setBackgroundColor(attr, value - 40 + 1);
212:                    break;
213:
214:                case 49:
215:                    // revert to default (dtterm specific)
216:                    attr = Attr.setBackgroundColor(attr, 0);
217:                    break;
218:
219:                case 50:
220:                case 51:
221:                case 52:
222:                case 53:
223:                case 54:
224:                case 55:
225:                case 56:
226:                case 57:
227:                    // custom colors
228:                    attr = Attr.setForegroundColor(attr, value - 50 + 9);
229:                    break;
230:
231:                case 60:
232:                case 61:
233:                case 62:
234:                case 63:
235:                case 64:
236:                case 65:
237:                case 66:
238:                case 67:
239:                    // custom colors
240:                    attr = Attr.setBackgroundColor(attr, value - 60 + 9);
241:                    break;
242:
243:                default:
244:                    // silently ignore unrecognized attribute
245:                    break;
246:                }
247:                return attr;
248:            }
249:
250:            /*
251:             * Read-modify-write utility for unsetting bitfields in 'attr'.
252:             * Note: this doesn't cover the unsetting operations which
253:             * setAttributes does.
254:             */
255:            public static int unsetAttribute(int attr, int value) {
256:                switch (value) {
257:                case 0:
258:                    // Reset all attributes
259:                    attr = 0;
260:                    break;
261:                case 5:
262:                    // Attr.BLINK
263:                    // FALLTHRU
264:                case 1:
265:                    attr &= ~Attr.BRIGHT;
266:                    break;
267:                case 2:
268:                    attr &= ~Attr.DIM;
269:                    break;
270:                case 4:
271:                    attr &= ~Attr.UNDERSCORE;
272:                    break;
273:                case 7:
274:                    attr &= ~Attr.REVERSE;
275:                    break;
276:                case 8:
277:                    attr &= ~Attr.HIDDEN;
278:                    break;
279:                case 9:
280:                    attr &= ~Attr.ACTIVE;
281:                    break;
282:
283:                case 30:
284:                case 31:
285:                case 32:
286:                case 33:
287:                case 34:
288:                case 35:
289:                case 36:
290:                case 37:
291:                    attr = Attr.setForegroundColor(attr, 0);
292:                    break;
293:
294:                case 40:
295:                case 41:
296:                case 42:
297:                case 43:
298:                case 44:
299:                case 45:
300:                case 46:
301:                case 47:
302:                    attr = Attr.setBackgroundColor(attr, 0);
303:                    break;
304:
305:                case 50:
306:                case 51:
307:                case 52:
308:                case 53:
309:                case 54:
310:                case 55:
311:                case 56:
312:                case 57:
313:                    // custom colors
314:                    attr = Attr.setForegroundColor(attr, 0);
315:                    break;
316:
317:                case 60:
318:                case 61:
319:                case 62:
320:                case 63:
321:                case 64:
322:                case 65:
323:                case 66:
324:                case 67:
325:                    // custom colors
326:                    attr = Attr.setBackgroundColor(attr, 0);
327:                    break;
328:
329:                default:
330:                    // silently ignore unrecognized attribute
331:                    break;
332:                }
333:                return attr;
334:            }
335:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.