Source Code Cross Referenced for BasicCanvasFieldNode.java in  » IDE-Netbeans » soa » org » netbeans » modules » soa » mapper » basicmapper » canvas » jgo » 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 » soa » org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        package org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo;
021:
022:        import java.awt.Color;
023:        import java.awt.Dimension;
024:        import java.beans.PropertyChangeEvent;
025:        import java.beans.PropertyChangeListener;
026:
027:        import com.nwoods.jgo.JGoBrush;
028:        import com.nwoods.jgo.JGoObject;
029:        import com.nwoods.jgo.JGoPen;
030:        import com.nwoods.jgo.JGoPort;
031:        import java.awt.Point;
032:        import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.util.DrawPort;
033:        import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasView;
034:        import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IFieldNode;
035:        import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IMethoid;
036:        import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IMethoidNode;
037:        import org.netbeans.modules.soa.mapper.common.IMapperGroupNode;
038:        import org.netbeans.modules.soa.mapper.common.IMapperNode;
039:        import org.netbeans.modules.soa.mapper.common.gtk.ICanvasGroupNode;
040:
041:        /**
042:         * <p>
043:         *
044:         * Title: </p> BasicCanvasFieldNode <p>
045:         *
046:         * Description: </p> BasicCanvasFieldNode provides an implemenation of canvas
047:         * field node. The port circles are explictly handled by this class and not
048:         * added to this JGoArea due to its bounding exceeds this bounding area. They
049:         * are added and removed directly to the document. <p>
050:         *
051:         * @author    Un Seng Leong
052:         * @created   January 2, 2003
053:         */
054:        public class BasicCanvasFieldNode extends AbstractCanvasFieldNode {
055:
056:            private static final Color TEXT_COLOR_RESULT = Color.WHITE;
057:            private static final Color TEXT_COLOR_INPUT = Color.BLACK;
058:            private static final Color TEXT_COLOR_LITERAL = new Color(30, 70,
059:                    230); // navy
060:
061:            private static final JGoPen BORDER_INPUT_REGULAR = JGoPen
062:                    .makeStockPen(new Color(186, 205, 240)); // baby blue
063:            private static final JGoPen BORDER_OUTPUT_REGULAR = JGoPen
064:                    .makeStockPen(new Color(116, 140, 192)); // purple
065:            private static final JGoPen BORDER_HOVER = JGoPen.make(
066:                    JGoPen.SOLID, 1, new Color(0, 24, 127));
067:
068:            private static final JGoBrush BRUSH_LITERAL = JGoBrush
069:                    .makeStockBrush(Color.WHITE);
070:            private static final JGoBrush BRUSH_REGULAR = JGoBrush
071:                    .makeStockBrush(new Color(255, 255, 255, 0)); // transparent
072:            private static final JGoBrush BRUSH_RESULT = JGoBrush
073:                    .makeStockBrush(new Color(116, 140, 192)); // purple
074:
075:            private DrawPort mInPort;
076:            private DrawPort mOutPort;
077:            private BasicCanvasPort mPort;
078:            private String mCurrentTextStyle = "";
079:            private boolean mIsResultField;
080:            private boolean mIsLiteral;
081:
082:            /**
083:             * Creates a new BasicCanvasFieldNode object.
084:             *
085:             * @param node  the field node
086:             */
087:            public BasicCanvasFieldNode(IFieldNode node) {
088:                super (node);
089:                node.addPropertyChangeListener(new PropertyChangeListener() {
090:                    public void propertyChange(PropertyChangeEvent e) {
091:                        String propName = e.getPropertyName();
092:                        if (IFieldNode.NAME_CHANGED.equals(propName)) {
093:                            updateLabel((String) e.getNewValue());
094:                        } else if (IFieldNode.FIELD_OBJECT_CHANGED
095:                                .equals(propName)) {
096:                            updateLabel(mFieldNode.getName());
097:                        } else if (IFieldNode.STYLE_CHANGED.equals(propName)) {
098:                            updateLabelStyle((String) e.getNewValue());
099:                        } else if (IMapperNode.LINK_ADDED.equals(propName)) {
100:                            setPortStyleVacant(false);
101:                        } else if (IMapperNode.LINK_REMOVED.equals(propName)) {
102:                            setPortStyleVacant(true);
103:                        }
104:                    }
105:                });
106:                mPort = new BasicCanvasPort();
107:                mPort.setStyle(JGoPort.StyleObject);
108:                mPort.setValidDestination(false);
109:                mPort.setValidSource(false);
110:                mPort.setSelectable(false);
111:                mPort.setDraggable(true);
112:
113:                mIsResultField = node.isOutput();
114:                IMapperGroupNode groupNode = node.getGroupNode();
115:                if (groupNode instanceof  IMethoidNode) {
116:                    IMethoidNode methoidNode = (IMethoidNode) groupNode;
117:                    if (methoidNode.getMethoidObject() instanceof  IMethoid) {
118:                        IMethoid methoid = (IMethoid) methoidNode
119:                                .getMethoidObject();
120:                        if (methoid.isLiteral()) {
121:                            mIsResultField = false;
122:                            mIsLiteral = true;
123:                        }
124:                    }
125:                }
126:
127:                if (node.isInput()) {
128:                    mInPort = makePort();
129:                    mPort.setValidDestination(true);
130:                }
131:
132:                if (node.isOutput()) {
133:                    mOutPort = makePort();
134:                    mPort.setValidSource(true);
135:                }
136:
137:                mPort.setPortObject(getDrawPort());
138:                layoutPorts();
139:
140:                setHorizonalAligment(LEFT);
141:
142:                if (mIsResultField) {
143:                    setBrush(BRUSH_RESULT);
144:                } else if (mIsLiteral) {
145:                    setBrush(BRUSH_LITERAL);
146:                } else {
147:                    setBrush(BRUSH_REGULAR);
148:                }
149:
150:                mCurrentTextStyle = IFieldNode.STYLE_TYPE_NORMAL;
151:                setTextColorFromStyle(mCurrentTextStyle);
152:            }
153:
154:            private DrawPort makePort() {
155:                DrawPort ob = new DrawPort(this );
156:                ob.setDraggable(false);
157:                ob.setSelectable(false);
158:                ob.setResizable(false);
159:                return ob;
160:            }
161:
162:            /**
163:             * Return the connection point object of this node.
164:             *
165:             * @return   the connection point object of this node.
166:             */
167:            public Object getConnectPointObject() {
168:                return mPort;
169:            }
170:
171:            public DrawPort getDrawPort() {
172:                if (mInPort != null) {
173:                    return mInPort;
174:                } else if (mOutPort != null) {
175:                    return mOutPort;
176:                }
177:                return null;
178:            }
179:
180:            /**
181:             * Set the mapper canvas that displays this node.
182:             *
183:             * @param canvas  the canvas displays this node.
184:             */
185:            public void setMapperCanvas(ICanvasView canvas) {
186:                super .setMapperCanvas(canvas);
187:
188:                if (mInPort != null) {
189:                    // white top/bottom border around each input field
190:                    setPen(BORDER_INPUT_REGULAR);
191:                }
192:
193:                if (mOutPort != null) {
194:                    setPen(BORDER_OUTPUT_REGULAR);
195:                }
196:            }
197:
198:            public void setIsHovering(boolean isHovering) {
199:                if (mInPort != null) {
200:                    // input ports show special hover animation: dark blue rectangle
201:                    setPen(isHovering ? BORDER_HOVER : BORDER_INPUT_REGULAR);
202:                }
203:            }
204:
205:            /**
206:             * Defines the location of the drawing region (port object) of the
207:             * DrawPort as well as the bounding rect of the JGoPort itself.
208:             */
209:            public void layoutPorts() {
210:                Point point = null;
211:                if (mOutPort != null) {
212:                    point = getSpotLocation(JGoObject.RightCenter);
213:                    Dimension drawSize = mPort.getDrawSize();
214:                    int offset = 3;
215:                    mOutPort.setDrawLocation(point.x + offset, point.y
216:                            - drawSize.height / 2);
217:                    mPort.setBoundingRect(getLeft(), getTop(), getWidth()
218:                            + drawSize.width + offset, getHeight());
219:                }
220:
221:                if (mInPort != null) {
222:                    point = getSpotLocation(JGoObject.LeftCenter);
223:                    Dimension drawSize = mPort.getDrawSize();
224:                    int offset = drawSize.width + 2;
225:                    mInPort.setDrawLocation(point.x - offset, point.y
226:                            - drawSize.height / 2);
227:                    mPort.setBoundingRect(getLeft() - offset, getTop(),
228:                            getWidth() + offset, getHeight());
229:                }
230:            }
231:
232:            /**
233:             * Sets the visible attribute of the BasicCanvasFieldNode object
234:             *
235:             * @param visible  The new visible value
236:             */
237:            public void setVisible(boolean visible) {
238:                super .setVisible(visible);
239:                mPort.setVisible(visible);
240:            }
241:
242:            private void updateLabelStyle(String newStyle) {
243:                if (mCurrentTextStyle.equals(newStyle)) {
244:                    return;
245:                }
246:                if (!IFieldNode.STYLE_TYPE_NORMAL.equals(newStyle)
247:                        && !IFieldNode.STYLE_TYPE_LITERAL.equals(newStyle)) {
248:                    throw new IllegalArgumentException("Style " + newStyle
249:                            + " not supported.");
250:                }
251:                mCurrentTextStyle = newStyle;
252:                setTextColorFromStyle(newStyle);
253:                setPortStyleVacant(IFieldNode.STYLE_TYPE_NORMAL
254:                        .equals(newStyle));
255:                ensureContainerSize();
256:            }
257:
258:            /**
259:             * update the text of this node.
260:             *
261:             * @param text  update the text of this node.
262:             */
263:            public void updateLabel(String text) {
264:                super .updateLabel(text);
265:
266:                ensureContainerSize();
267:            }
268:
269:            private void ensureContainerSize() {
270:                // ensure methoid canvas node size is updated
271:                ICanvasGroupNode container = getContainer();
272:                if (container != null) {
273:                    if (container instanceof  BasicCanvasMethoidNode) {
274:                        ((BasicCanvasMethoidNode) container).ensureBounding();
275:                    }
276:                }
277:            }
278:
279:            public void setHighlight(boolean isHighlighted) {
280:                DrawPort port = getDrawPort();
281:                if (port != null) {
282:                    port.setIsActivated(isHighlighted);
283:                }
284:            }
285:
286:            private void setTextColorFromStyle(String newStyle) {
287:                if (mIsResultField) {
288:                    setTextColor(TEXT_COLOR_RESULT);
289:                } else if (newStyle.equals(IFieldNode.STYLE_TYPE_NORMAL)) {
290:                    setTextColor(TEXT_COLOR_INPUT);
291:                } else if (newStyle.equals(IFieldNode.STYLE_TYPE_LITERAL)) {
292:                    setTextColor(TEXT_COLOR_LITERAL);
293:                }
294:            }
295:
296:            private void setPortStyleVacant(boolean isVacant) {
297:                DrawPort port = getDrawPort();
298:                if (port != null) {
299:                    port.setIsConnected(!isVacant);
300:                }
301:            }
302:        }
w__w__w___.__j__a__va__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.