Source Code Cross Referenced for TableLayout.java in  » RSS-RDF » Feedzeo » layout » 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 » RSS RDF » Feedzeo » layout 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************************
002:
003:            Feedzeo! 
004:            A free and open source RSS/Atom/RDF feed aggregator
005:
006:            Copyright (C) 2005-2006  Anand Rao (anandrao@users.sourceforge.net)
007:
008:            This library is free software; you can redistribute it and/or
009:            modify it under the terms of the GNU Lesser General Public
010:            License as published by the Free Software Foundation; either
011:            version 2.1 of the License, or (at your option) any later version.
012:
013:            This library is distributed in the hope that it will be useful,
014:            but WITHOUT ANY WARRANTY; without even the implied warranty of
015:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:            Lesser General Public License for more details.
017:
018:            You should have received a copy of the GNU Lesser General Public
019:            License along with this library; if not, write to the Free Software
020:            Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
021:
022:         ************************************************************************************/package layout;
023:
024:        import java.util.*;
025:
026:        import util.*;
027:        import ui.*;
028:
029:        /**
030:         *
031:         * @author  Anand Rao
032:         */
033:        public class TableLayout {
034:
035:            private String Name; // table object name
036:            private boolean IsTableList; // if all the cell elements of this table
037:            // have the same datatype and form a list of items
038:            // then IsTableList is true
039:            private int NumRows, NumCols;
040:            private CellElement[][] cellArray;
041:
042:            private BitSet[] RowStatus; /* bitmap containing status of each row in the table;
043:             * Each RowStatus[i]  reflects the status of one row; 
044:             * If a row has a cell with non-empty data,
045:             * then the bit corresponding to that cell is set; 
046:             * If all cells of a particular row are empty, then
047:             * all the bits corresponding to those cells are clear;
048:             * i.e RowStatus[i] is empty
049:             */
050:
051:            private BitSet copyBitSet(BitSet s) {
052:                return (BitSet) s.clone();
053:            }
054:
055:            /*
056:             * serves to do common processing between normal constructor 
057:             * and copy constructor
058:             */
059:            private void CommonConstructor(String Tablename, int nRows,
060:                    int nCols, TableLayout t) {
061:
062:                //System.out.println("   Rows"+NumRows+" Cols"+NumCols);                                       
063:                if (t == null) {
064:                    Name = Tablename;
065:                    NumRows = nRows;
066:                    NumCols = nCols;
067:                    IsTableList = false;
068:                    cellArray = new CellElement[NumRows][NumCols];
069:                    RowStatus = new BitSet[NumRows];
070:                    for (int i = 0; i < NumRows; i++)
071:                        RowStatus[i] = new BitSet();
072:                } else {
073:                    Name = new String(t.Name);
074:                    NumRows = t.NumRows;
075:                    NumCols = t.NumCols;
076:                    IsTableList = t.IsTableList;
077:                    cellArray = new CellElement[NumRows][NumCols];
078:                    for (int i = 0; i < NumRows; i++)
079:                        for (int j = 0; j < NumCols; j++) {
080:                            CellElement c = new CellElement(t.cellArray[i][j]);
081:                            cellArray[i][j] = c;
082:                        }
083:                    RowStatus = new BitSet[NumRows];
084:                    for (int i = 0; i < NumRows; i++)
085:                        RowStatus[i] = copyBitSet(t.RowStatus[i]);
086:                }
087:            }
088:
089:            /** Creates a new instance of TableLayout */
090:            public TableLayout(String Tablename, int NumRows, int NumCols) {
091:                CommonConstructor(Tablename, NumRows, NumCols, null);
092:                /*
093:                Name = Tablename;
094:                cellArray = new CellElement[NumRows][NumCols];
095:                this.NumRows = NumRows;
096:                this.NumCols = NumCols;
097:                IsTableList = false;
098:                RowStatus = new BitSet[NumRows];
099:                for (int i = 0; i < NumRows; i++)
100:                    RowStatus[i] =  new BitSet();
101:                 */
102:            }
103:
104:            // copy constructor
105:            public TableLayout(TableLayout t) {
106:                //System.out.println("COPY Table "+t.Name);
107:                CommonConstructor("", 0, 0, t);
108:                /*
109:                Name = new String(t.Name);
110:                NumRows = t.NumRows;
111:                NumCols = t.NumCols;
112:                //System.out.println("   Rows"+NumRows+" Cols"+NumCols);
113:                IsTableList = t.IsTableList;
114:                cellArray = new CellElement[NumRows][NumCols];
115:                for (int i = 0; i < NumRows; i++)
116:                    for (int j = 0; j < NumCols; j++) {
117:                        CellElement c = new CellElement(t.cellArray[i][j]);
118:                        cellArray[i][j] = c;
119:                    }
120:                 */
121:            }
122:
123:            public void addCell(int row, int col, String DataTypename,
124:                    String Data, String url) {
125:                if ((row >= NumRows) || (col >= NumCols))
126:                    return;
127:                cellArray[row][col] = new CellElement(DataTypename, Data, url);
128:            }
129:
130:            public CellElement getCell(int row, int col) {
131:                if ((row >= NumRows) || (col >= NumCols))
132:                    return null;
133:                return cellArray[row][col];
134:            }
135:
136:            public void setCellStatus(int row, int col, boolean status) {
137:                BitSet s = RowStatus[row];
138:                s.set(col, status);
139:            }
140:
141:            private boolean IsRowEmpty(int row) {
142:                BitSet s = RowStatus[row];
143:                return s.isEmpty();
144:            }
145:
146:            public boolean IsTableEmpty() {
147:                for (int i = 0; i < NumRows; i++) {
148:                    if (!IsRowEmpty(i))
149:                        return false;
150:                }
151:                return true;
152:            }
153:
154:            private boolean IsCellEmpty(int row, int col) {
155:                BitSet s = RowStatus[row];
156:                return !s.get(col);
157:            }
158:
159:            public void setTableEmpty() {
160:                // clear the RowStatus bitset
161:                for (int i = 0; i < NumRows; i++) {
162:                    BitSet s = RowStatus[i];
163:                    s.clear();
164:                }
165:            }
166:
167:            public int getNumRows() {
168:                return NumRows;
169:            }
170:
171:            public int getNumCols() {
172:                return NumCols;
173:            }
174:
175:            public String getName() {
176:                return Name;
177:            }
178:
179:            public String toHTML() {
180:
181:                if (IsTableEmpty())
182:                    return "";
183:
184:                HTMLTag table = new HTMLTag(TagName.TABLE_TAG);
185:                table.addAttribute("class", Name);
186:
187:                for (int i = 0; i < NumRows; i++) {
188:                    if (IsRowEmpty(i))
189:                        continue;
190:
191:                    HTMLTag trow = new HTMLTag(TagName.TABLE_ROW_TAG);
192:                    for (int j = 0; j < NumCols; j++) {
193:                        if (IsCellEmpty(i, j))
194:                            continue;
195:                        trow.add(cellArray[i][j].toHTML());
196:                    }
197:                    table.add(trow);
198:                }
199:                return table.toString();
200:            }
201:
202:            public boolean IsTableListType() {
203:                return IsTableList;
204:            }
205:
206:            public void setTableListType(boolean value) {
207:                IsTableList = value;
208:            }
209:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.