Source Code Cross Referenced for ReportElementUtilities.java in  » Report » pentaho-report » org » pentaho » reportdesigner » crm » report » util » 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.util 
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.util;
015:
016:        import org.jetbrains.annotations.NotNull;
017:        import org.jetbrains.annotations.Nullable;
018:        import org.pentaho.reportdesigner.crm.report.model.BandReportElement;
019:        import org.pentaho.reportdesigner.crm.report.model.BandToplevelReportElement;
020:        import org.pentaho.reportdesigner.crm.report.model.FilePath;
021:        import org.pentaho.reportdesigner.crm.report.model.Report;
022:        import org.pentaho.reportdesigner.crm.report.model.ReportElement;
023:        import org.pentaho.reportdesigner.crm.report.model.SubReportElement;
024:        import org.pentaho.reportdesigner.crm.report.model.dataset.TableModelDataSetReportElement;
025:
026:        import java.awt.geom.Point2D;
027:        import java.awt.geom.Rectangle2D;
028:        import java.util.ArrayList;
029:        import java.util.Collection;
030:
031:        /**
032:         * User: Martin
033:         * Date: 21.02.2006
034:         * Time: 10:15:59
035:         */
036:        public class ReportElementUtilities {
037:            private ReportElementUtilities() {
038:            }
039:
040:            public static boolean canPreviewReport(@Nullable
041:            Report report) {
042:                if (report != null) {
043:                    ArrayList<ReportElement> children = report
044:                            .getDataSetsReportElement().getChildren();
045:                    for (ReportElement reportElement : children) {
046:                        if (reportElement instanceof  TableModelDataSetReportElement) {
047:                            TableModelDataSetReportElement tableModelDataSetReportElement = (TableModelDataSetReportElement) reportElement;
048:                            if (tableModelDataSetReportElement
049:                                    .canFetchPreviewDataTableModel()) {
050:                                return true;
051:                            }
052:                        }
053:                    }
054:                }
055:
056:                return false;
057:            }
058:
059:            public static boolean canCreateReport(@Nullable
060:            Report report) {
061:                if (report != null) {
062:                    ArrayList<ReportElement> children = report
063:                            .getDataSetsReportElement().getChildren();
064:                    for (ReportElement reportElement : children) {
065:                        if (reportElement instanceof  TableModelDataSetReportElement) {
066:                            TableModelDataSetReportElement tableModelDataSetReportElement = (TableModelDataSetReportElement) reportElement;
067:                            if (tableModelDataSetReportElement
068:                                    .canFetchRealDataTableModel()) {
069:                                return true;
070:                            }
071:                        }
072:                    }
073:                }
074:
075:                return false;
076:            }
077:
078:            @NotNull
079:            public static ReportElement getDeepestReportElementAt(@NotNull
080:            Point2D.Double point, @NotNull
081:            BandToplevelReportElement bandToplevelReportElement, @NotNull
082:            Collection<ReportElement> excludedElements) {
083:                ArrayList<ReportElement> children = bandToplevelReportElement
084:                        .getChildren();
085:                for (ReportElement reportElement : children) {
086:                    if (!excludedElements.contains(reportElement)
087:                            && reportElement.getRectangle().contains(point)) {
088:                        return getDeepestReportElementAt(point, reportElement,
089:                                excludedElements, reportElement.getPosition()
090:                                        .getX(), reportElement.getPosition()
091:                                        .getY());//bandTopLevel always has a position of (0,0)
092:                    }
093:                }
094:
095:                return bandToplevelReportElement;
096:            }
097:
098:            @NotNull
099:            private static ReportElement getDeepestReportElementAt(@NotNull
100:            Point2D.Double point, @NotNull
101:            ReportElement element, @NotNull
102:            Collection<ReportElement> excludedElements, double xParent,
103:                    double yParent) {
104:                ArrayList<ReportElement> children = element.getChildren();
105:                for (ReportElement reportElement : children) {
106:                    Rectangle2D.Double rectangle = new Rectangle2D.Double(
107:                            xParent + reportElement.getRectangle().getX(),
108:                            yParent + reportElement.getRectangle().getY(),
109:                            reportElement.getRectangle().getWidth(),
110:                            reportElement.getRectangle().getHeight());
111:                    if (!excludedElements.contains(reportElement)
112:                            && rectangle.contains(point)) {
113:                        return getDeepestReportElementAt(point, reportElement,
114:                                excludedElements, xParent
115:                                        + reportElement.getRectangle().getX(),
116:                                yParent + reportElement.getRectangle().getY());
117:                    }
118:                }
119:                return element;
120:            }
121:
122:            @Nullable
123:            public static BandReportElement getDeepestBandReportElement(
124:                    @NotNull
125:                    Point2D.Double point, @NotNull
126:                    BandToplevelReportElement bandToplevelReportElement,
127:                    @NotNull
128:                    Collection<ReportElement> excludedElements) {
129:                ReportElement reportElement = getDeepestReportElementAt(point,
130:                        bandToplevelReportElement, excludedElements);
131:
132:                do {
133:                    if (reportElement instanceof  BandReportElement) {
134:                        BandReportElement bandReportElement = (BandReportElement) reportElement;
135:                        if (isShowInLayoutGUI(bandReportElement)) {
136:                            return bandReportElement;
137:                        }
138:                    }
139:                } while ((reportElement = reportElement.getParent()) != null);
140:
141:                return null;
142:            }
143:
144:            public static void convertRectangle(@NotNull
145:            Rectangle2D.Double rect, @NotNull
146:            ReportElement source, @Nullable
147:            ReportElement target) {
148:                ReportElement temp = source.getParent();
149:                //noinspection ObjectEquality
150:                while (temp != target && temp != null) {
151:                    rect.x += temp.getPosition().getX();
152:                    rect.y += temp.getPosition().getY();
153:
154:                    temp = temp.getParent();
155:                }
156:            }
157:
158:            public static void convertRectangleIncludingSource(@NotNull
159:            Rectangle2D.Double rect, @NotNull
160:            ReportElement source, @Nullable
161:            ReportElement target) {
162:                ReportElement temp = source;
163:                //noinspection ObjectEquality
164:                while (temp != target && temp != null) {
165:                    rect.x += temp.getPosition().getX();
166:                    rect.y += temp.getPosition().getY();
167:
168:                    temp = temp.getParent();
169:                }
170:            }
171:
172:            public static void convertPointToInner(@NotNull
173:            Point2D.Double point, @NotNull
174:            ReportElement source, @Nullable
175:            ReportElement target) {
176:                ReportElement temp = source;
177:                //noinspection ObjectEquality
178:                while (temp != target && temp != null) {
179:                    point.x -= temp.getPosition().getX();
180:                    point.y -= temp.getPosition().getY();
181:
182:                    temp = temp.getParent();
183:                }
184:            }
185:
186:            public static boolean isShowInLayoutGUI(@NotNull
187:            ReportElement reportElement) {
188:                ReportElement testElement = reportElement;
189:                do {
190:                    if (testElement instanceof  BandReportElement) {
191:                        BandReportElement bandReportElement = (BandReportElement) testElement;
192:                        if (!bandReportElement.isShowInLayoutGUI()) {
193:                            return false;
194:                        }
195:                    }
196:                } while ((testElement = testElement.getParent()) != null);
197:
198:                return true;
199:            }
200:
201:            @Nullable
202:            public static SubReportElement findSubReportElement(@NotNull
203:            ReportElement reportElement, @NotNull
204:            FilePath filePath) {
205:                if (reportElement instanceof  SubReportElement) {
206:                    SubReportElement subReportElement = (SubReportElement) reportElement;
207:                    if (subReportElement.getFilePath().equals(filePath)) {
208:                        return subReportElement;
209:                    }
210:                }
211:
212:                ArrayList<ReportElement> children = reportElement.getChildren();
213:                for (ReportElement element : children) {
214:                    SubReportElement subReportElement = findSubReportElement(
215:                            element, filePath);
216:                    if (subReportElement != null) {
217:                        return subReportElement;
218:                    }
219:                }
220:                return null;
221:            }
222:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.