Source Code Cross Referenced for RecordStore.java in  » XML-UI » XUI » net » xoetrope » xui » wmf » 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 » XML UI » XUI » net.xoetrope.xui.wmf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)Jmf.java 2.00 28/4/1999
003:         *
004:         * Copyright (c) 1997-9 Axiom Software Development Ltd..
005:         * All Rights Reserved.
006:         *
007:         * Permission to use, copy, modify, and distribute this
008:         * software and its documentation for NON-COMMERCIAL purposes
009:         * and without fee is hereby granted provided that this
010:         * copyright notice appears in all copies. Please refer to
011:         * the file "copyright.html" for further important copyright
012:         * and licensing information.
013:         *
014:         * ASD MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE
015:         * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED,
016:         * INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
017:         * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
018:         * NON-INFRINGEMENT. ASD SHALL NOT BE LIABLE FOR ANY DAMAGES
019:         * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
020:         * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
021:         * $Revision: 1.12 $
022:         */
023:        package net.xoetrope.xui.wmf;
024:
025:        import java.io.DataInputStream;
026:        import java.io.IOException;
027:        import java.net.URL;
028:        import java.util.Vector;
029:
030:        /**
031:         * An object that stores the vector graphics records.
032:         * @version 2.00
033:         */
034:        public class RecordStore {
035:
036:            public RecordStore() {
037:                reset();
038:            }
039:
040:            /**
041:             * Resets the internal storage and viewport coordinates.
042:             */
043:            public void reset() {
044:                numRecords = 0;
045:                vpX = 0;
046:                vpY = 0;
047:                vpW = 1000;
048:                vpH = 1000;
049:                numObjects = 0;
050:                records = new Vector(20, 20);
051:                objectVector = new Vector();
052:            }
053:
054:            synchronized void setReading(boolean state) {
055:                bReading = state;
056:            }
057:
058:            synchronized boolean isReading() {
059:                return bReading;
060:            }
061:
062:            /**
063:             * Reads the JMF file from the specified Stream.
064:             * A JMF file can be produced using the GConvert utility found at
065:             * http://www.asd.ie/jmf.htm
066:             *
067:             * The JMF format is slightly more compact than the original WMF format and
068:             * in some cases may produce better handling of colours.
069:             */
070:            public boolean read(DataInputStream is) throws IOException {
071:                setReading(true);
072:                reset();
073:
074:                int functionId = 0;
075:                numRecords = 0;
076:
077:                numObjects = is.readShort();
078:                objectVector.ensureCapacity(numObjects);
079:                for (int i = 0; i < numObjects; i++) {
080:                    objectVector.addElement(new GdiObject(i, false));
081:                }
082:
083:                while (functionId != -1) {
084:                    functionId = is.readShort();
085:                    if (functionId == -1)
086:                        break;
087:
088:                    MetaRecord mr;
089:                    switch (functionId) {
090:                    case 0x0521:
091:                    case 0x062F:
092:                    case 0x0a32:
093:                    case 0x02FB: {
094:                        short len = is.readShort();
095:                        byte[] b = new byte[len];
096:                        for (int i = 0; i < len; i++)
097:                            b[i] = is.readByte();
098:                        String str = new String(b);
099:                        mr = new StringRecord(str);
100:                    }
101:                        break;
102:
103:                    default:
104:                        mr = new MetaRecord();
105:                        break;
106:                    }
107:
108:                    int numPts = is.readShort();
109:                    mr.numPoints = numPts;
110:                    mr.functionId = functionId;
111:
112:                    for (int j = 0; j < numPts; j++)
113:                        mr.AddElement(new Integer(is.readShort()));
114:
115:                    records.addElement(mr);
116:
117:                    numRecords++;
118:                }
119:
120:                setReading(false);
121:                return true;
122:            }
123:
124:            /**
125:             * Adds a GdiObject to the internal handle table.
126:             * Adds the object at the next free location.
127:             *
128:             * This function should not normally be called by an application.
129:             */
130:            public int addObject(int type, Object obj) {
131:                for (int i = 0; i < numObjects; i++) {
132:                    GdiObject gdi = (GdiObject) objectVector.elementAt(i);
133:                    if (gdi.used == false) {
134:                        gdi.Setup(type, obj);
135:                        lastObjectIdx = i;
136:                        return i;
137:                    }
138:                }
139:                return -1;
140:            }
141:
142:            /**
143:             * Adds a GdiObject to the internal handle table.
144:             * JMF files specify the index as given in EMF records such as
145:             * EMRCREATEPENINDIRECT whereas WMF files always use 0.
146:             *
147:             * This function should not normally be called by an application.
148:             */
149:            public int addObjectAt(int type, Object obj, int idx) {
150:                if ((idx == 0) || (idx > numObjects)) {
151:                    return addObject(type, obj);
152:                }
153:                lastObjectIdx = idx;
154:                for (int i = 0; i < numObjects; i++) {
155:                    GdiObject gdi = (GdiObject) objectVector.elementAt(i);
156:                    if (i == idx) {
157:                        gdi.Setup(type, obj);
158:                        return i;
159:                    }
160:                }
161:                return -1;
162:            }
163:
164:            /**
165:             * Returns the current URL
166:             */
167:            public URL getUrl() {
168:                return url;
169:            }
170:
171:            /**
172:             * Sets the current URL
173:             */
174:            public void setUrl(URL newUrl) {
175:                url = newUrl;
176:            }
177:
178:            /**
179:             * Returns a GdiObject from the handle table
180:             */
181:            public GdiObject getObject(int idx) {
182:                return (GdiObject) objectVector.elementAt(idx);
183:            }
184:
185:            /**
186:             * Returns a meta record.
187:             */
188:            public MetaRecord getRecord(int idx) {
189:                return (MetaRecord) records.elementAt(idx);
190:            }
191:
192:            /**
193:             * Returns a number of records in the image
194:             */
195:            public int getNumRecords() {
196:                return numRecords;
197:            }
198:
199:            /**
200:             * Returns the number of GdiObjects in the handle table
201:             */
202:            public int getNumObjects() {
203:                return numObjects;
204:            }
205:
206:            /**
207:             * Returns the viewport x origin
208:             */
209:            public int getVpX() {
210:                return vpX;
211:            }
212:
213:            /**
214:             * Returns the viewport y origin
215:             */
216:            public int getVpY() {
217:                return vpY;
218:            }
219:
220:            /**
221:             * Returns the viewport width
222:             */
223:            public int getVpW() {
224:                return vpW;
225:            }
226:
227:            /**
228:             * Returns the viewport height
229:             */
230:            public int getVpH() {
231:                return vpH;
232:            }
233:
234:            /**
235:             * Sets the viewport x origin
236:             */
237:            public void setVpX(int newValue) {
238:                vpX = newValue;
239:            }
240:
241:            /**
242:             * Sets the viewport y origin
243:             */
244:            public void setVpY(int newValue) {
245:                vpY = newValue;
246:            }
247:
248:            /**
249:             * Sets the viewport width
250:             */
251:            public void setVpW(int newValue) {
252:                vpW = newValue;
253:            }
254:
255:            /**
256:             * Sets the viewport height
257:             */
258:            public void setVpH(int newValue) {
259:                vpH = newValue;
260:            }
261:
262:            transient private URL url;
263:
264:            transient protected int numRecords;
265:            transient protected int numObjects;
266:            transient public int lastObjectIdx;
267:            transient protected int vpX, vpY, vpW, vpH;
268:            transient protected Vector records;
269:            transient protected Vector objectVector;
270:
271:            transient protected boolean bReading = false;
272:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.