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


001:        /*
002:         * FieldHierachy.java
003:         *
004:         * Created on June 24, 2004, 10:48 AM
005:         */
006:
007:        package jimm.datavision.layout.excel;
008:
009:        import java.util.*;
010:        import jimm.datavision.*;
011:        import jimm.datavision.field.Rectangle;
012:
013:        /**
014:         *
015:         * @author  dbeeler
016:         */
017:        public class FieldMap {
018:
019:            public ArrayList reportRows;
020:            public double[] colWidths = new double[256];
021:            public boolean[] colAlloc = new boolean[256];
022:            public static final int MAXCOL = 256;
023:
024:            /** Creates a new instance of FieldHierachy */
025:            public FieldMap() {
026:                // 8.00 pels or 61 pixels
027:                this (8.00);
028:            }
029:
030:            public FieldMap(double defaultColWidth) {
031:                int i;
032:                for (i = 0; i < MAXCOL; i++) {
033:                    colWidths[i] = defaultColWidth * 7.625;
034:                    colAlloc[i] = false;
035:                }
036:                reportRows = new ArrayList();
037:            }
038:
039:            public RowContainer createRow() {
040:                RowContainer tmpRow = new RowContainer(this );
041:                reportRows.add(tmpRow);
042:                return tmpRow;
043:            }
044:
045:            /* Transverses all rows and columns and establishes the best column allotment */
046:            public void realignColumns() {
047:                int i;
048:                Iterator it = reportRows.iterator();
049:                while (it.hasNext()) {
050:                    RowContainer tmpRow = (RowContainer) it.next();
051:                    /* Iterate through the fields in this line and find acceptable column allocations */
052:                    Iterator rowit = tmpRow.reportFields.iterator();
053:                    while (rowit.hasNext()) {
054:                        PermField tmpField = (PermField) rowit.next();
055:                        Rectangle fbound = tmpField.getBounds();
056:                        /* Find a column that fits or has a position near it */
057:
058:                        for (i = 0; i < MAXCOL; i++) {
059:                            int curvalue = getColOffset(i);
060:                            if (fbound.x == curvalue) {
061:                                /* Found a perfect match.  Lets make sure its allocated. */
062:                                if (!colAlloc[i])
063:                                    colAlloc[i] = true;
064:                                break;
065:                            }
066:                            if (fbound.x < curvalue) {
067:                                /* We've passed our ideal column.  Lets allocate this one and change
068:                                 * its size to fit, if its not already allocated.  If it is, we'll 
069:                                 * shift this column and the others to the right and insert ours here */
070:                                if (!colAlloc[i]) {
071:                                    colAlloc[i] = true;
072:                                    double prePosition = getColOffset(i - 1);
073:                                    double postPosition = getColOffset(i + 1);
074:                                    colWidths[i - 1] = fbound.x - prePosition;
075:                                    colWidths[i] = postPosition - fbound.x;
076:                                    break;
077:                                } else {
078:                                    /* Column is allocated.  Shift it to the right */
079:                                    double prePosition = getColOffset(i - 1);
080:                                    double postPosition = getColOffset(i);
081:                                    shiftColsRight(i);
082:                                    colAlloc[i] = true;
083:                                    colWidths[i - 1] = fbound.x - prePosition;
084:                                    colWidths[i] = postPosition - fbound.x;
085:                                    break;
086:                                }
087:                            }
088:                        }
089:                    }
090:                }
091:            }
092:
093:            /**
094:             * Calculates the column offset given the stored array of widths 
095:             */
096:            public int getColOffset(int colNum) {
097:                int offset = 0;
098:                int i = 0;
099:                for (i = 0; i < colNum; i++)
100:                    offset += colWidths[i];
101:                return offset;
102:            }
103:
104:            public void shiftColsRight(int startColNum) {
105:                int i;
106:                for (i = MAXCOL - 1; i > startColNum; --i) {
107:                    colWidths[i] = colWidths[i - 1];
108:                    colAlloc[i] = colAlloc[i - 1];
109:                }
110:
111:            }
112:
113:            /**
114:             * Routine to prepare for garbage collection
115:             */
116:            public void delete() {
117:                reportRows.clear();
118:
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.