01: /*
02: * The contents of this file are subject to the terms of the Common Development
03: * and Distribution License (the License). You may not use this file except in
04: * compliance with the License.
05: *
06: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
07: * or http://www.netbeans.org/cddl.txt.
08:
09: * When distributing Covered Code, include this CDDL Header Notice in each file
10: * and include the License file at http://www.netbeans.org/cddl.txt.
11: * If applicable, add the following below the CDDL Header, with the fields
12: * enclosed by brackets [] replaced by your own identifying information:
13: * "Portions Copyrighted [year] [name of copyright owner]"
14: *
15: * The Original Software is NetBeans. The Initial Developer of the Original
16: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17: * Microsystems, Inc. All Rights Reserved.
18: */
19:
20: package org.netbeans.test.xslt.lib;
21:
22: import java.awt.Point;
23: import java.awt.Rectangle;
24: import java.util.Collection;
25: import java.util.Iterator;
26: import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.BasicCanvasFieldNode;
27: import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.util.DrawPort;
28: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasMethoidNode;
29:
30: /**
31: *
32: * @author ca@netbeans.org
33: */
34:
35: public class MethoidOperator {
36: private ICanvasMethoidNode m_canvasMethoidNode;
37:
38: /** Creates a new instance of MethoidOperator */
39: public MethoidOperator(ICanvasMethoidNode canvasMethoidNode) {
40: m_canvasMethoidNode = canvasMethoidNode;
41: }
42:
43: public int getPortCount() {
44: int counter = 0;
45:
46: Collection c = m_canvasMethoidNode.getNodes();
47: Iterator iter = c.iterator();
48: while (iter.hasNext()) {
49: Object obj = iter.next();
50: if (obj instanceof BasicCanvasFieldNode) {
51: counter++;
52: }
53: }
54:
55: return counter;
56: }
57:
58: public Point getPortPoint(int portNumber) {
59: int counter = 0;
60: Point point = null;
61:
62: Collection c = m_canvasMethoidNode.getNodes();
63: Iterator iter = c.iterator();
64: while (iter.hasNext()) {
65: Object obj = iter.next();
66: if (obj instanceof BasicCanvasFieldNode) {
67: if (counter++ == portNumber) {
68: BasicCanvasFieldNode fieldNode = (BasicCanvasFieldNode) obj;
69: DrawPort port = fieldNode.getDrawPort();
70: Rectangle rect = port.getBoundingRect();
71:
72: Helpers.writeJemmyLog("Methoid:"
73: + m_canvasMethoidNode.getBounding());
74: return new Point(rect.x + rect.width / 2, rect.y
75: + rect.height / 2);
76: }
77: }
78: }
79:
80: return point;
81: }
82:
83: public Rectangle getBoundings() {
84: return m_canvasMethoidNode.getBounding();
85: }
86: }
|