Source Code Cross Referenced for BandToplevelReportElement.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » 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 » Report » pentaho report » org.pentaho.reportdesigner.crm.report.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2006-2007 Pentaho Corporation.  All rights reserved.
003:         * This software was developed by Pentaho Corporation and is provided under the terms
004:         * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005:         * this file except in compliance with the license. If you need a copy of the license,
006:         * please go to http://www.mozilla.org/MPL/MPL-1.1.txt.
007:         *
008:         * Software distributed under the Mozilla Public License is distributed on an "AS IS"
009:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to
010:         * the license for the specific language governing your rights and limitations.
011:         *
012:         * Additional Contributor(s): Martin Schmid gridvision engineering GmbH
013:         */
014:        package org.pentaho.reportdesigner.crm.report.model;
015:
016:        import org.gjt.xpp.XmlPullNode;
017:        import org.jetbrains.annotations.NotNull;
018:        import org.jetbrains.annotations.Nullable;
019:        import org.pentaho.reportdesigner.crm.report.GraphicsContext;
020:        import org.pentaho.reportdesigner.crm.report.PropertyKeys;
021:        import org.pentaho.reportdesigner.crm.report.lineal.LinealModel;
022:        import org.pentaho.reportdesigner.crm.report.model.functions.ExpressionRegistry;
023:        import org.pentaho.reportdesigner.crm.report.reportexporter.ReportCreationException;
024:        import org.pentaho.reportdesigner.crm.report.reportexporter.ReportVisitor;
025:        import org.pentaho.reportdesigner.lib.client.undo.Undo;
026:        import org.pentaho.reportdesigner.lib.client.undo.UndoEntry;
027:        import org.pentaho.reportdesigner.lib.common.xml.XMLConstants;
028:        import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
029:        import org.pentaho.reportdesigner.lib.common.xml.XMLUtils;
030:        import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
031:
032:        import java.awt.*;
033:        import java.awt.geom.Rectangle2D;
034:        import java.io.IOException;
035:        import java.util.ArrayList;
036:
037:        /**
038:         * User: Martin
039:         * Date: 20.10.2005
040:         * Time: 16:03:02
041:         */
042:        public class BandToplevelReportElement extends ReportElement {
043:            private boolean pageBreakBefore;
044:            private boolean pageBreakAfter;
045:
046:            private boolean showInLayoutGUI;
047:
048:            private double visualHeight;
049:
050:            @Nullable
051:            private LinealModel verticalLinealModel;
052:
053:            @NotNull
054:            private BandToplevelType bandToplevelType;
055:
056:            public BandToplevelReportElement() {
057:                setName("Band" + System.identityHashCode(this ));
058:
059:                showInLayoutGUI = true;
060:
061:                visualHeight = 100;
062:                bandToplevelType = BandToplevelType.ITEM_BAND;
063:            }
064:
065:            @NotNull
066:            public BandToplevelType getBandToplevelType() {
067:                return bandToplevelType;
068:            }
069:
070:            public void setBandToplevelType(@NotNull
071:            BandToplevelType bandToplevelType) {
072:                this .bandToplevelType = bandToplevelType;
073:            }
074:
075:            @Nullable
076:            public LinealModel getVerticalLinealModel() {
077:                LinealModel linealModel = verticalLinealModel;
078:                if (linealModel == null) {
079:                    Report report = getReport();
080:                    if (report != null) {
081:                        verticalLinealModel = new LinealModel(report);
082:                    }
083:                } else if (linealModel.getReport() == null) {
084:                    Report report = getReport();
085:                    linealModel.setReport(report);
086:                }
087:                return verticalLinealModel;
088:            }
089:
090:            public double getVisualHeight() {
091:                return visualHeight;
092:            }
093:
094:            public void setVisualHeight(final double visualHeight) {
095:                final double oldVisualHeight = this .visualHeight;
096:                this .visualHeight = visualHeight;
097:
098:                firePropertyChange(PropertyKeys.VISUAL_HEIGHT, Double
099:                        .valueOf(oldVisualHeight), Double.valueOf(visualHeight));
100:            }
101:
102:            public boolean isPageBreakBefore() {
103:                return pageBreakBefore;
104:            }
105:
106:            public void setPageBreakBefore(final boolean pageBreakBefore) {
107:                final boolean oldPageBreakBefore = this .pageBreakBefore;
108:                this .pageBreakBefore = pageBreakBefore;
109:
110:                Undo undo = getUndo();
111:                if (undo != null && !undo.isInProgress()) {
112:                    undo.startTransaction(PropertyKeys.PAGE_BREAK_BEFORE);
113:                    undo.add(new UndoEntry() {
114:                        public void undo() {
115:                            setPageBreakBefore(oldPageBreakBefore);
116:                        }
117:
118:                        public void redo() {
119:                            setPageBreakBefore(pageBreakBefore);
120:                        }
121:                    });
122:                    undo.endTransaction();
123:                }
124:
125:                firePropertyChange(PropertyKeys.PAGE_BREAK_BEFORE, Boolean
126:                        .valueOf(oldPageBreakBefore), Boolean
127:                        .valueOf(pageBreakBefore));
128:            }
129:
130:            public boolean isPageBreakAfter() {
131:                return pageBreakAfter;
132:            }
133:
134:            public void setPageBreakAfter(final boolean pageBreakAfter) {
135:                final boolean oldPageBreakAfter = this .pageBreakAfter;
136:                this .pageBreakAfter = pageBreakAfter;
137:
138:                Undo undo = getUndo();
139:                if (undo != null && !undo.isInProgress()) {
140:                    undo.startTransaction(PropertyKeys.PAGE_BREAK_AFTER);
141:                    undo.add(new UndoEntry() {
142:                        public void undo() {
143:                            setPageBreakAfter(oldPageBreakAfter);
144:                        }
145:
146:                        public void redo() {
147:                            setPageBreakAfter(pageBreakAfter);
148:                        }
149:                    });
150:                    undo.endTransaction();
151:                }
152:
153:                firePropertyChange(PropertyKeys.PAGE_BREAK_AFTER, Boolean
154:                        .valueOf(oldPageBreakAfter), Boolean
155:                        .valueOf(pageBreakAfter));
156:            }
157:
158:            public boolean isShowInLayoutGUI() {
159:                return showInLayoutGUI;
160:            }
161:
162:            public void setShowInLayoutGUI(final boolean showInLayoutGUI) {
163:                final boolean oldShowInLayoutGUI = this .showInLayoutGUI;
164:                this .showInLayoutGUI = showInLayoutGUI;
165:
166:                Undo undo = getUndo();
167:                if (undo != null && !undo.isInProgress()) {
168:                    undo.startTransaction(PropertyKeys.SHOW_IN_LAYOUT_GUI);
169:                    undo.add(new UndoEntry() {
170:                        public void undo() {
171:                            setShowInLayoutGUI(oldShowInLayoutGUI);
172:                        }
173:
174:                        public void redo() {
175:                            setShowInLayoutGUI(showInLayoutGUI);
176:                        }
177:                    });
178:                    undo.endTransaction();
179:                }
180:
181:                firePropertyChange(PropertyKeys.SHOW_IN_LAYOUT_GUI, Boolean
182:                        .valueOf(oldShowInLayoutGUI), Boolean
183:                        .valueOf(showInLayoutGUI));
184:            }
185:
186:            public void paint(@NotNull
187:            GraphicsContext graphicsContext, @NotNull
188:            Graphics2D g2d) {
189:                if (!showInLayoutGUI) {
190:                    return;
191:                }
192:
193:                Shape origClip = g2d.getClip();
194:                Color origColor = g2d.getColor();
195:                Composite origComposite = g2d.getComposite();
196:                Stroke origStroke = g2d.getStroke();
197:
198:                Rectangle2D.Double rect = getRectangle();
199:
200:                g2d.clip(new Rectangle2D.Double(rect.x, rect.y, rect.width + 1,
201:                        rect.height + 1));
202:                paintBackroundAndBorder(g2d);
203:
204:                g2d.clip(rect);
205:
206:                g2d.setStroke(origStroke);
207:                g2d.setComposite(origComposite);
208:                g2d.setColor(origColor);
209:                g2d.setClip(origClip);
210:
211:                //paint children
212:                ArrayList<ReportElement> children = getChildren();
213:                for (ReportElement reportElement : children) {
214:                    reportElement.paint(graphicsContext, g2d);
215:                }
216:            }
217:
218:            public void validate() {
219:                if (!invalid) {
220:                    return;
221:                }
222:
223:                ArrayList<ReportElement> children = getChildren();
224:                for (ReportElement reportElement : children) {
225:                    reportElement.validate();
226:                }
227:
228:                //convert position to absolute coordinate
229:                double borderHeight = getElementBorder().getTopSide()
230:                        .getWidth()
231:                        + getElementBorder().getBottomSide().getWidth();
232:
233:                Report report = getReport();
234:                if (report != null) {
235:                    origRectangle.setRect(position.getX(), position.getY(),
236:                            report.getPageDefinition().getInnerPageSize()
237:                                    .getWidth(), minimumSize.getHeight());
238:                    rectangle.setRect(position.getX(), position.getY(), report
239:                            .getPageDefinition().getInnerPageSize().getWidth(),
240:                            minimumSize.getHeight());
241:                }
242:
243:                for (ReportElement reportElement : children) {
244:                    origRectangle = (Rectangle2D.Double) origRectangle
245:                            .createUnion(reportElement.getOrigRectangle());
246:                    rectangle = (Rectangle2D.Double) rectangle
247:                            .createUnion(reportElement.getOrigRectangle());
248:                }
249:
250:                origRectangle.height += borderHeight;
251:                rectangle.height += borderHeight;
252:
253:            }
254:
255:            //@NotNull
256:            //public Rectangle2D.Double getRectangle()
257:            //{
258:            //    Rectangle2D.Double r = super.getRectangle();
259:            //    r.width = getReport().getPageDefinition().getInnerPageSize().getWidth();
260:            //
261:            //    return r;
262:            //}
263:
264:            public void accept(@Nullable
265:            Object parent, @NotNull
266:            ReportVisitor reportVisitor) throws ReportCreationException {
267:                Object newParent = reportVisitor.visit(parent, this );
268:
269:                ArrayList<ReportElement> children = new ArrayList<ReportElement>(
270:                        getChildren());
271:                for (ReportElement reportElement : children) {
272:                    reportElement.accept(newParent, reportVisitor);
273:                }
274:            }
275:
276:            protected void externalizeElements(@NotNull
277:            XMLWriter xmlWriter, @NotNull
278:            XMLContext xmlContext) throws IOException {
279:                super .externalizeElements(xmlWriter, xmlContext);
280:
281:                xmlWriter.writeProperty(PropertyKeys.PAGE_BREAK_BEFORE, String
282:                        .valueOf(pageBreakBefore));
283:                xmlWriter.writeProperty(PropertyKeys.PAGE_BREAK_AFTER, String
284:                        .valueOf(pageBreakAfter));
285:                xmlWriter.writeProperty(PropertyKeys.SHOW_IN_LAYOUT_GUI, String
286:                        .valueOf(showInLayoutGUI));
287:                xmlWriter.writeProperty(PropertyKeys.VISUAL_HEIGHT, String
288:                        .valueOf(visualHeight));
289:
290:                LinealModel linealModel = verticalLinealModel;
291:                if (linealModel != null) {
292:                    xmlWriter.startElement(PropertyKeys.VERTICAL_LINEAL_MODEL);
293:                    linealModel.externalizeObject(xmlWriter, xmlContext);
294:                    xmlWriter.closeElement(PropertyKeys.VERTICAL_LINEAL_MODEL);
295:                }
296:            }
297:
298:            protected void readElement(@NotNull
299:            ExpressionRegistry expressions, @NotNull
300:            XmlPullNode node, @NotNull
301:            XMLContext xmlContext) throws Exception {
302:                super .readElement(expressions, node, xmlContext);
303:
304:                if (XMLConstants.PROPERTY.equals(node.getRawName())
305:                        && PropertyKeys.PAGE_BREAK_BEFORE
306:                                .equals(node
307:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
308:                    pageBreakBefore = Boolean
309:                            .parseBoolean(XMLUtils.readProperty(
310:                                    PropertyKeys.PAGE_BREAK_BEFORE, node));
311:                } else if (XMLConstants.PROPERTY.equals(node.getRawName())
312:                        && PropertyKeys.PAGE_BREAK_AFTER
313:                                .equals(node
314:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
315:                    pageBreakAfter = Boolean.parseBoolean(XMLUtils
316:                            .readProperty(PropertyKeys.PAGE_BREAK_AFTER, node));
317:                } else if (XMLConstants.PROPERTY.equals(node.getRawName())
318:                        && PropertyKeys.SHOW_IN_LAYOUT_GUI
319:                                .equals(node
320:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
321:                    showInLayoutGUI = Boolean
322:                            .parseBoolean(XMLUtils.readProperty(
323:                                    PropertyKeys.SHOW_IN_LAYOUT_GUI, node));
324:                } else if (XMLConstants.PROPERTY.equals(node.getRawName())
325:                        && PropertyKeys.VISUAL_HEIGHT
326:                                .equals(node
327:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
328:                    visualHeight = Double.parseDouble(XMLUtils.readProperty(
329:                            PropertyKeys.VISUAL_HEIGHT, node));
330:                } else if (PropertyKeys.VERTICAL_LINEAL_MODEL.equals(node
331:                        .getRawName())) {
332:                    verticalLinealModel = new LinealModel(getReport());
333:                    verticalLinealModel.readObject(node, xmlContext);
334:                }
335:            }
336:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.