Java Reference
In-Depth Information
sourceAnchor =
new
SourceFixedConnectionAnchor(getNodeFigure());
}
return
sourceAnchor;
}
public class
SourceFixedConnectionAnchor
extends
AbstractConnectionAnchor {
public
SourceFixedConnectionAnchor(IFigure owner) {
super
(owner);
}
public
Point getLocation(Point reference) {
Point right = getOwner().getBounds().getRight();
Point p =
new
PrecisionPoint(right.x + 1, right.y - 1);
getOwner().translateToAbsolute(p);
return
p;
}
}
The overridden
getLocation()
method provides the main functionality. To
install on our
EditPart
, we override
getSourceConnectionAnchor()
, and in
our
Topic2EditPart
, we override
getSourceConnectionAnchor()
as well.
private
ConnectionAnchor targetAnchor;
private
ConnectionAnchor sourceAnchor;
@Override
public
ConnectionAnchor getTargetConnectionAnchor(
ConnectionEditPart connEditPart) {
if
(targetAnchor ==
null
) {
targetAnchor =
new
TargetFixedConnectionAnchor(getNodeFigure());
}
return
targetAnchor;
}
@Override
public
ConnectionAnchor getSourceConnectionAnchor(
ConnectionEditPart connEditPart) {
if
(sourceAnchor ==
null
) {
sourceAnchor =
new
SourceFixedConnectionAnchor(getNodeFigure());
}
return
sourceAnchor;
}
public class
SourceFixedConnectionAnchor
extends
AbstractConnectionAnchor {
public
SourceFixedConnectionAnchor(IFigure owner) {
super
(owner);
}
Search WWH ::
Custom Search