Source Code Cross Referenced for RdpCache.java in  » Net » Remote-desktop » org » rdesktop » server » rdp » 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 
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;
022:
023:        import java.awt.Cursor;
024:        import java.awt.image.IndexColorModel;
025:
026:        public class RdpCache {
027:            private static final int RDPCACHE_COLOURMAPSIZE = 0x06; // unified patch
028:
029:            private RdpBitmap[][] bitmapcache = new RdpBitmap[3][600];
030:            private Cursor[] cursorcache = new Cursor[32];
031:            private RdpGlyph[][] fontcache = new RdpGlyph[12][256];
032:            private RdpDataBlob[] textcache = new RdpDataBlob[256];
033:            private int[] highdeskcache = new int[921600];
034:            private int num_bitmaps_in_memory[] = new int[3];
035:            private IndexColorModel[] colourcache = new IndexColorModel[RDPCACHE_COLOURMAPSIZE];
036:
037:            public RdpCache() {
038:            }
039:
040:            protected void removeLRUBitmap(int cache_id) {
041:                int i;
042:                int cache_idx = 0;
043:                int m = 0xffffffff;
044:
045:                for (i = 0; i < bitmapcache[cache_id].length; i++) {
046:                    if ((bitmapcache[cache_id][i] != null)
047:                            && (bitmapcache[cache_id][i].getBitmapData() != null)
048:                            && (bitmapcache[cache_id][i].usage < m)) {
049:                        cache_idx = i;
050:                        m = bitmapcache[cache_id][i].usage;
051:                    }
052:                }
053:
054:                bitmapcache[cache_id][cache_idx] = null;
055:                --num_bitmaps_in_memory[cache_id];
056:            }
057:
058:            public IndexColorModel get_colourmap(int cache_id)
059:                    throws RdpDesktopException {
060:                IndexColorModel map = null;
061:                if (cache_id < colourcache.length) {
062:                    map = colourcache[cache_id];
063:                    if (map != null) {
064:                        return map;
065:                    }
066:                }
067:
068:                throw new RdpDesktopException(
069:                        "Could not get colourmap with cache_id=" + cache_id);
070:            }
071:
072:            public void put_colourmap(int cache_id, IndexColorModel map)
073:                    throws RdpDesktopException {
074:                if (cache_id < colourcache.length) {
075:                    colourcache[cache_id] = map;
076:                } else {
077:                    throw new RdpDesktopException(
078:                            "Could not put colourmap with cache_id=" + cache_id);
079:                }
080:            }
081:
082:            public RdpBitmap getBitmap(int cache_id, int cache_idx)
083:                    throws RdpDesktopException {
084:                RdpBitmap bitmap = null;
085:
086:                if ((cache_id < bitmapcache.length)
087:                        && (cache_idx < bitmapcache[0].length)) {
088:                    bitmap = bitmapcache[cache_id][cache_idx];
089:
090:                    if (bitmap != null) {
091:                        return bitmap;
092:                    }
093:                }
094:
095:                throw new RdpDesktopException("Could not get Bitmap!");
096:            }
097:
098:            public void putBitmap(int cache_id, int cache_idx,
099:                    RdpBitmap bitmap, int stamp) throws RdpDesktopException {
100:                if ((cache_id < bitmapcache.length)
101:                        && (cache_idx < bitmapcache[0].length)) {
102:                    bitmapcache[cache_id][cache_idx] = bitmap;
103:                } else {
104:                    throw new RdpDesktopException("Could not put Bitmap!");
105:                }
106:            }
107:
108:            public Cursor getCursor(int cache_idx) throws RdpDesktopException {
109:                Cursor cursor = null;
110:
111:                if (cache_idx < cursorcache.length) {
112:                    cursor = cursorcache[cache_idx];
113:                    if (cursor != null) {
114:                        return cursor;
115:                    }
116:                }
117:
118:                throw new RdpDesktopException("Cursor not found");
119:            }
120:
121:            public void putCursor(int cache_idx, Cursor cursor)
122:                    throws RdpDesktopException {
123:                if (cache_idx < cursorcache.length) {
124:                    cursorcache[cache_idx] = cursor;
125:                } else {
126:                    throw new RdpDesktopException("Could not put Cursor!");
127:                }
128:            }
129:
130:            public void putFont(RdpGlyph glyph) throws RdpDesktopException {
131:                if ((glyph.getFont() < fontcache.length)
132:                        && (glyph.getCharacter() < fontcache[0].length)) {
133:                    fontcache[glyph.getFont()][glyph.getCharacter()] = glyph;
134:                } else {
135:                    throw new RdpDesktopException("Could not put font");
136:                }
137:            }
138:
139:            public RdpGlyph getFont(int font, int character)
140:                    throws RdpDesktopException {
141:                if ((font < fontcache.length)
142:                        && (character < fontcache[0].length)) {
143:                    RdpGlyph glyph = fontcache[font][character];
144:
145:                    if (glyph != null) {
146:                        return glyph;
147:                    }
148:                }
149:
150:                throw new RdpDesktopException("Could not get Font:" + font
151:                        + ", " + character);
152:            }
153:
154:            public RdpDataBlob getText(int cache_id) throws RdpDesktopException {
155:                RdpDataBlob entry = null;
156:
157:                if (cache_id < textcache.length) {
158:                    entry = textcache[cache_id];
159:                    if (entry != null) {
160:                        if (entry.getData() != null) {
161:                            return entry;
162:                        }
163:                    }
164:                }
165:
166:                throw new RdpDesktopException("Could not get Text:" + cache_id);
167:            }
168:
169:            public void putText(int cache_id, RdpDataBlob entry)
170:                    throws RdpDesktopException {
171:                if (cache_id < textcache.length) {
172:                    textcache[cache_id] = entry;
173:                } else {
174:                    throw new RdpDesktopException("Could not put Text");
175:                }
176:            }
177:
178:            public void putDesktop(int offset, int cx, int cy, int[] data)
179:                    throws RdpDesktopException {
180:                int length = cx * cy;
181:                int pdata = 0;
182:
183:                if (offset > highdeskcache.length) {
184:                    offset = 0;
185:                }
186:
187:                if ((int) offset + length <= highdeskcache.length) {
188:                    for (int i = 0; i < cy; i++) {
189:                        System
190:                                .arraycopy(data, pdata, highdeskcache, offset,
191:                                        cx);
192:                        offset += cx;
193:                        pdata += cx;
194:                    }
195:                } else {
196:                    throw new RdpDesktopException("Could not put Desktop");
197:                }
198:            }
199:
200:            public int[] getDesktopInt(int offset, int cx, int cy)
201:                    throws RdpDesktopException {
202:                int length = cx * cy;
203:                int pdata = 0;
204:                int[] data = new int[length];
205:
206:                if (offset > highdeskcache.length) {
207:                    offset = 0;
208:                }
209:
210:                if ((int) offset + length <= highdeskcache.length) {
211:                    for (int i = 0; i < cy; i++) {
212:                        System
213:                                .arraycopy(highdeskcache, offset, data, pdata,
214:                                        cx);
215:                        offset += cx;
216:                        pdata += cx;
217:                    }
218:
219:                    return data;
220:                }
221:
222:                throw new RdpDesktopException("Could not get Bitmap");
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.