Source Code Cross Referenced for ColorHelper.java in  » Net » j2ssh » com » sshtools » daemon » terminal » 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 » Net » j2ssh » com.sshtools.daemon.terminal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  SSHTools - Java SSH2 API
003:         *
004:         *  Copyright (C) 2002-2003 Lee David Painter and Contributors.
005:         *
006:         *  Contributions made by:
007:         *
008:         *  Brett Smith
009:         *  Richard Pernavas
010:         *  Erwin Bolwidt
011:         *
012:         *  This program is free software; you can redistribute it and/or
013:         *  modify it under the terms of the GNU General Public License
014:         *  as published by the Free Software Foundation; either version 2
015:         *  of the License, or (at your option) any later version.
016:         *
017:         *  This program is distributed in the hope that it will be useful,
018:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
019:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
020:         *  GNU General Public License for more details.
021:         *
022:         *  You should have received a copy of the GNU General Public License
023:         *  along with this program; if not, write to the Free Software
024:         *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
025:         */
026:        /**
027:         * SSHTools - Java SSH API The contents of this package has been derived from
028:         * the TelnetD library available from http://sourceforge.net/projects/telnetd
029:         * The original license of the source code is as follows: TelnetD library
030:         * (embeddable telnet daemon) Copyright (C) 2000 Dieter Wimberger This library
031:         * is free software; you can either redistribute it and/or modify it under the
032:         * terms of the GNU Lesser General Public License version 2.1,1999 as
033:         * published by the Free Software Foundation (see copy received along with the
034:         * library), or under the terms of the BSD-style license received along with
035:         * this library.
036:         */package com.sshtools.daemon.terminal;
037:
038:        /**
039:         *
040:         *
041:         * @author $author$
042:         * @version $Revision: 1.12 $
043:         */
044:        public class ColorHelper {
045:            /**  */
046:            public static final String INTERNAL_MARKER = "\001";
047:
048:            /**  */
049:            public static final int MARKER_CODE = 1;
050:
051:            /**  */
052:            public static final String BLACK = "S";
053:
054:            /**  */
055:            public static final String RED = "R";
056:
057:            /**  */
058:            public static final String GREEN = "G";
059:
060:            /**  */
061:            public static final String YELLOW = "Y";
062:
063:            /**  */
064:            public static final String BLUE = "B";
065:
066:            /**  */
067:            public static final String MAGENTA = "M";
068:
069:            /**  */
070:            public static final String CYAN = "C";
071:
072:            /**  */
073:            public static final String white = "W";
074:
075:            /**  */
076:            public static final String BOLD = "f";
077:
078:            /**  */
079:            public static final String BOLD_OFF = "d"; //normal color or normal intensity
080:
081:            /**  */
082:            public static final String ITALIC = "i";
083:
084:            /**  */
085:            public static final String ITALIC_OFF = "j";
086:
087:            /**  */
088:            public static final String UNDERLINED = "u";
089:
090:            /**  */
091:            public static final String UNDERLINED_OFF = "v";
092:
093:            /**  */
094:            public static final String BLINK = "e";
095:
096:            /**  */
097:            public static final String BLINK_OFF = "n";
098:
099:            /**  */
100:            public static final String RESET_ALL = "a";
101:
102:            /**
103:             *
104:             *
105:             * @param str
106:             * @param color
107:             *
108:             * @return
109:             */
110:            public static String colorizeText(String str, String color) {
111:                return INTERNAL_MARKER + color + str + INTERNAL_MARKER
112:                        + RESET_ALL;
113:            }
114:
115:            //colorizeText
116:            public static String colorizeBackground(String str, String color) {
117:                return INTERNAL_MARKER + color.toLowerCase() + str
118:                        + INTERNAL_MARKER + RESET_ALL;
119:            }
120:
121:            //colorizeBackground
122:            public static String colorizeText(String str, String fgc, String bgc) {
123:                return INTERNAL_MARKER + fgc + INTERNAL_MARKER
124:                        + bgc.toLowerCase() + str + INTERNAL_MARKER + RESET_ALL;
125:            }
126:
127:            //colorizeText
128:            public static String boldcolorizeText(String str, String color) {
129:                return INTERNAL_MARKER + BOLD + INTERNAL_MARKER + color + str
130:                        + INTERNAL_MARKER + RESET_ALL;
131:            }
132:
133:            //colorizeBoldText
134:            public static String boldcolorizeText(String str, String fgc,
135:                    String bgc) {
136:                return INTERNAL_MARKER + BOLD + INTERNAL_MARKER + fgc
137:                        + INTERNAL_MARKER + bgc.toLowerCase() + str
138:                        + INTERNAL_MARKER + RESET_ALL;
139:            }
140:
141:            //colorizeBoldText
142:            public static String boldText(String str) {
143:                return INTERNAL_MARKER + BOLD + str + INTERNAL_MARKER
144:                        + BOLD_OFF;
145:            }
146:
147:            //boldText
148:            public static String italicText(String str) {
149:                return INTERNAL_MARKER + ITALIC + str + INTERNAL_MARKER
150:                        + ITALIC_OFF;
151:            }
152:
153:            //italicText
154:            public static String underlinedText(String str) {
155:                return INTERNAL_MARKER + UNDERLINED + str + INTERNAL_MARKER
156:                        + UNDERLINED_OFF;
157:            }
158:
159:            //underlinedText
160:            public static String blinkingText(String str) {
161:                return INTERNAL_MARKER + BLINK + str + INTERNAL_MARKER
162:                        + BLINK_OFF;
163:            }
164:
165:            //blinkingText
166:            public static long getVisibleLength(String str) {
167:                int counter = 0;
168:                int parsecursor = 0;
169:                int foundcursor = 0;
170:                boolean done = false;
171:
172:                while (!done) {
173:                    foundcursor = str.indexOf(MARKER_CODE, parsecursor);
174:
175:                    if (foundcursor != -1) {
176:                        //increment counter
177:                        counter++;
178:
179:                        //parseon from the next char
180:                        parsecursor = foundcursor + 1;
181:                    } else {
182:                        done = true;
183:                    }
184:                }
185:
186:                return (str.length() - (counter * 2));
187:            }
188:
189:            //getVisibleLength
190:        }
191:
192:        //class ColorHelper
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.