Source Code Cross Referenced for BasicListArea.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » sql » framework » ui » graph » impl » 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 » IDE Netbeans » etl.project » org.netbeans.modules.sql.framework.ui.graph.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:
042:        package org.netbeans.modules.sql.framework.ui.graph.impl;
043:
044:        import java.awt.Color;
045:        import java.awt.Insets;
046:        import java.awt.Point;
047:
048:        import javax.swing.DefaultListModel;
049:        import javax.swing.ListModel;
050:
051:        import com.nwoods.jgo.JGoObject;
052:
053:        /**
054:         * @author Ritesh Adval
055:         * @version $Revision$
056:         */
057:        public class BasicListArea extends BasicCanvasArea {
058:
059:            protected static final GradientBrush BRUSH_TITLE = new GradientBrush(
060:                    new Color(221, 221, 255), // light
061:                    // magenta
062:                    new Color(160, 186, 213)); // navy
063:
064:            /**
065:             * list area in this Basic List Area
066:             */
067:            protected ListArea listArea;
068:
069:            /**
070:             * Creates a new instance of BasicListArea
071:             * 
072:             * @param title title
073:             */
074:            public BasicListArea(String title) {
075:                this .setPickableBackground(true);
076:                this .setSelectable(true);
077:                titleArea = new TitleArea(title);
078:                titleArea.setBrush(BRUSH_TITLE);
079:
080:                this .addObjectAtTail(titleArea);
081:            }
082:
083:            /**
084:             * create an instance of list area
085:             * 
086:             * @param title title
087:             * @param data list cell data array
088:             */
089:            public BasicListArea(String title, Object[] data) {
090:                this (title);
091:
092:                listArea = new ListArea();
093:                // don not draw lines in the list area
094:                // line drawing occurs in paint method
095:                listArea.setDrawLines(false);
096:                listArea.setVerticalSpacing(0);
097:
098:                this .addObjectAtTail(listArea);
099:
100:                DefaultListModel model = new DefaultListModel();
101:
102:                for (int i = 0; i < data.length; i++) {
103:                    model.addElement(data[i]);
104:                }
105:                setModel(model);
106:
107:            }
108:
109:            /**
110:             * add an object in list area
111:             * 
112:             * @param val value
113:             */
114:            public void add(Object val) {
115:                DefaultListModel dListModel = (DefaultListModel) getModel();
116:                dListModel.addElement(val);
117:            }
118:
119:            /**
120:             * add the list cell at a specfic row index
121:             * 
122:             * @param row row
123:             * @param val value
124:             */
125:            public void add(int row, Object val) {
126:                DefaultListModel dListModel = (DefaultListModel) getModel();
127:                dListModel.add(row, val);
128:            }
129:
130:            /**
131:             * set the first visible row of the list
132:             * 
133:             * @param rowIdx row index
134:             */
135:            public void setFirstVisibleRow(int rowIdx) {
136:                listArea.setFirstVisibleRow(rowIdx);
137:            }
138:
139:            /**
140:             * set the last visible row of the list
141:             * 
142:             * @param rowIdx row index
143:             */
144:            public void setLastVisibleRow(int rowIdx) {
145:                listArea.setLastVisibleRow(rowIdx);
146:            }
147:
148:            /**
149:             * get the index of child object
150:             * 
151:             * @param val value
152:             * @return index of child object
153:             */
154:            public int getIndexOf(Object val) {
155:                DefaultListModel dListModel = (DefaultListModel) getModel();
156:                return dListModel.indexOf(val);
157:            }
158:
159:            /**
160:             * get the value at a particular point
161:             * 
162:             * @param loc location
163:             * @return value at a point
164:             */
165:            public Object getValueAt(Point loc) {
166:                return listArea.getValueAt(loc);
167:            }
168:
169:            /**
170:             * get the title area of this list
171:             * 
172:             * @return title area
173:             */
174:            public TitleArea getTitleArea() {
175:                return titleArea;
176:            }
177:
178:            /**
179:             * get maximum width of this area
180:             * 
181:             * @return max width
182:             */
183:            public int getMaximumWidth() {
184:                int maxWidth = getInsets().left + getInsets().right;
185:
186:                int w = 0;
187:
188:                w = titleArea.getMaximumWidth();
189:
190:                if (listArea.getMaximumWidth() > w) {
191:                    w = listArea.getMaximumWidth();
192:                }
193:
194:                maxWidth += w;
195:
196:                return maxWidth;
197:            }
198:
199:            /**
200:             * get the maximum height of this area
201:             * 
202:             * @return max height
203:             */
204:            public int getMaximumHeight() {
205:                int maxHeight = getInsets().top + getInsets().bottom;
206:
207:                maxHeight += titleArea.getMaximumHeight();
208:                maxHeight += listArea.getMaximumHeight();
209:
210:                return maxHeight;
211:            }
212:
213:            /**
214:             * get the minimum width of this area
215:             * 
216:             * @return minimum width
217:             */
218:            public int getMinimumWidth() {
219:                int minWidth = 0;
220:                minWidth = getInsets().left + getInsets().right;
221:                minWidth += titleArea.getMinimumWidth();
222:
223:                return minWidth;
224:            }
225:
226:            /**
227:             * get the minimum height of this area
228:             * 
229:             * @return minimum height
230:             */
231:            public int getMinimumHeight() {
232:                int minHeight = 0;
233:                minHeight = getInsets().top + getInsets().bottom;
234:                minHeight += titleArea.getMinimumHeight();
235:
236:                return minHeight;
237:            }
238:
239:            // override this to get the visible row height.
240:            // subclass must override this if they have any custom areas
241:            protected int getVisibleRowHeights() {
242:                int visHeight = getInsets().top + getInsets().bottom;
243:                visHeight += titleArea.getMaximumHeight();
244:                visHeight += listArea.getVisibleRowHeights();
245:
246:                return visHeight;
247:            }
248:
249:            /**
250:             * get the vertical spacing
251:             * 
252:             * @return vertical spacing
253:             */
254:            public int getVerticalSpacing() {
255:                return listArea.getVerticalSpacing();
256:            }
257:
258:            /**
259:             * set the vertical spacing between cells of this list area
260:             * 
261:             * @param newspace new vertical space
262:             */
263:            public void setVerticalSpacing(int newspace) {
264:                listArea.setVerticalSpacing(0);
265:            }
266:
267:            /**
268:             * set the vertical scrollbar gap from the edge of the list area
269:             * 
270:             * @param gap gap
271:             */
272:            public void setVerticalScrollBarGapFromEdge(int gap) {
273:                listArea.setVerticalScrollBarGapFromEdge(gap);
274:            }
275:
276:            /**
277:             * this gets the notification from the TableTitleArea when it expansion or collapse
278:             * image is clicked
279:             * 
280:             * @param hint event hint
281:             * @param prevInt previous integer value
282:             * @param prevVal previous object val
283:             */
284:            public void update(int hint, int prevInt, Object prevVal) {
285:                if (hint == TitleArea.EXPANSION_STATE_CHANGED) {
286:                    // optimization: assume area doesn't change when scrolling items
287:                    if (titleArea.getState() == TitleArea.EXPANDED) {
288:                        setExpanded(true);
289:                    } else {
290:                        setExpanded(false);
291:                    }
292:                    JGoObject parent = this .getParent();
293:                    if (parent != null) {
294:                        parent.update(hint, prevInt, prevVal);
295:                    }
296:                } else {
297:                    super .update(hint, prevInt, prevVal);
298:                }
299:            }
300:
301:            public boolean adjustHeight(JGoObject child) {
302:                // uncomment this once tested properly with scrolling
303:                if (child.equals(listArea) && this .isExpandedState()) {
304:
305:                    this .setHeight(getVisibleRowHeights());
306:                    return true;
307:                }
308:
309:                return false;
310:            }
311:
312:            /**
313:             * layout the children of this list area
314:             */
315:            public void layoutChildren() {
316:                Insets insets1 = getInsets();
317:
318:                // get the bounding rectangle of this table area
319:                int x = getLeft() + insets1.left;
320:                int y = getTop() + insets1.top;
321:                int width = getWidth() - insets1.left - insets1.right;
322:                int height = getHeight() - insets1.top - insets1.bottom;
323:
324:                titleArea.setBoundingRect(x, y, width, titleArea
325:                        .getMinimumHeight());
326:
327:                if (height - titleArea.getHeight() > 0) {
328:                    listArea.setVisible(true);
329:                    listArea.setOutOfScrollCellBounds(titleArea
330:                            .getBoundingRect());
331:                    listArea.setBoundingRect(x, y + titleArea.getHeight(),
332:                            width, height - titleArea.getHeight());
333:                } else {
334:                    listArea.setVisible(false);
335:                    listArea.setOutOfScrollCellBounds(titleArea
336:                            .getBoundingRect());
337:                    listArea.setBoundingRect(titleArea.getBoundingRect());
338:                }
339:            }
340:
341:            /**
342:             * set the model for this list area
343:             * 
344:             * @param model list model
345:             */
346:            public void setModel(ListModel model) {
347:                listArea.setModel(model);
348:            }
349:
350:            /**
351:             * get the list model of this list area
352:             * 
353:             * @return list model
354:             */
355:            public ListModel getModel() {
356:                return listArea.getModel();
357:            }
358:
359:        }
w___w_w___.___j_a_v___a__2___s_.___co___m | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.