Source Code Cross Referenced for BandReportElement.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.model.functions.ExpressionRegistry;
022:        import org.pentaho.reportdesigner.crm.report.model.layoutmanager.NullReportLayoutManager;
023:        import org.pentaho.reportdesigner.crm.report.model.layoutmanager.ReportLayoutManager;
024:        import org.pentaho.reportdesigner.crm.report.model.layoutmanager.StackedReportLayoutManager;
025:        import org.pentaho.reportdesigner.crm.report.reportexporter.ReportCreationException;
026:        import org.pentaho.reportdesigner.crm.report.reportexporter.ReportVisitor;
027:        import org.pentaho.reportdesigner.lib.client.undo.Undo;
028:        import org.pentaho.reportdesigner.lib.client.undo.UndoEntry;
029:        import org.pentaho.reportdesigner.lib.common.xml.XMLConstants;
030:        import org.pentaho.reportdesigner.lib.common.xml.XMLContext;
031:        import org.pentaho.reportdesigner.lib.common.xml.XMLUtils;
032:        import org.pentaho.reportdesigner.lib.common.xml.XMLWriter;
033:
034:        import java.awt.*;
035:        import java.awt.geom.AffineTransform;
036:        import java.awt.geom.Rectangle2D;
037:        import java.io.IOException;
038:        import java.util.ArrayList;
039:
040:        /**
041:         * User: Martin
042:         * Date: 20.10.2005
043:         * Time: 16:03:02
044:         */
045:        public class BandReportElement extends ReportElement {
046:            @NotNull
047:            private ReportLayoutManager.Type reportLayoutManagerType;
048:            @NotNull
049:            private ReportLayoutManager reportLayoutManager;
050:
051:            private boolean showInLayoutGUI;
052:
053:            public BandReportElement() {
054:                setName("Band" + System.identityHashCode(this ));
055:
056:                reportLayoutManagerType = ReportLayoutManager.Type.STACKED;
057:                reportLayoutManager = new StackedReportLayoutManager();
058:
059:                showInLayoutGUI = true;
060:            }
061:
062:            @NotNull
063:            public ReportLayoutManager.Type getReportLayoutManagerType() {
064:                return reportLayoutManagerType;
065:            }
066:
067:            public void setReportLayoutManagerType(@NotNull
068:            final ReportLayoutManager.Type reportLayoutManagerType) {
069:                //noinspection ConstantConditions
070:                if (reportLayoutManagerType == null) {
071:                    throw new IllegalArgumentException(
072:                            "reportLayoutManagerType must not be null");
073:                }
074:
075:                final ReportLayoutManager.Type oldReportLayoutManagerType = this .reportLayoutManagerType;
076:                this .reportLayoutManagerType = reportLayoutManagerType;
077:
078:                if (reportLayoutManagerType == ReportLayoutManager.Type.STACKED) {
079:                    reportLayoutManager = new StackedReportLayoutManager();
080:                } else {
081:                    reportLayoutManager = new NullReportLayoutManager();
082:                }
083:
084:                Undo undo = getUndo();
085:                if (undo != null && !undo.isInProgress()) {
086:                    undo
087:                            .startTransaction(PropertyKeys.REPORT_LAYOUT_MANAGER_TYPE);
088:                    undo.add(new UndoEntry() {
089:                        public void undo() {
090:                            setReportLayoutManagerType(oldReportLayoutManagerType);
091:                        }
092:
093:                        public void redo() {
094:                            setReportLayoutManagerType(reportLayoutManagerType);
095:                        }
096:                    });
097:                    undo.endTransaction();
098:                }
099:
100:                firePropertyChange(PropertyKeys.REPORT_LAYOUT_MANAGER_TYPE,
101:                        oldReportLayoutManagerType, reportLayoutManagerType);
102:            }
103:
104:            public boolean isShowInLayoutGUI() {
105:                return showInLayoutGUI;
106:            }
107:
108:            public void setShowInLayoutGUI(final boolean showInLayoutGUI) {
109:                final boolean oldShowInLayoutGUI = this .showInLayoutGUI;
110:                this .showInLayoutGUI = showInLayoutGUI;
111:
112:                Undo undo = getUndo();
113:                if (undo != null && !undo.isInProgress()) {
114:                    undo.startTransaction(PropertyKeys.SHOW_IN_LAYOUT_GUI);
115:                    undo.add(new UndoEntry() {
116:                        public void undo() {
117:                            setShowInLayoutGUI(oldShowInLayoutGUI);
118:                        }
119:
120:                        public void redo() {
121:                            setShowInLayoutGUI(showInLayoutGUI);
122:                        }
123:                    });
124:                    undo.endTransaction();
125:                }
126:
127:                firePropertyChange(PropertyKeys.SHOW_IN_LAYOUT_GUI,
128:                        oldShowInLayoutGUI, showInLayoutGUI);
129:            }
130:
131:            @NotNull
132:            public ReportLayoutManager getReportLayoutManager() {
133:                return reportLayoutManager;
134:            }
135:
136:            public void validate() {
137:                if (!invalid) {
138:                    return;
139:                }
140:
141:                //this validates all children (gives them a chance to calculate their layout)
142:                ArrayList<ReportElement> children = getChildren();
143:                for (ReportElement reportElement : children) {
144:                    reportElement.validate();
145:                }
146:
147:                //now we take this outcome and layout how we like the children again to reflect our preferences
148:                reportLayoutManager.layoutReportElement(this );//this adjusts only the minimumsize
149:
150:                for (ReportElement reportElement : children) {
151:                    reportElement.validate();
152:                }
153:
154:                //convert position to absolute coordinate
155:                getOrigRectangle().setRect(getPosition().getX(),
156:                        getPosition().getY(), getMinimumSize().getWidth(),
157:                        getMinimumSize().getHeight());
158:                getRectangle().setRect(getPosition().getX(),
159:                        getPosition().getY(), getMinimumSize().getWidth(),
160:                        getMinimumSize().getHeight());
161:            }
162:
163:            public void paint(@NotNull
164:            GraphicsContext graphicsContext, @NotNull
165:            Graphics2D g2d) {
166:                if (!showInLayoutGUI) {
167:                    return;
168:                }
169:
170:                Shape origClip = g2d.getClip();
171:                Color origColor = g2d.getColor();
172:                Composite origComposite = g2d.getComposite();
173:                Stroke origStroke = g2d.getStroke();
174:
175:                Rectangle2D.Double rect = getRectangle();
176:
177:                g2d.setColor(new Color(220, 220, 220));
178:                g2d.draw(rect);
179:
180:                g2d.clip(new Rectangle2D.Double(rect.x, rect.y, rect.width + 1,
181:                        rect.height + 1));
182:                paintBackroundAndBorder(g2d);
183:
184:                g2d.clip(rect);
185:
186:                g2d.setStroke(origStroke);
187:                g2d.setComposite(origComposite);
188:                g2d.setColor(origColor);
189:                g2d.setClip(origClip);
190:
191:                //paint children
192:                ArrayList<ReportElement> children = getChildren();
193:                AffineTransform origTransform = g2d.getTransform();
194:
195:                g2d.translate(getRectangle().x, getRectangle().y);
196:                for (ReportElement reportElement : children) {
197:                    reportElement.paint(graphicsContext, g2d);
198:                }
199:
200:                g2d.setTransform(origTransform);
201:            }
202:
203:            public void accept(@Nullable
204:            Object parent, @NotNull
205:            ReportVisitor reportVisitor) throws ReportCreationException {
206:                Object newParent = reportVisitor.visit(parent, this );
207:
208:                ArrayList<ReportElement> children = new ArrayList<ReportElement>(
209:                        getChildren());
210:                for (ReportElement reportElement : children) {
211:                    reportElement.accept(newParent, reportVisitor);
212:                }
213:            }
214:
215:            protected void externalizeElements(@NotNull
216:            XMLWriter xmlWriter, @NotNull
217:            XMLContext xmlContext) throws IOException {
218:                super .externalizeElements(xmlWriter, xmlContext);
219:
220:                xmlWriter.writeProperty(
221:                        PropertyKeys.REPORT_LAYOUT_MANAGER_TYPE,
222:                        reportLayoutManagerType.toString());
223:                xmlWriter.writeProperty(PropertyKeys.SHOW_IN_LAYOUT_GUI, String
224:                        .valueOf(showInLayoutGUI));
225:            }
226:
227:            protected void readElement(@NotNull
228:            ExpressionRegistry expressions, @NotNull
229:            XmlPullNode node, @NotNull
230:            XMLContext xmlContext) throws Exception {
231:                super .readElement(expressions, node, xmlContext);
232:
233:                if (XMLConstants.PROPERTY.equals(node.getRawName())
234:                        && PropertyKeys.REPORT_LAYOUT_MANAGER_TYPE
235:                                .equals(node
236:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
237:                    reportLayoutManagerType = ReportLayoutManager.Type
238:                            .valueOf(XMLUtils.readProperty(
239:                                    PropertyKeys.REPORT_LAYOUT_MANAGER_TYPE,
240:                                    node));
241:                    if (reportLayoutManagerType == ReportLayoutManager.Type.STACKED) {
242:                        reportLayoutManager = new StackedReportLayoutManager();
243:                    } else {
244:                        reportLayoutManager = new NullReportLayoutManager();
245:                    }
246:                } else if (XMLConstants.PROPERTY.equals(node.getRawName())
247:                        && PropertyKeys.SHOW_IN_LAYOUT_GUI
248:                                .equals(node
249:                                        .getAttributeValueFromRawName(XMLConstants.NAME))) {
250:                    showInLayoutGUI = Boolean
251:                            .parseBoolean(XMLUtils.readProperty(
252:                                    PropertyKeys.SHOW_IN_LAYOUT_GUI, node));
253:                }
254:            }
255:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.