Source Code Cross Referenced for EscherSpgrRecord.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » ddf » 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 » Collaboration » poi 3.0.2 beta2 » org.apache.poi.ddf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ====================================================================
002:         Licensed to the Apache Software Foundation (ASF) under one or more
003:         contributor license agreements.  See the NOTICE file distributed with
004:         this work for additional information regarding copyright ownership.
005:         The ASF licenses this file to You under the Apache License, Version 2.0
006:         (the "License"); you may not use this file except in compliance with
007:         the License.  You may obtain a copy of the License at
008:
009:         http://www.apache.org/licenses/LICENSE-2.0
010:
011:         Unless required by applicable law or agreed to in writing, software
012:         distributed under the License is distributed on an "AS IS" BASIS,
013:         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         See the License for the specific language governing permissions and
015:         limitations under the License.
016:         ==================================================================== */
017:
018:        package org.apache.poi.ddf;
019:
020:        import org.apache.poi.util.HexDump;
021:        import org.apache.poi.util.LittleEndian;
022:        import org.apache.poi.hssf.record.RecordFormatException;
023:
024:        /**
025:         * The spgr record defines information about a shape group.  Groups in escher
026:         * are simply another form of shape that you can't physically see.
027:         *
028:         * @author Glen Stampoultzis (glens at apache.org)
029:         */
030:        public class EscherSpgrRecord extends EscherRecord {
031:            public static final short RECORD_ID = (short) 0xF009;
032:            public static final String RECORD_DESCRIPTION = "MsofbtSpgr";
033:
034:            private int field_1_rectX1;
035:            private int field_2_rectY1;
036:            private int field_3_rectX2;
037:            private int field_4_rectY2;
038:
039:            /**
040:             * This method deserializes the record from a byte array.
041:             *
042:             * @param data          The byte array containing the escher record information
043:             * @param offset        The starting offset into <code>data</code>.
044:             * @param recordFactory May be null since this is not a container record.
045:             * @return The number of bytes read from the byte array.
046:             */
047:            public int fillFields(byte[] data, int offset,
048:                    EscherRecordFactory recordFactory) {
049:                int bytesRemaining = readHeader(data, offset);
050:                int pos = offset + 8;
051:                int size = 0;
052:                field_1_rectX1 = LittleEndian.getInt(data, pos + size);
053:                size += 4;
054:                field_2_rectY1 = LittleEndian.getInt(data, pos + size);
055:                size += 4;
056:                field_3_rectX2 = LittleEndian.getInt(data, pos + size);
057:                size += 4;
058:                field_4_rectY2 = LittleEndian.getInt(data, pos + size);
059:                size += 4;
060:                bytesRemaining -= size;
061:                if (bytesRemaining != 0)
062:                    throw new RecordFormatException(
063:                            "Expected no remaining bytes but got "
064:                                    + bytesRemaining);
065:                //        remainingData  =  new byte[bytesRemaining];
066:                //        System.arraycopy( data, pos + size, remainingData, 0, bytesRemaining );
067:                return 8 + size + bytesRemaining;
068:            }
069:
070:            /**
071:             * This method serializes this escher record into a byte array.
072:             *
073:             * @param offset   The offset into <code>data</code> to start writing the record data to.
074:             * @param data     The byte array to serialize to.
075:             * @param listener A listener to retrieve start and end callbacks.  Use a <code>NullEscherSerailizationListener</code> to ignore these events.
076:             * @return The number of bytes written.
077:             *
078:             * @see NullEscherSerializationListener
079:             */
080:            public int serialize(int offset, byte[] data,
081:                    EscherSerializationListener listener) {
082:                listener.beforeRecordSerialize(offset, getRecordId(), this );
083:                LittleEndian.putShort(data, offset, getOptions());
084:                LittleEndian.putShort(data, offset + 2, getRecordId());
085:                int remainingBytes = 16;
086:                LittleEndian.putInt(data, offset + 4, remainingBytes);
087:                LittleEndian.putInt(data, offset + 8, field_1_rectX1);
088:                LittleEndian.putInt(data, offset + 12, field_2_rectY1);
089:                LittleEndian.putInt(data, offset + 16, field_3_rectX2);
090:                LittleEndian.putInt(data, offset + 20, field_4_rectY2);
091:                //        System.arraycopy( remainingData, 0, data, offset + 26, remainingData.length );
092:                //        int pos = offset + 8 + 18 + remainingData.length;
093:                listener.afterRecordSerialize(offset + getRecordSize(),
094:                        getRecordId(), offset + getRecordSize(), this );
095:                return 8 + 16;
096:            }
097:
098:            /**
099:             * Returns the number of bytes that are required to serialize this record.
100:             *
101:             * @return Number of bytes
102:             */
103:            public int getRecordSize() {
104:                return 8 + 16;
105:            }
106:
107:            /**
108:             * The 16 bit identifier of this shape group record.
109:             */
110:            public short getRecordId() {
111:                return RECORD_ID;
112:            }
113:
114:            /**
115:             * The short name for this record
116:             */
117:            public String getRecordName() {
118:                return "Spgr";
119:            }
120:
121:            /**
122:             * @return  the string representation of this record.
123:             */
124:            public String toString() {
125:                String nl = System.getProperty("line.separator");
126:
127:                //        String extraData;
128:                //        ByteArrayOutputStream b = new ByteArrayOutputStream();
129:                //        try
130:                //        {
131:                //            HexDump.dump(this.remainingData, 0, b, 0);
132:                //            extraData = b.toString();
133:                //        }
134:                //        catch ( Exception e )
135:                //        {
136:                //            extraData = "error";
137:                //        }
138:                return getClass().getName() + ":" + nl + "  RecordId: 0x"
139:                        + HexDump.toHex(RECORD_ID) + nl + "  Options: 0x"
140:                        + HexDump.toHex(getOptions()) + nl + "  RectX: "
141:                        + field_1_rectX1 + nl + "  RectY: " + field_2_rectY1
142:                        + nl + "  RectWidth: " + field_3_rectX2 + nl
143:                        + "  RectHeight: " + field_4_rectY2 + nl;
144:
145:            }
146:
147:            /**
148:             * The starting top-left coordinate of child records.
149:             */
150:            public int getRectX1() {
151:                return field_1_rectX1;
152:            }
153:
154:            /**
155:             * The starting top-left coordinate of child records.
156:             */
157:            public void setRectX1(int x1) {
158:                this .field_1_rectX1 = x1;
159:            }
160:
161:            /**
162:             * The starting top-left coordinate of child records.
163:             */
164:            public int getRectY1() {
165:                return field_2_rectY1;
166:            }
167:
168:            /**
169:             * The starting top-left coordinate of child records.
170:             */
171:            public void setRectY1(int y1) {
172:                this .field_2_rectY1 = y1;
173:            }
174:
175:            /**
176:             * The starting bottom-right coordinate of child records.
177:             */
178:            public int getRectX2() {
179:                return field_3_rectX2;
180:            }
181:
182:            /**
183:             * The starting bottom-right coordinate of child records.
184:             */
185:            public void setRectX2(int x2) {
186:                this .field_3_rectX2 = x2;
187:            }
188:
189:            /**
190:             * The starting bottom-right coordinate of child records.
191:             */
192:            public int getRectY2() {
193:                return field_4_rectY2;
194:            }
195:
196:            /**
197:             * The starting bottom-right coordinate of child records.
198:             */
199:            public void setRectY2(int field_4_rectY2) {
200:                this.field_4_rectY2 = field_4_rectY2;
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.