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 com.nwoods.jgo.JGoPort;
023: import com.nwoods.jgo.JGoView;
024: import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.AbstractCanvasLink.NodeYChangeListener;
025: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasFieldNode;
026: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasTreeToNodeLink;
027: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasView;
028: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IFieldNode;
029: import org.netbeans.modules.soa.mapper.common.basicmapper.tree.IMapperTreeNode;
030: import org.netbeans.modules.soa.mapper.common.IMapperLink;
031:
032: /**
033: * <p>
034: *
035: * Title: </p> BasicCanvasTreeToNodeLink<p>
036: *
037: * Description: </p> BasicCanvasTreeToNodeLink provides basic implementation of
038: * ICanvasTreeToNodeLink <p>
039: *
040: * Copyright: Copyright (c) 2002 </p> <p>
041: *
042: * Company: </p>
043: *
044: * @author Un Seng Leong
045: * @created January 2, 2003
046: * @version 1.0
047: */
048: public class BasicCanvasTreeToNodeLink extends AbstractCanvasLink
049: implements ICanvasTreeToNodeLink {
050:
051: /**
052: * the end canvas node
053: */
054: private ICanvasFieldNode mCanvasNode;
055:
056: /**
057: * the node change listener
058: */
059: private NodeYChangeListener mYListener;
060:
061: /**
062: * Creates a new BasicCanvasTreeToNodeLink object.
063: *
064: * @param link the mapper link
065: */
066: public BasicCanvasTreeToNodeLink(IMapperLink link) {
067: super (link);
068: this .setArrowHeads(false, true);
069: initializeArrowHeads(this );
070: startPort = new BasicCanvasPort();
071: startPort.setDraggable(false);
072: startPort.setSelectable(false);
073: startPort.setStyle(JGoPort.StyleHidden);
074: this .setFromPort(startPort);
075: }
076:
077: /**
078: * Return the canvas field node repersetns the end point of this link.
079: *
080: * @return the canvas node repersetns the end point of this link.
081: */
082: public ICanvasFieldNode getDestFieldNode() {
083: return mCanvasNode;
084: }
085:
086: /**
087: * Return the tree node repersetns the start point of this link.
088: *
089: * @return the tree node repersetns the start point of this link.
090: */
091: public IMapperTreeNode getSourceTreeAddress() {
092: return (IMapperTreeNode) this .getMapperLink().getStartNode();
093: }
094:
095: /**
096: * Set the canvas contains this canvas node.
097: *
098: * @param canvas the canvas contains this canvas node.
099: */
100: public void setMapperCanvas(ICanvasView canvas) {
101: super .setMapperCanvas(canvas);
102: mCanvasNode = canvas
103: .findCanvasFieldNode((IFieldNode) getMapperLink()
104: .getEndNode());
105:
106: if (mCanvasNode != null) {
107: endPort = (JGoPort) mCanvasNode.getConnectPointObject();
108: this .setToPort(endPort);
109: }
110:
111: if (canvas instanceof BasicCanvasView) {
112: startPort.setLeft(((BasicCanvasView) canvas)
113: .getTreeLinkFromPortX());
114:
115: IMapperLink link = getMapperLink();
116: startPort.setTop(link.getStartNode().getY()
117: + NodeYChangeListener.Y_AXIS_DIFF
118: + ((JGoView) canvas).getViewPosition().y);
119: mYListener = new NodeYChangeListener((JGoView) canvas,
120: startPort);
121: link.getStartNode().addPropertyChangeListener(mYListener);
122: }
123:
124: if (getMapperCanvas().isPathHighlightingEnabled()) {
125: boolean isHighlighting = new NetworkHighlightDetector(this )
126: .isHighlightDetected();
127: new NetworkHighlightTraverser(isHighlighting).visit(this);
128: }
129: }
130: }
|