Source Code Cross Referenced for AbstractShape.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hssf » model » 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.hssf.model 
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.hssf.model;
019:
020:        import org.apache.poi.ddf.*;
021:        import org.apache.poi.hssf.record.ObjRecord;
022:        import org.apache.poi.hssf.usermodel.*;
023:
024:        /**
025:         * An abstract shape is the lowlevel model for a shape.
026:         *
027:         * @author Glen Stampoultzis (glens at apache.org)
028:         */
029:        public abstract class AbstractShape {
030:            /**
031:             * Create a new shape object used to create the escher records.
032:             *
033:             * @param hssfShape     The simple shape this is based on.
034:             */
035:            public static AbstractShape createShape(HSSFShape hssfShape,
036:                    int shapeId) {
037:                AbstractShape shape;
038:                if (hssfShape instanceof  HSSFComment) {
039:                    shape = new CommentShape((HSSFComment) hssfShape, shapeId);
040:                } else if (hssfShape instanceof  HSSFTextbox) {
041:                    shape = new TextboxShape((HSSFTextbox) hssfShape, shapeId);
042:                } else if (hssfShape instanceof  HSSFPolygon) {
043:                    shape = new PolygonShape((HSSFPolygon) hssfShape, shapeId);
044:                } else if (hssfShape instanceof  HSSFSimpleShape) {
045:                    HSSFSimpleShape simpleShape = (HSSFSimpleShape) hssfShape;
046:                    switch (simpleShape.getShapeType()) {
047:                    case HSSFSimpleShape.OBJECT_TYPE_PICTURE:
048:                        shape = new PictureShape(simpleShape, shapeId);
049:                        break;
050:                    case HSSFSimpleShape.OBJECT_TYPE_LINE:
051:                        shape = new LineShape(simpleShape, shapeId);
052:                        break;
053:                    case HSSFSimpleShape.OBJECT_TYPE_OVAL:
054:                    case HSSFSimpleShape.OBJECT_TYPE_RECTANGLE:
055:                        shape = new SimpleFilledShape(simpleShape, shapeId);
056:                        break;
057:                    default:
058:                        throw new IllegalArgumentException(
059:                                "Do not know how to handle this type of shape");
060:                    }
061:                } else {
062:                    throw new IllegalArgumentException("Unknown shape type");
063:                }
064:                EscherSpRecord sp = shape.getSpContainer().getChildById(
065:                        EscherSpRecord.RECORD_ID);
066:                if (hssfShape.getParent() != null)
067:                    sp.setFlags(sp.getFlags() | EscherSpRecord.FLAG_CHILD);
068:                return shape;
069:            }
070:
071:            protected AbstractShape() {
072:            }
073:
074:            /**
075:             * @return  The shape container and it's children that can represent this
076:             *          shape.
077:             */
078:            public abstract EscherContainerRecord getSpContainer();
079:
080:            /**
081:             * @return  The object record that is associated with this shape.
082:             */
083:            public abstract ObjRecord getObjRecord();
084:
085:            /**
086:             * Creates an escher anchor record from a HSSFAnchor.
087:             *
088:             * @param userAnchor    The high level anchor to convert.
089:             * @return  An escher anchor record.
090:             */
091:            protected EscherRecord createAnchor(HSSFAnchor userAnchor) {
092:                return ConvertAnchor.createAnchor(userAnchor);
093:            }
094:
095:            /**
096:             * Add standard properties to the opt record.  These properties effect
097:             * all records.
098:             *
099:             * @param shape     The user model shape.
100:             * @param opt       The opt record to add the properties to.
101:             * @return          The number of options added.
102:             */
103:            protected int addStandardOptions(HSSFShape shape,
104:                    EscherOptRecord opt) {
105:                opt
106:                        .addEscherProperty(new EscherBoolProperty(
107:                                EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE,
108:                                0x080000));
109:                //        opt.addEscherProperty( new EscherBoolProperty( EscherProperties.TEXT__SIZE_TEXT_TO_FIT_SHAPE, 0x080008 ) );
110:                if (shape.isNoFill()) {
111:                    // Wonderful... none of the spec's give any clue as to what these constants mean.
112:                    opt.addEscherProperty(new EscherBoolProperty(
113:                            EscherProperties.FILL__NOFILLHITTEST, 0x00110000));
114:                } else {
115:                    opt.addEscherProperty(new EscherBoolProperty(
116:                            EscherProperties.FILL__NOFILLHITTEST, 0x00010000));
117:                }
118:                opt
119:                        .addEscherProperty(new EscherRGBProperty(
120:                                EscherProperties.FILL__FILLCOLOR, shape
121:                                        .getFillColor()));
122:                opt.addEscherProperty(new EscherBoolProperty(
123:                        EscherProperties.GROUPSHAPE__PRINT, 0x080000));
124:                opt.addEscherProperty(new EscherRGBProperty(
125:                        EscherProperties.LINESTYLE__COLOR, shape
126:                                .getLineStyleColor()));
127:                int options = 5;
128:                if (shape.getLineWidth() != HSSFShape.LINEWIDTH_DEFAULT) {
129:                    opt.addEscherProperty(new EscherSimpleProperty(
130:                            EscherProperties.LINESTYLE__LINEWIDTH, shape
131:                                    .getLineWidth()));
132:                    options++;
133:                }
134:                if (shape.getLineStyle() != HSSFShape.LINESTYLE_SOLID) {
135:                    opt.addEscherProperty(new EscherSimpleProperty(
136:                            EscherProperties.LINESTYLE__LINEDASHING, shape
137:                                    .getLineStyle()));
138:                    opt.addEscherProperty(new EscherSimpleProperty(
139:                            EscherProperties.LINESTYLE__LINEENDCAPSTYLE, 0));
140:                    if (shape.getLineStyle() == HSSFShape.LINESTYLE_NONE)
141:                        opt.addEscherProperty(new EscherBoolProperty(
142:                                EscherProperties.LINESTYLE__NOLINEDRAWDASH,
143:                                0x00080000));
144:                    else
145:                        opt.addEscherProperty(new EscherBoolProperty(
146:                                EscherProperties.LINESTYLE__NOLINEDRAWDASH,
147:                                0x00080008));
148:                    options += 3;
149:                }
150:                opt.sortProperties();
151:                return options; // # options added
152:            }
153:
154:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.