Source Code Cross Referenced for Fill.java in  » Collaboration » poi-3.0.2-beta2 » org » apache » poi » hslf » 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.hslf.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.hslf.model;
019:
020:        import org.apache.poi.ddf.*;
021:        import org.apache.poi.hslf.record.*;
022:        import org.apache.poi.hslf.usermodel.PictureData;
023:        import org.apache.poi.hslf.usermodel.SlideShow;
024:        import org.apache.poi.hslf.exceptions.HSLFException;
025:
026:        import java.awt.*;
027:        import java.util.*;
028:
029:        /**
030:         * Represents functionality provided by the 'Fill Effects' dialog in PowerPoint.
031:         *
032:         * @author Yegor Kozlov
033:         */
034:        public class Fill {
035:            /**
036:             *  Fill with a solid color
037:             */
038:            public static final int FILL_SOLID = 0;
039:
040:            /**
041:             *  Fill with a pattern (bitmap)
042:             */
043:            public static final int FILL_PATTERN = 1;
044:
045:            /**
046:             *  A texture (pattern with its own color map)
047:             */
048:            public static final int FILL_TEXTURE = 2;
049:
050:            /**
051:             *  Center a picture in the shape
052:             */
053:            public static final int FILL_PICTURE = 3;
054:
055:            /**
056:             *  Shade from start to end points
057:             */
058:            public static final int FILL_SHADE = 4;
059:
060:            /**
061:             *  Shade from bounding rectangle to end point
062:             */
063:            public static final int FILL_SHADE_CENTER = 5;
064:
065:            /**
066:             *  Shade from shape outline to end point
067:             */
068:            public static final int FILL_SHADE_SHAPE = 6;
069:
070:            /**
071:             *  Similar to FILL_SHADE, but the fill angle
072:             *  is additionally scaled by the aspect ratio of
073:             *  the shape. If shape is square, it is the same as FILL_SHADE
074:             */
075:            public static final int FILL_SHADE_SCALE = 7;
076:
077:            /**
078:             *  shade to title
079:             */
080:            public static final int FILL_SHADE_TITLE = 8;
081:
082:            /**
083:             *  Use the background fill color/pattern
084:             */
085:            public static final int FILL_BACKGROUND = 9;
086:
087:            /**
088:             * The shape this background applies to
089:             */
090:            protected Shape shape;
091:
092:            /**
093:             * Construct a <code>Fill</code> object for a shape.
094:             * Fill information will be read from shape's escher properties.
095:             *
096:             * @param shape the shape this background applies to
097:             */
098:            public Fill(Shape shape) {
099:                this .shape = shape;
100:            }
101:
102:            /**
103:             * Returns fill type.
104:             * Must be one of the <code>FILL_*</code> constants defined in this class.
105:             *
106:             * @return type of fill
107:             */
108:            public int getFillType() {
109:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
110:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
111:                EscherSimpleProperty prop = (EscherSimpleProperty) Shape
112:                        .getEscherProperty(opt, EscherProperties.FILL__FILLTYPE);
113:                return prop == null ? FILL_SOLID : prop.getPropertyValue();
114:            }
115:
116:            /**
117:             * Sets fill type.
118:             * Must be one of the <code>FILL_*</code> constants defined in this class.
119:             *
120:             * @param type type of the fill
121:             */
122:            public void setFillType(int type) {
123:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
124:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
125:                Shape.setEscherProperty(opt, EscherProperties.FILL__FILLTYPE,
126:                        type);
127:            }
128:
129:            /**
130:             * Foreground color
131:             */
132:            public Color getForegroundColor() {
133:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
134:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
135:                EscherSimpleProperty p1 = (EscherSimpleProperty) Shape
136:                        .getEscherProperty(opt,
137:                                EscherProperties.FILL__FILLCOLOR);
138:                EscherSimpleProperty p2 = (EscherSimpleProperty) Shape
139:                        .getEscherProperty(opt,
140:                                EscherProperties.FILL__NOFILLHITTEST);
141:
142:                int p2val = p2 == null ? 0 : p2.getPropertyValue();
143:
144:                Color clr = null;
145:                if (p1 != null && (p2val & 0x10) != 0) {
146:                    int rgb = p1.getPropertyValue();
147:                    clr = shape.getColor(rgb);
148:                }
149:                return clr;
150:            }
151:
152:            /**
153:             * Foreground color
154:             */
155:            public void setForegroundColor(Color color) {
156:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
157:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
158:                if (color == null) {
159:                    Shape.setEscherProperty(opt,
160:                            EscherProperties.FILL__FILLCOLOR, -1);
161:                    Shape.setEscherProperty(opt,
162:                            EscherProperties.FILL__NOFILLHITTEST, 0x150010);
163:                } else {
164:                    int rgb = new Color(color.getBlue(), color.getGreen(),
165:                            color.getRed(), 0).getRGB();
166:                    Shape.setEscherProperty(opt,
167:                            EscherProperties.FILL__FILLCOLOR, rgb);
168:                    Shape.setEscherProperty(opt,
169:                            EscherProperties.FILL__NOFILLHITTEST, 0x150011);
170:                }
171:            }
172:
173:            /**
174:             * Background color
175:             */
176:            public Color getBackgroundColor() {
177:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
178:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
179:                EscherSimpleProperty p1 = (EscherSimpleProperty) Shape
180:                        .getEscherProperty(opt,
181:                                EscherProperties.FILL__FILLBACKCOLOR);
182:                EscherSimpleProperty p2 = (EscherSimpleProperty) Shape
183:                        .getEscherProperty(opt,
184:                                EscherProperties.FILL__NOFILLHITTEST);
185:
186:                int p2val = p2 == null ? 0 : p2.getPropertyValue();
187:
188:                Color clr = null;
189:                if (p1 != null && (p2val & 0x10) != 0) {
190:                    int rgb = p1.getPropertyValue();
191:                    clr = shape.getColor(rgb);
192:                }
193:                return clr;
194:            }
195:
196:            /**
197:             * Background color
198:             */
199:            public void setBackgroundColor(Color color) {
200:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
201:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
202:                if (color == null) {
203:                    Shape.setEscherProperty(opt,
204:                            EscherProperties.FILL__FILLBACKCOLOR, -1);
205:                } else {
206:                    int rgb = new Color(color.getBlue(), color.getGreen(),
207:                            color.getRed(), 0).getRGB();
208:                    Shape.setEscherProperty(opt,
209:                            EscherProperties.FILL__FILLBACKCOLOR, rgb);
210:                }
211:            }
212:
213:            /**
214:             * <code>PictureData</code> object used in a texture, pattern of picture fill.
215:             */
216:            public PictureData getPictureData() {
217:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
218:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
219:                EscherSimpleProperty p = (EscherSimpleProperty) Shape
220:                        .getEscherProperty(opt,
221:                                EscherProperties.FILL__PATTERNTEXTURE);
222:                if (p == null)
223:                    return null;
224:
225:                SlideShow ppt = shape.getSheet().getSlideShow();
226:                PictureData[] pict = ppt.getPictureData();
227:                Document doc = ppt.getDocumentRecord();
228:
229:                EscherContainerRecord dggContainer = doc.getPPDrawingGroup()
230:                        .getDggContainer();
231:                EscherContainerRecord bstore = (EscherContainerRecord) Shape
232:                        .getEscherChild(dggContainer,
233:                                EscherContainerRecord.BSTORE_CONTAINER);
234:
235:                java.util.List lst = bstore.getChildRecords();
236:                int idx = p.getPropertyValue();
237:                EscherBSERecord bse = (EscherBSERecord) lst.get(idx);
238:                for (int i = 0; i < pict.length; i++) {
239:                    if (pict[i].getOffset() == bse.getOffset()) {
240:                        return pict[i];
241:                    }
242:                }
243:                throw new HSLFException("Picture data not found: \n"
244:                        + "  bse: " + bse + " at " + bse.getOffset());
245:
246:            }
247:
248:            /**
249:             * Assign picture used to fill the underlying shape.
250:             *
251:             * @param idx 0-based index of the picture added to this ppt by <code>SlideShow.addPicture</code> method. 
252:             */
253:            public void setPictureData(int idx) {
254:                EscherOptRecord opt = (EscherOptRecord) Shape.getEscherChild(
255:                        shape.getSpContainer(), EscherOptRecord.RECORD_ID);
256:                Shape
257:                        .setEscherProperty(
258:                                opt,
259:                                (short) (EscherProperties.FILL__PATTERNTEXTURE + 0x4000),
260:                                idx);
261:            }
262:
263:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.