Source Code Cross Referenced for MapDef.java in  » Net » Remote-desktop » org » rdesktop » server » rdp » keymapping » 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 » Remote desktop » org.rdesktop.server.rdp.keymapping 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        ///////////////////////////////////////////////////////////////////////////////
002:        //
003:        //   This program is free software; you can redistribute it and/or modify
004:        //   it under the terms of the GNU General Public License and GNU Library
005:        //   General Public License as published by the Free Software Foundation;
006:        //   either version 2, or (at your option) any later version.
007:        //
008:        //   This program is distributed in the hope that it will be useful,
009:        //   but WITHOUT ANY WARRANTY; without even the implied warranty of
010:        //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
011:        //   GNU General Public License and GNU Library General Public License
012:        //   for more details.
013:        //
014:        //   You should have received a copy of the GNU General Public License
015:        //   and GNU Library General Public License along with this program; if
016:        //   not, write to the Free Software Foundation, 675 Mass Ave, Cambridge,
017:        //   MA 02139, USA.
018:        //
019:        ///////////////////////////////////////////////////////////////////////////////
020:
021:        package org.rdesktop.server.rdp.keymapping;
022:
023:        import java.io.*;
024:        import java.util.*;
025:        import java.awt.event.KeyEvent;
026:
027:        import org.rdesktop.server.rdp.RdpOptions;
028:
029:        public class MapDef {
030:            private final int FLAG_SHIFT = 0x01;
031:            private final int FLAG_CTRL = 0x02;
032:            private final int FLAG_ALT = 0x04;
033:            private final int FLAG_CAPSLOCK = 0x08;
034:
035:            private int m_scancode;
036:            private boolean m_altDown;
037:            private boolean m_ctrlDown;
038:            private boolean m_shiftDown;
039:            private boolean m_capslockDown;
040:
041:            private char m_keyChar;
042:            private int m_keyCode;
043:            private int m_keyLocation;
044:            private boolean m_characterDef;
045:
046:            public MapDef(char keyChar, int keyLocation, int scancode,
047:                    boolean ctrlDown, boolean shiftDown, boolean altDown,
048:                    boolean capslockDown) {
049:                m_keyChar = keyChar;
050:                m_characterDef = true;
051:
052:                m_keyLocation = keyLocation;
053:                m_scancode = scancode;
054:                m_ctrlDown = ctrlDown;
055:                m_altDown = altDown;
056:                m_shiftDown = shiftDown;
057:                m_capslockDown = capslockDown;
058:            }
059:
060:            public MapDef(int keyCode, int keyLocation, int scancode,
061:                    boolean ctrlDown, boolean shiftDown, boolean altDown,
062:                    boolean capslockDown) {
063:                m_keyCode = keyCode;
064:                m_characterDef = false;
065:
066:                m_keyLocation = keyLocation;
067:                m_scancode = scancode;
068:                m_ctrlDown = ctrlDown;
069:                m_altDown = altDown;
070:                m_shiftDown = shiftDown;
071:                m_capslockDown = capslockDown;
072:            }
073:
074:            public MapDef(String definition) throws KeyMapException {
075:                try {
076:                    StringTokenizer st = new StringTokenizer(definition);
077:                    m_characterDef = ((Integer.parseInt(st.nextToken()) == 1) ? true
078:                            : false);
079:
080:                    if (m_characterDef == true) {
081:                        m_keyChar = (char) Integer.parseInt(st.nextToken());
082:                    } else {
083:                        m_keyCode = Integer.parseInt(st.nextToken());
084:                    }
085:
086:                    m_keyLocation = Integer.parseInt(st.nextToken());
087:                    m_scancode = Integer.decode(st.nextToken()).intValue();
088:
089:                    int modifiers = Integer.parseInt(st.nextToken());
090:                    m_shiftDown = ((modifiers & FLAG_SHIFT) != 0);
091:                    m_ctrlDown = ((modifiers & FLAG_CTRL) != 0);
092:                    m_altDown = ((modifiers & FLAG_ALT) != 0);
093:                    m_capslockDown = ((modifiers & FLAG_CAPSLOCK) != 0);
094:                } catch (NumberFormatException nfEx) {
095:                    throw new KeyMapException("" + nfEx.getMessage()
096:                            + " is not numeric");
097:                } catch (NoSuchElementException nseEx) {
098:                    throw new KeyMapException(
099:                            "Not enough parameters in definition");
100:                }
101:            }
102:
103:            protected boolean appliesToTyped(KeyEvent e) {
104:                return ((m_characterDef == true) && (m_keyChar == e
105:                        .getKeyChar()));
106:            }
107:
108:            protected boolean appliesToTyped(KeyEvent e, boolean capslock) {
109:                return ((m_characterDef) && (m_keyChar == e.getKeyChar()));
110:            }
111:
112:            protected boolean appliesToPressed(KeyEvent e) {
113:                if (m_characterDef == false) {
114:                    if ((((m_ctrlDown == true) && (e.isControlDown() == true)) || (m_ctrlDown == false)) == false) {
115:                        return false;
116:                    }
117:
118:                    if ((((m_altDown == true) && (e.isAltDown() == true)) || (m_altDown == false)) == false) {
119:                        return false;
120:                    }
121:                }
122:
123:                return ((m_characterDef == false) && (m_keyCode == e
124:                        .getKeyCode()));
125:            }
126:
127:            public int getKeyCode() {
128:                return m_keyCode;
129:            }
130:
131:            public char getKeyChar() {
132:                return m_keyChar;
133:            }
134:
135:            public int getScancode() {
136:                return m_scancode;
137:            }
138:
139:            public boolean isCharacterDef() {
140:                return m_characterDef;
141:            }
142:
143:            public boolean isCtrlDown() {
144:                return m_ctrlDown;
145:            }
146:
147:            public boolean isAltDown() {
148:                return m_altDown;
149:            }
150:
151:            public boolean isShiftDown() {
152:                return m_shiftDown;
153:            }
154:
155:            public boolean isCapslockOn() {
156:                return m_capslockDown;
157:            }
158:
159:            public int modifierDistance(KeyEvent e, boolean capslock) {
160:                if (m_characterDef == false) {
161:                    return 0;
162:                }
163:
164:                int dist = 0;
165:                if (m_ctrlDown != e.isControlDown()) {
166:                    dist += 1;
167:                }
168:
169:                if (m_altDown != e.isAltDown()) {
170:                    dist += 1;
171:                }
172:
173:                if (m_shiftDown != e.isShiftDown()) {
174:                    dist += 1;
175:                }
176:
177:                if (m_capslockDown != capslock) {
178:                    dist += 1;
179:                }
180:
181:                return dist;
182:            }
183:
184:            public boolean appliesTo(char c) {
185:                return ((m_characterDef == true) && (m_keyChar == c) && (m_capslockDown == false));
186:            }
187:
188:            public void writeToStream(PrintStream printStream) {
189:                String definition = "" + (m_characterDef ? 1 : 0);
190:
191:                definition += "\t";
192:                if (m_characterDef == true) {
193:                    definition += (int) m_keyChar;
194:                } else {
195:                    definition += m_keyCode;
196:                }
197:
198:                definition += "\t" + m_keyLocation;
199:                definition += "\t0x" + Integer.toHexString(m_scancode);
200:
201:                int modifiers = 0;
202:                modifiers |= (m_shiftDown ? FLAG_SHIFT : 0);
203:                modifiers |= (m_ctrlDown ? FLAG_CTRL : 0);
204:                modifiers |= (m_altDown ? FLAG_ALT : 0);
205:                modifiers |= (m_capslockDown ? FLAG_CAPSLOCK : 0);
206:                definition += "\t" + modifiers;
207:
208:                if (m_characterDef == false) {
209:                    definition += "\t" + KeyEvent.getKeyText(m_keyCode);
210:                }
211:
212:                printStream.println(definition);
213:            }
214:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.