Source Code Cross Referenced for OperatorGraphNode.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:        package org.netbeans.modules.sql.framework.ui.graph.impl;
042:
043:        import java.awt.Color;
044:        import java.awt.Rectangle;
045:        import java.util.ArrayList;
046:        import java.util.List;
047:
048:        import javax.swing.Icon;
049:
050:        import org.netbeans.modules.sql.framework.ui.graph.IGraphFieldNode;
051:        import org.netbeans.modules.sql.framework.ui.graph.IGraphPort;
052:        import org.netbeans.modules.sql.framework.ui.graph.IOperatorField;
053:        import org.netbeans.modules.sql.framework.ui.graph.IOperatorXmlInfo;
054:
055:        import com.nwoods.jgo.JGoBrush;
056:        import com.nwoods.jgo.JGoObject;
057:        import com.nwoods.jgo.JGoPen;
058:        import com.nwoods.jgo.JGoRectangle;
059:        import com.nwoods.jgo.JGoText;
060:
061:        /**
062:         * @author Ritesh Adval
063:         * @version $Revision$
064:         */
065:        public class OperatorGraphNode extends BasicCanvasArea {
066:
067:            private static final GradientBrush BRUSH_TITLE = new GradientBrush(
068:                    new Color(221, 221, 255), // light
069:                    // magenta
070:                    new Color(160, 186, 213)); // navy
071:
072:            private static final Color DEFAULT_BG_COLOR = new Color(254, 253,
073:                    235);
074:
075:            private static final JGoPen PEN_DEFAULT = JGoPen
076:                    .makeStockPen(Color.WHITE);
077:
078:            protected ArrayList fieldList = new ArrayList();;
079:            protected int verticalGap = 0;
080:            protected JGoRectangle columnRect;
081:
082:            protected OperatorGraphFieldNode resultField;
083:
084:            public OperatorGraphNode(String displayName, String toolTip,
085:                    Icon icon) {
086:                super ();
087:                columnRect = new JGoRectangle();
088:                columnRect.setSelectable(true);
089:                columnRect.setPen(PEN_DEFAULT);
090:                columnRect.setBrush(JGoBrush.makeStockBrush(DEFAULT_BG_COLOR));
091:                addObjectAtHead(columnRect);
092:
093:                titleArea = new TitleArea(displayName);
094:                titleArea.setShowDot(false);
095:                titleArea.setTextAndExpandedImgGap(10);
096:                titleArea.setToolTipText(toolTip);
097:                titleArea.setTitleImage(icon);
098:                titleArea.setPen(PEN_DEFAULT);
099:                titleArea.setBrush(BRUSH_TITLE);
100:                this .addObjectAtTail(titleArea);
101:
102:                this .setResizable(false);
103:                this .setSelectable(true);
104:                this .setPickableBackground(true);
105:
106:                // RJR - remove setting of fieldlist which was causing a NPE
107:            }
108:
109:            /**
110:             * Creates a new instance of OperatorGraphNode using GUI info contained in the given
111:             * configuration object.
112:             * 
113:             * @param info IOperatorXmlInfo object containing operator layout info.
114:             */
115:            public OperatorGraphNode(IOperatorXmlInfo info) {
116:                this (info.getDisplayName(), info.getToolTip(), info.getIcon());
117:            }
118:
119:            /**
120:             * Initialize this instance using GUI info contained in the given configuration
121:             * object.
122:             * 
123:             * @param info IOperatorXmlInfo object containing operator layout info.
124:             */
125:            protected void initialize(IOperatorXmlInfo info) {
126:                // add input graph field
127:                for (int i = 0; i < info.getInputCount(); i++) {
128:                    IOperatorField field = (IOperatorField) info
129:                            .getInputFields().get(i);
130:
131:                    OperatorGraphFieldNode fieldNode = new OperatorGraphFieldNode(
132:                            BasicCellArea.LEFT_PORT_AREA, field);
133:
134:                    this .addObjectAtTail(fieldNode);
135:                    fieldList.add(fieldNode);
136:                }
137:
138:                // add output graph field
139:                for (int i = 0; i < info.getOutputCount(); i++) {
140:                    IOperatorField field = (IOperatorField) info
141:                            .getOutputFields().get(i);
142:
143:                    OperatorGraphFieldNode fieldNode = new OperatorGraphFieldNode(
144:                            BasicCellArea.RIGHT_PORT_AREA, field,
145:                            JGoText.ALIGN_CENTER);
146:
147:                    // there is only one result field for operator
148:                    resultField = fieldNode;
149:                    this .addObjectAtTail(fieldNode);
150:                    fieldList.add(fieldNode);
151:                }
152:            }
153:
154:            /**
155:             * Gets the minimum height of this area
156:             * 
157:             * @return minimum height
158:             */
159:            public int getMinimumHeight() {
160:                int minHeight = 0;
161:                minHeight = getInsets().top + getInsets().bottom;
162:                minHeight += titleArea.getMinimumHeight();
163:
164:                return minHeight;
165:            }
166:
167:            /**
168:             * Gets maximum height
169:             * 
170:             * @return max height
171:             */
172:            public int getMaximumHeight() {
173:                int maxHeight = 0;
174:                maxHeight = getInsets().top + getInsets().bottom;
175:                maxHeight += titleArea.getMaximumHeight();
176:
177:                for (int i = 0; i < fieldList.size(); i++) {
178:                    CanvasArea fieldNode = (CanvasArea) fieldList.get(i);
179:                    maxHeight += fieldNode.getMaximumHeight() + verticalGap;
180:                }
181:
182:                return maxHeight;
183:            }
184:
185:            /**
186:             * Gets the maximum width
187:             * 
188:             * @return max width
189:             */
190:            public int getMinimumWidth() {
191:                int minWidth = titleArea.getMinimumWidth();
192:
193:                for (int i = 0; i < fieldList.size(); i++) {
194:                    CanvasArea fieldNode = (CanvasArea) fieldList.get(i);
195:
196:                    int w = fieldNode.getMinimumWidth();
197:                    if (w > minWidth) {
198:                        minWidth = w;
199:                    }
200:                }
201:
202:                minWidth += getInsets().left + getInsets().right;
203:                return minWidth;
204:            }
205:
206:            public int getMaximumWidth() {
207:                int maxWidth = titleArea.getMaximumWidth();
208:
209:                for (int i = 0; i < fieldList.size(); i++) {
210:                    CanvasArea fieldNode = (CanvasArea) fieldList.get(i);
211:
212:                    int w = fieldNode.getMaximumWidth();
213:                    if (w > maxWidth) {
214:                        maxWidth = w;
215:                    }
216:                }
217:
218:                maxWidth += getInsets().left + getInsets().right;
219:                return maxWidth;
220:            }
221:
222:            /**
223:             * Constrains instance to the maximum height; do not allow resize in height. Also,
224:             * enforces minimum width for the operator.
225:             * 
226:             * @param left left
227:             * @param top top
228:             * @param width width
229:             * @param height height
230:             */
231:            public void setBoundingRect(int left, int top, int width, int height) {
232:                super .setBoundingRect(left, top, width, Math.min(height,
233:                        getMaximumHeight()));
234:            }
235:
236:            protected boolean geometryChangeChild(JGoObject child,
237:                    Rectangle prevRect) {
238:                // do nothing as we do not want to listen to changes in children
239:                return true;
240:            }
241:
242:            /**
243:             * Handles geometry change
244:             * 
245:             * @param prevRect previous bounds rectangle
246:             */
247:            protected void geometryChange(Rectangle prevRect) {
248:                // handle any size changes by repositioning all the items
249:                if (prevRect.width != getWidth()
250:                        || prevRect.height != getHeight()) {
251:                    layoutChildren();
252:                } else {
253:                    super .geometryChange(prevRect);
254:                }
255:            }
256:
257:            /**
258:             * Lays out this area's child objects.
259:             */
260:            public void layoutChildren() {
261:                columnRect.setBoundingRect(this .getBoundingRect());
262:
263:                int rectleft = getLeft();
264:                int recttop = getTop();
265:                int rectwidth = getWidth();
266:                int rectheight = getHeight();
267:
268:                int left = rectleft + insets.left;
269:                int top = recttop + insets.top;
270:                int width = rectwidth - insets.left - insets.right;
271:                int height = rectheight - insets.top - insets.bottom;
272:
273:                titleArea.setBoundingRect(left, top, width, titleArea
274:                        .getMinimumHeight());
275:
276:                int aggrHeight = top + titleArea.getMinimumHeight();
277:
278:                for (int i = 0; i < fieldList.size(); i++) {
279:                    CanvasArea fieldNode = (CanvasArea) fieldList.get(i);
280:
281:                    if (aggrHeight < top + height) {
282:                        fieldNode.setVisible(true);
283:                        fieldNode.setBoundingRect(left, aggrHeight, width,
284:                                fieldNode.getHeight() + verticalGap);
285:                    } else {
286:                        fieldNode.setVisible(false);
287:                        fieldNode.setBoundingRect(left, top, width, fieldNode
288:                                .getHeight()
289:                                + verticalGap);
290:                    }
291:                    aggrHeight += fieldNode.getHeight() + verticalGap;
292:                }
293:            }
294:
295:            /**
296:             * Gets field name associated with the given port
297:             * 
298:             * @param graphPort graph port
299:             * @return field name
300:             */
301:            public String getFieldName(IGraphPort graphPort) {
302:                for (int i = 0; i < fieldList.size(); i++) {
303:                    IGraphFieldNode fieldNode = (IGraphFieldNode) fieldList
304:                            .get(i);
305:
306:                    if (graphPort.equals(fieldNode.getLeftGraphPort())
307:                            || graphPort.equals(fieldNode.getRightGraphPort())) {
308:                        return fieldNode.getName();
309:                    }
310:                }
311:                return null;
312:            }
313:
314:            /**
315:             * Gets input graph port, if any, associated with the given field name
316:             * 
317:             * @param fieldName field name
318:             * @return graph port
319:             */
320:            public IGraphPort getInputGraphPort(String fieldName) {
321:
322:                if (fieldName == null) {
323:                    return null;
324:                }
325:
326:                for (int i = 0; i < fieldList.size(); i++) {
327:                    IGraphFieldNode fieldNode = (IGraphFieldNode) fieldList
328:                            .get(i);
329:
330:                    if (fieldName.equals(fieldNode.getName())) {
331:                        return fieldNode.getLeftGraphPort();
332:                    }
333:                }
334:                return null;
335:            }
336:
337:            /**
338:             * Gets output graph port, if any, associated with the given field name
339:             * 
340:             * @param fieldName field name
341:             * @return graph port
342:             */
343:            public IGraphPort getOutputGraphPort(String fieldName) {
344:                return resultField.getRightGraphPort();
345:            }
346:
347:            /**
348:             * Gets object, if any, associated with the given port
349:             * 
350:             * @param graphPort graph port
351:             * @return object for the given port
352:             */
353:            Object getObject(IGraphPort graphPort) {
354:                return null;
355:            }
356:
357:            /**
358:             * Gets port, if any, associated with the given object
359:             * 
360:             * @param graphPort graph port
361:             * @return object for the given port
362:             */
363:            IGraphPort getGraphPort(Object obj) {
364:                return null;
365:            }
366:
367:            /**
368:             * Gets a list of all input and output links
369:             * 
370:             * @return list of input links
371:             */
372:            public List getAllLinks() {
373:                ArrayList list = new ArrayList();
374:
375:                for (int i = 0; i < fieldList.size(); i++) {
376:                    IGraphFieldNode fieldNode = (IGraphFieldNode) fieldList
377:                            .get(i);
378:                    IGraphPort port = fieldNode.getLeftGraphPort();
379:                    if (port != null) {
380:                        addLinks(port, list);
381:                    }
382:                    port = fieldNode.getRightGraphPort();
383:                    if (port != null) {
384:                        addLinks(port, list);
385:                    }
386:                }
387:
388:                return list;
389:            }
390:        }
w_ww___.__j___ava__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.