Source Code Cross Referenced for FeatureTableModel.java in  » GIS » GeoTools-2.4.1 » org » geotools » gui » swing » table » 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 » GIS » GeoTools 2.4.1 » org.geotools.gui.swing.table 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-2006, Geotools Project Managment Committee (PMC)
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation; either
009:         *    version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.gui.swing.table;
017:
018:        // J2SE dependencies
019:        import javax.swing.table.TableModel;
020:        import javax.swing.table.AbstractTableModel;
021:
022:        // Geotools dependencies
023:        import org.geotools.feature.Feature;
024:        import org.geotools.feature.FeatureCollection;
025:        import org.geotools.feature.FeatureType;
026:
027:        /**
028:         * An implementation of Swing's table model which allows feature tables to be displayed.
029:         *
030:         * @since 2.2
031:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/widgets-swing/src/main/java/org/geotools/gui/swing/table/FeatureTableModel.java $
032:         * @version $Id: FeatureTableModel.java 22482 2006-10-31 02:58:00Z desruisseaux $
033:         * @author James Macgill, CCG
034:         *
035:         * @todo It would be excellent if there were custom cell renderers available for Geometry types.
036:         */
037:        public class FeatureTableModel extends AbstractTableModel implements 
038:                TableModel {
039:            /**
040:             * Holds the feature table that will be represented by this model.
041:             */
042:            private FeatureCollection featureTable;
043:
044:            /**
045:             * {@link #featureTable} as an array. Will be created only when first needed.
046:             */
047:            private transient Feature[] featureArray;
048:
049:            /**
050:             * Creates a new instance of feature table model.
051:             */
052:            public FeatureTableModel() {
053:            }
054:
055:            /**
056:             * Creates a new instance of FeatureTableModel based on the feature collection provided.
057:             */
058:            public FeatureTableModel(final FeatureCollection features) {
059:                setFeatureCollection(features);
060:            }
061:
062:            /**
063:             * Sets which featureTable to represent
064:             *
065:             * @param features The featureTable to represent. This could fire
066:             *        a Table Structure Changed event.
067:             */
068:            public void setFeatureCollection(final FeatureCollection features) {
069:                featureArray = null;
070:                featureTable = features;
071:                fireTableStructureChanged();
072:            }
073:
074:            /**
075:             * The number of columns in the feature table. Note: for the moment, this is
076:             * determined by the first feature.
077:             *
078:             * @return the number of columns in this feature table.
079:             *
080:             * @todo Just gets first feature type - should use typed feature
081:             *       collection.  Revisit when we have FeatureDocument.
082:             */
083:            public int getColumnCount() {
084:                if (featureTable == null || featureTable.isEmpty()) {
085:                    return 0;
086:                }
087:                return featureTable.features().next().getNumberOfAttributes();
088:            }
089:
090:            /**
091:             * Gets the row count for the featureTable.
092:             *
093:             * @return the number of features in feature table.
094:             */
095:            public int getRowCount() {
096:                if (featureTable == null) {
097:                    return 0;
098:                }
099:                return featureTable.size();
100:            }
101:
102:            /**
103:             * Gets the name of a specified column.
104:             *
105:             * @param col the index of the column to get the name of.
106:             * @return the name of {@code col}.
107:             *
108:             * @todo Just gets first feature type - should use typed feature
109:             *       collection.  Revisit when we have FeatureDocument.
110:             */
111:            public String getColumnName(int col) {
112:                if (featureTable == null || featureTable.isEmpty()) {
113:                    return null;
114:                }
115:                Feature firstFeature = featureTable.features().next();
116:                FeatureType firstType = firstFeature.getFeatureType();
117:                return firstType.getAttributeType(col).getName();
118:            }
119:
120:            /**
121:             * Gets the value stored in a specified cell. In this case, {@code row}={@code Feature}
122:             * and {@code col}={@code Attribute}.
123:             *
124:             * @param row the row number.
125:             * @param col the column number.
126:             * @return the value in the specified cell.
127:             */
128:            public Object getValueAt(final int row, final int col) {
129:                if (featureArray == null) {
130:                    featureArray = (Feature[]) featureTable
131:                            .toArray(new Feature[featureTable.size()]);
132:                }
133:                return featureArray[row].getAttribute(col);
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.