Source Code Cross Referenced for FloatColumn.java in  » Database-Client » prefuse » prefuse » data » column » 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 » Database Client » prefuse » prefuse.data.column 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.data.column;
002:
003:        import java.util.Arrays;
004:
005:        import prefuse.data.DataReadOnlyException;
006:        import prefuse.data.DataTypeException;
007:
008:        /**
009:         * Column instance for sotring flaot values.
010:         * 
011:         * @author <a href="http://jheer.org">jeffrey heer</a>
012:         */
013:        public class FloatColumn extends AbstractColumn {
014:
015:            private float[] m_values;
016:            private int m_size;
017:
018:            /**
019:             * Create a new empty FloatColumn. 
020:             */
021:            public FloatColumn() {
022:                this (0, 10, 0f);
023:            }
024:
025:            /**
026:             * Create a new FloatColumn. 
027:             * @param nrows the initial size of the column
028:             */
029:            public FloatColumn(int nrows) {
030:                this (nrows, nrows, 0f);
031:            }
032:
033:            /**
034:             * Create a new FloatColumn. 
035:             * @param nrows the initial size of the column
036:             * @param capacity the initial capacity of the column
037:             * @param defaultValue the default value for the column
038:             */
039:            public FloatColumn(int nrows, int capacity, float defaultValue) {
040:                super (float.class, new Float(defaultValue));
041:                if (capacity < nrows) {
042:                    throw new IllegalArgumentException(
043:                            "Capacity value can not be less than the row count.");
044:                }
045:                m_values = new float[capacity];
046:                Arrays.fill(m_values, defaultValue);
047:                m_size = nrows;
048:            }
049:
050:            // ------------------------------------------------------------------------
051:            // Column Metadata
052:
053:            /**
054:             * @see prefuse.data.column.Column#getRowCount()
055:             */
056:            public int getRowCount() {
057:                return m_size;
058:            }
059:
060:            /**
061:             * @see prefuse.data.column.Column#setMaximumRow(int)
062:             */
063:            public void setMaximumRow(int nrows) {
064:                if (nrows > m_values.length) {
065:                    int capacity = Math.max((3 * m_values.length) / 2 + 1,
066:                            nrows);
067:                    float[] values = new float[capacity];
068:                    System.arraycopy(m_values, 0, values, 0, m_size);
069:                    Arrays.fill(values, m_size, capacity,
070:                            ((Float) m_defaultValue).floatValue());
071:                    m_values = values;
072:                }
073:                m_size = nrows;
074:            }
075:
076:            // ------------------------------------------------------------------------
077:            // Data Access Methods
078:
079:            /**
080:             * @see prefuse.data.column.Column#get(int)
081:             */
082:            public Object get(int row) {
083:                return new Float(getFloat(row));
084:            }
085:
086:            /**
087:             * @see prefuse.data.column.Column#set(java.lang.Object, int)
088:             */
089:            public void set(Object val, int row) throws DataTypeException {
090:                if (m_readOnly) {
091:                    throw new DataReadOnlyException();
092:                } else if (val != null) {
093:                    if (val instanceof  Number) {
094:                        setFloat(((Number) val).floatValue(), row);
095:                    } else if (val instanceof  String) {
096:                        setString((String) val, row);
097:                    } else {
098:                        throw new DataTypeException(val.getClass());
099:                    }
100:                } else {
101:                    throw new DataTypeException(
102:                            "Column does not accept null values");
103:                }
104:            }
105:
106:            // ------------------------------------------------------------------------
107:            // Data Type Convenience Methods
108:
109:            /**
110:             * @see prefuse.data.column.AbstractColumn#getFloat(int)
111:             */
112:            public float getFloat(int row) throws DataTypeException {
113:                if (row < 0 || row > m_size) {
114:                    throw new IllegalArgumentException(
115:                            "Row index out of bounds: " + row);
116:                }
117:                return m_values[row];
118:            }
119:
120:            /**
121:             * @see prefuse.data.column.AbstractColumn#setFloat(float, int)
122:             */
123:            public void setFloat(float val, int row) throws DataTypeException {
124:                if (m_readOnly) {
125:                    throw new DataReadOnlyException();
126:                } else if (row < 0 || row >= m_size) {
127:                    throw new IllegalArgumentException(
128:                            "Row index out of bounds: " + row);
129:                }
130:                // get the previous value
131:                float prev = m_values[row];
132:
133:                // exit early if no change
134:                if (prev == val)
135:                    return;
136:
137:                // set the new value
138:                m_values[row] = val;
139:
140:                // fire a change event
141:                fireColumnEvent(row, prev);
142:            }
143:
144:            //    /**
145:            //     * @see prefuse.data.column.AbstractColumn#getString(int)
146:            //     */
147:            //    public String getString(int row) throws DataTypeException {
148:            //        return String.valueOf(getFloat(row));
149:            //    }
150:            //
151:            //    /**
152:            //     * @see prefuse.data.column.AbstractColumn#setString(java.lang.String, int)
153:            //     */
154:            //    public void setString(String val, int row) throws DataTypeException {
155:            //        setFloat(Float.parseFloat(val), row);
156:            //    }
157:
158:            // ------------------------------------------------------------------------
159:
160:            /**
161:             * @see prefuse.data.column.Column#getInt(int)
162:             */
163:            public int getInt(int row) throws DataTypeException {
164:                return (int) getFloat(row);
165:            }
166:
167:            /**
168:             * @see prefuse.data.column.Column#getLong(int)
169:             */
170:            public long getLong(int row) throws DataTypeException {
171:                return (long) getFloat(row);
172:            }
173:
174:            /**
175:             * @see prefuse.data.column.Column#getDouble(int)
176:             */
177:            public double getDouble(int row) throws DataTypeException {
178:                return getFloat(row);
179:            }
180:
181:        } // end of class FloatColumn
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.