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.ICanvasNodeToTreeLink;
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> BasicCanvasNodeToTreeLink <p>
036: *
037: * Description: </p> BasicCanvasNodeToTreeLink provides basic implementation of
038: * ICanvasNodeToTreeLink <p>
039: *
040: * @author Un Seng Leong
041: * @created January 2, 2003
042: */
043: public class BasicCanvasNodeToTreeLink extends AbstractCanvasLink
044: implements ICanvasNodeToTreeLink {
045:
046: /**
047: * the start canvas node.
048: */
049: private ICanvasFieldNode mCanvasNode;
050:
051: /**
052: * Creates a new BasicCanvasNodeToTreeLink object.
053: *
054: * @param link the mapper link
055: */
056: public BasicCanvasNodeToTreeLink(IMapperLink link) {
057: super (link);
058: this .setArrowHeads(false, false);
059: initializeArrowHeads(this );
060: endPort = new BasicCanvasPort();
061: endPort.setDraggable(false);
062: endPort.setSelectable(false);
063: endPort.setStyle(JGoPort.StyleHidden);
064: this .setToPort(endPort);
065: }
066:
067: /**
068: * Return the tree node repersetns the end point of this link.
069: *
070: * @return the tree node repersetns the end point of this link.
071: */
072: public IMapperTreeNode getDestTreeAddress() {
073: return (IMapperTreeNode) this .getMapperLink().getEndNode();
074: }
075:
076: /**
077: * Return the canvas field node repersetns the start point of this link.
078: *
079: * @return the canvas field node repersetns the start point of this link.
080: */
081: public ICanvasFieldNode getSourceFieldNode() {
082: return mCanvasNode;
083: }
084:
085: /**
086: * Set the canvas contains this canvas node.
087: *
088: * @param canvas the canvas contains this canvas node.
089: */
090: public void setMapperCanvas(ICanvasView canvas) {
091: super .setMapperCanvas(canvas);
092: mCanvasNode = canvas
093: .findCanvasFieldNode((IFieldNode) getMapperLink()
094: .getStartNode());
095:
096: if (mCanvasNode != null) {
097: startPort = (JGoPort) mCanvasNode.getConnectPointObject();
098: this .setFromPort(startPort);
099: }
100:
101: if (canvas instanceof BasicCanvasView) {
102: endPort.setLeft(((BasicCanvasView) canvas)
103: .getTreeLinkToPortX());
104:
105: IMapperLink link = getMapperLink();
106: endPort.setTop(link.getEndNode().getY()
107: + NodeYChangeListener.Y_AXIS_DIFF
108: + ((JGoView) canvas).getViewPosition().y);
109: link.getEndNode().addPropertyChangeListener(
110: new NodeYChangeListener((JGoView) canvas, endPort));
111: }
112:
113: if (getMapperCanvas().isPathHighlightingEnabled()) {
114: boolean isHighlighting = new NetworkHighlightDetector(this )
115: .isHighlightDetected();
116: new NetworkHighlightTraverser(isHighlighting).visit(this);
117: }
118: }
119: }
|