Source Code Cross Referenced for SectionArea.java in  » Report » datavision-1.1.0 » jimm » datavision » 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 » datavision 1.1.0 » jimm.datavision 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jimm.datavision;
002:
003:        import jimm.util.I18N;
004:        import jimm.util.XMLWriter;
005:        import java.util.*;
006:
007:        /*
008:         * A section area holds an ordered list of {@see Section}s and knows its
009:         * name and type.
010:         *
011:         * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
012:         */
013:        public class SectionArea implements  Writeable {
014:
015:            public static final int REPORT_HEADER = 0;
016:            public static final int REPORT_FOOTER = 1;
017:            public static final int PAGE_HEADER = 2;
018:            public static final int PAGE_FOOTER = 3;
019:            public static final int DETAIL = 4;
020:            public static final int GROUP_HEADER = 5;
021:            public static final int GROUP_FOOTER = 6;
022:
023:            /**
024:             * These are I18N lookup keys for <code>REPORT_*</code> constants.
025:             * The order of these keys must match the values of those constants.
026:             */
027:            protected static final String[] AREA_NAME_KEYS = {
028:                    "Report.report_header", "Report.report_footer",
029:                    "Report.page_header", "Report.page_footer",
030:                    "Report.detail", "Report.group_header",
031:                    "Report.group_footer" };
032:
033:            List sections;
034:            /** One of the <code>REPORT_*</code> constants. */
035:            int area;
036:
037:            /**
038:             * Given the <code>REPORT_*</code> constant <var>area</var>,
039:             * returns the section area name.
040:             *
041:             * @param area a <code>REPORT_*</code> constant
042:             */
043:            public static String nameFromArea(int area) {
044:                return I18N.get(AREA_NAME_KEYS[area]);
045:            }
046:
047:            /**
048:             * Constructor.
049:             *
050:             * @param area a <code>REPORT_*</code> constant
051:             */
052:            public SectionArea(int area) {
053:                this .area = area;
054:                sections = new ArrayList();
055:            }
056:
057:            public int getArea() {
058:                return area;
059:            }
060:
061:            public int indexOf(Section s) {
062:                return sections.indexOf(s);
063:            }
064:
065:            public Section get(int index) {
066:                return (Section) sections.get(index);
067:            }
068:
069:            public Section first() {
070:                return (Section) sections.get(0);
071:            }
072:
073:            /**
074:             * Adds a section to our list and sets its name and other area-related
075:             * information.
076:             *
077:             * @param s a section
078:             */
079:            public void add(Section s) {
080:                sections.add(s);
081:                imprint(s);
082:            }
083:
084:            /**
085:             * Adds a section to our list and sets its name and other area-related
086:             * information.
087:             *
088:             * @param s a section
089:             */
090:            public void add(int index, Section s) {
091:                sections.add(index, s);
092:                imprint(s);
093:            }
094:
095:            /**
096:             * Adds a (possibly created) section after <var>afterThis</var> and
097:             * returns the section. If <var>section</var> is <code>null</code>,
098:             * a new section will be created.
099:             *
100:             * @param section the section to insert; if <code>null</code>, a new
101:             * section will be created
102:             * @param afterThis the new section will be inserted after this one
103:             */
104:            public Section insertAfter(Section section, Section afterThis) {
105:                if (section == null) {
106:                    if (afterThis != null)
107:                        section = new Section(afterThis.getReport());
108:                    else
109:                        throw new IllegalArgumentException(
110:                                "SectionArea.insertAfter:"
111:                                        + " both section and afterThis"
112:                                        + " can't be null");
113:                }
114:
115:                sections.add(sections.indexOf(afterThis) + 1, section);
116:                imprint(section);
117:                return section;
118:            }
119:
120:            /**
121:             * Modifies <var>section</var> so it knows that it's part of this area.
122:             *
123:             * @param section a section
124:             */
125:            protected void imprint(Section section) {
126:                section.setArea(this );
127:            }
128:
129:            /**
130:             * Returns <code>true</code> if this is a report detail section.
131:             *
132:             * @return <code>true</code> if this is a report detail section
133:             */
134:            public boolean isDetail() {
135:                return area == DETAIL;
136:            }
137:
138:            /**
139:             * Removes a section.
140:             *
141:             * @param s a report section
142:             */
143:            public void remove(Section s) {
144:                sections.remove(s);
145:                s.setArea(null);
146:            }
147:
148:            /**
149:             * Returns <code>true</code> if <var>s</var> is one of our sections.
150:             *
151:             * @param s a section
152:             * @return <code>true</code> if <var>s</var> is one of our sections
153:             */
154:            public boolean contains(Section s) {
155:                return sections.contains(s);
156:            }
157:
158:            /**
159:             * Returns the name of this area.
160:             *
161:             * @return the name of this area
162:             */
163:            public String getName() {
164:                return nameFromArea(area);
165:            }
166:
167:            /**
168:             * Returns an unmodifiable version of our list of sections.
169:             *
170:             * @return an unmodifiable version of our list of sections.
171:             */
172:            public List sections() {
173:                return Collections.unmodifiableList(sections);
174:            }
175:
176:            public Iterator iterator() {
177:                return sections.iterator();
178:            }
179:
180:            public int size() {
181:                return sections.size();
182:            }
183:
184:            public boolean isEmpty() {
185:                return sections.isEmpty();
186:            }
187:
188:            public void clear() {
189:                for (Iterator iter = sections.iterator(); iter.hasNext();)
190:                    ((Section) iter.next()).setArea(null);
191:                sections.clear();
192:            }
193:
194:            public void withSectionsDo(SectionWalker s) {
195:                for (Iterator iter = sections.iterator(); iter.hasNext();)
196:                    s.step((Section) iter.next());
197:            }
198:
199:            public void writeXML(XMLWriter out) {
200:                ListWriter.writeList(out, sections);
201:            }
202:
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.