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.common.gtk;
021:
022: import com.nwoods.jgo.JGoPort;
023:
024: /**
025: * ICanvasLink connects two ports. If the position of one or both of
026: * its ports changes, the ICanvasLink redraws itself to connect the
027: * new positions.
028: * <p>
029: * The default link stroke will consist of three segments. The
030: * end segments, at the ports, will be relatively short and either
031: * horizontal or vertical. The middle segment will be just a straight
032: * line connecting the two short segments at the ports. There is
033: * no short end segment if the corresponding port does not have a
034: * link port spot (i.e., the value is NoSpot).
035: * <p>
036: * By turning on the Orthogonal property, a link will have segments
037: * that are all either horizontal or vertical. To handle what would
038: * normally be "Z" shaped links, there are five segments (i.e. six
039: * stroke points).
040: * <p>
041: * A selected link will not have selection handles at the very
042: * end points, unless there are only one or two segments in the stroke.
043: * Resizing a link causes a new link to be started, keeping one
044: * of the ports for the new link.
045: * <p>
046: * You can define your own style of link by overriding calculateStroke()
047: * or by overriding paint().
048: * <p>
049: * The resize behavior for the user's "relinking" an existing link
050: * to a different port sets the link's corresponding port to null
051: * and calls the Canvas.startReLink method.
052: * <p>
053: * Three properties have been added: Relinkable, AvoidsNodes, and JumpsOver.
054: * <p>
055: * A Relinkable link (by default true) allows the user to interactively
056: * reconnect one end of the link to another valid port (or to the original
057: * port; or to nothing, thereby deleting the link).
058: * <p>
059: * A link that AvoidsNodes has a smarter implementation of calculateStroke()
060: * that routes the path of the link so as to try not to cross any avoidable
061: * objects. Of course, if either end of the link is inside an object,
062: * or if there is no non-area-crossing path that be found, the path
063: * of the link may default to the standard calculateStroke behavior.
064: * You can customize the objects to be avoided by overriding
065: * ICanvasModel.isAvoidable and ICanvasModel.getAvoidableRectangle
066: * -- by default ICanvasModel.isAvoidable is true for instances of JGoArea,
067: * and the size and position of the object to be avoided is just the
068: * bounding rectangle of the area.
069: * This property, by default false, only applies when isOrthogonal()
070: * is true and isCubic() is false.
071: * Setting this property to true will incur some additional overhead to
072: * search for the shortest, straightest path between the ports.
073: * You may wish to set JGoView.setDragsRealtime(false) in order to
074: * improve responsiveness while dragging.
075: * <p>
076: * A link that JumpsOver is drawn with small half-ellipses where the
077: * path of the segment crosses over another link whose isJumpsOver()
078: * property is true.
079: * Both the link that crosses over and the link that is crossed over
080: * must have the Orthogonal property true, the Cubic property false,
081: * and the JumpsOver property true. The crossed over link must
082: * be "behind" the crossing link. This property is false by default.
083: * Setting this property to true will incur some additional overhead to
084: * detect segment intersections.
085: * You may wish to set ICanvas.setDragsRealtime(false) in order to
086: * improve responsiveness while dragging.
087: * This property may also be ignored when the view's scale is small.
088: * <P>
089: * @author Charles Zhu
090: * @created December 3, 2002
091: */
092:
093: public interface ICanvasLink {
094: /**
095: * Retrieves the source node
096: *
097: * @return - source
098: */
099: ICanvasNode getSourceNode();
100:
101: /**
102: * Retrieves the destination node
103: *
104: * @return ICanvasNode
105: */
106: ICanvasNode getDestinationNode();
107:
108: /**
109: * Updates the label text
110: *
111: * @param name - the name
112: */
113: void updateLabelText(String name);
114:
115: /**
116: * sets the label text
117: *
118: * @param label - the canvas link label
119: */
120: void setLabel(ICanvasLinkLabel label);
121:
122: /**
123: * gets the linklabel
124: *
125: * @return The label value
126: */
127: ICanvasLinkLabel getLabel();
128:
129: /**
130: * Sets the labelVisible attribute of the ICanvasLink object
131: *
132: * @param val The new labelVisible value
133: */
134: void setLabelVisible(boolean val);
135:
136: /**
137: * Sets the data object
138: * @param dataobject The data object
139: */
140: void setDataObject(Object dataObject);
141:
142: /**
143: * Gets the data object
144: * @return dataobject
145: */
146: Object getDataObject();
147:
148: /**
149: * start highlighting this link
150: */
151: void startHighlighting();
152:
153: /**
154: * stop highlighting this link
155: */
156: void stopHighlighting();
157:
158: /**
159: * get start port
160: * @return
161: */
162: JGoPort getStartPort();
163:
164: /**
165: * get end port
166: * @return
167: */
168: JGoPort getEndPort();
169: }
|