本文整理汇总了Java中org.eclipse.draw2d.ConnectionAnchor类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionAnchor类的具体用法?Java ConnectionAnchor怎么用?Java ConnectionAnchor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionAnchor类属于org.eclipse.draw2d包,在下文中一共展示了ConnectionAnchor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: anchorMoved
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* Refreshes all outgoing or incoming connections if the super classes's anchors are moved.
*/
public void anchorMoved(ConnectionAnchor anchor) {
ConnectionLayer cLayer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
// jk (later): I'm not sure why we are refreshing all the connections; might want to try to reduce the scope.
if (cLayer.getConnectionRouter() instanceof UCMConnectionRouter)
((UCMConnectionRouter) cLayer.getConnectionRouter()).refreshConnections();
List toRefresh;
// and forks have their outputs rearranged; therefore the connection's source are rearranged.
if (getModel() instanceof AndFork)
toRefresh = getModelSourceConnections();
else
toRefresh = getModelTargetConnections();
// when one anchor is moved, we must inform the others as we are using mutually exclusive locations.
for (Iterator iter = toRefresh.iterator(); iter.hasNext();) {
NodeConnection element = (NodeConnection) iter.next();
AndForkJoinConnectionAnchor anch = (getAnchor(element));
if (anch != anchor)
anch.ancestorMoved(getFigure());
}
}
示例2: getConnectionCreateCommand
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
protected Command getConnectionCreateCommand(
CreateConnectionRequest request) {
LinkCommand command = new LinkCommand();
command.setConnection(new Link());
command.setSource(getComponentEditPart().getCastedModel());
ConnectionAnchor ctor = getComponentEditPart().getSourceConnectionAnchor(
request);
if (ctor == null)
return null;
command.setSourceTerminal(getComponentEditPart()
.mapConnectionAnchorToTerminal(ctor));
request.setStartCommand(command);
return command;
}
示例3: getConnectionCompleteCommand
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
protected Command getConnectionCompleteCommand(
CreateConnectionRequest request) {
LinkCommand command = (LinkCommand) request
.getStartCommand();
command.setTarget(getComponentEditPart().getCastedModel());
ConnectionAnchor ctor = getComponentEditPart().getTargetConnectionAnchor(
request);
if (ctor == null)
return null;
command.setTargetTerminal(getComponentEditPart()
.mapConnectionAnchorToTerminal(ctor));
return command;
}
示例4: getReconnectSourceCommand
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
protected Command getReconnectSourceCommand(
ReconnectRequest request) {
Link link=(Link)request.getConnectionEditPart().getModel();
Component comp=getComponentEditPart().getCastedModel();
LinkReconnectSourceCommand cmd=new LinkReconnectSourceCommand(link);
cmd.setOldSource(link);
cmd.setNewSource(comp);
ConnectionAnchor anchor=getComponentEditPart().getSourceConnectionAnchor(request);
if(anchor==null){
return null;
}
cmd.setNewSourceTerminal(getComponentEditPart().mapConnectionAnchorToTerminal(anchor));
return cmd;
}
示例5: getReconnectTargetCommand
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
protected Command getReconnectTargetCommand(
ReconnectRequest request) {
Link link=(Link)request.getConnectionEditPart().getModel();
Component component=getComponentEditPart().getCastedModel();
ConnectionAnchor anchor=getComponentEditPart().getTargetConnectionAnchor(request);
if(anchor==null){
return null;
}
LinkReconnectTargetCommand command=new LinkReconnectTargetCommand(link);
command.setOldTarget(link);
command.setNewTarget(component);
command.setNewTargetTerminal(getComponentEditPart().mapConnectionAnchorToTerminal(anchor));
return command;
}
示例6: makeConnection
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
private PolylineConnection makeConnection(IFigure contents, IFigure source, NodeFigure target, Color color) {
PolylineConnection c = new PolylineConnection();
ConnectionAnchor targetAnchor = new ChopboxAnchor(target);
c.setTargetAnchor(targetAnchor);
c.setSourceAnchor(new ChopboxAnchor(source));
PolygonDecoration decoration = new PolygonDecoration();
decoration.setTemplate(PolygonDecoration.TRIANGLE_TIP);
c.setTargetDecoration(decoration);
c.setForegroundColor(color);
ConnectionMouseListener listener = new ConnectionMouseListener(c);
c.addMouseMotionListener(listener);
c.addMouseListener(listener);
c.setCursor(Cursors.HAND);
contents.add(c);
connections.add(c);
return c;
}
示例7: getSourceConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart editPart) {
// if (!(editPart instanceof RelationEditPart)) {
// return super.getSourceConnectionAnchor(editPart);
// }
final ConnectionElement connection = (ConnectionElement) editPart.getModel();
final Rectangle bounds = getFigure().getBounds();
final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
if (connection.getSourceXp() != -1 && connection.getSourceYp() != -1) {
anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getSourceXp() / 100), bounds.y + (bounds.height * connection.getSourceYp() / 100)));
}
return anchor;
}
示例8: getTargetConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart editPart) {
// if (!(editPart instanceof RelationEditPart)) {
// return new ChopboxAnchor(this.getFigure());
// }
final ConnectionElement connection = (ConnectionElement) editPart.getModel();
final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
final Rectangle bounds = getFigure().getBounds();
if (connection.getTargetXp() != -1 && connection.getTargetYp() != -1) {
anchor.setLocation(new Point(bounds.x + (bounds.width * connection.getTargetXp() / 100), bounds.y + (bounds.height * connection.getTargetYp() / 100)));
}
return anchor;
}
示例9: getSourceConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public ConnectionAnchor getSourceConnectionAnchor(
ConnectionEditPart editPart) {
// if (!(editPart instanceof RelationEditPart)) {
// return super.getSourceConnectionAnchor(editPart);
// }
Category currentCategory = getDiagram().getCurrentCategory();
ConnectionElement connection = (ConnectionElement) editPart.getModel();
Rectangle bounds = this.getFigure().getBounds();
XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure());
if (connection.getSourceXp(currentCategory) != -1
&& connection.getSourceYp(currentCategory) != -1) {
anchor.setLocation(new Point(
bounds.x + (bounds.width * connection.getSourceXp(currentCategory) / 100),
bounds.y + (bounds.height * connection.getSourceYp(currentCategory) / 100)));
}
return anchor;
}
示例10: getTargetConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public ConnectionAnchor getTargetConnectionAnchor(
ConnectionEditPart editPart) {
// if (!(editPart instanceof RelationEditPart)) {
// return new ChopboxAnchor(this.getFigure());
// }
Category currentCategory = getDiagram().getCurrentCategory();
ConnectionElement connection = (ConnectionElement) editPart.getModel();
XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure());
Rectangle bounds = this.getFigure().getBounds();
if (connection.getTargetXp(currentCategory) != -1 && connection.getTargetYp(currentCategory) != -1) {
anchor.setLocation(new Point(
bounds.x + (bounds.width * connection.getTargetXp(currentCategory) / 100),
bounds.y + (bounds.height * connection.getTargetYp(currentCategory) / 100)));
}
return anchor;
}
示例11: getSourceConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*/
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
if (connection instanceof AttachementEditPart) {
return new ChopboxAnchor(getFigure());
}
if (connection.getTarget() != null && connection.getSource() != null) {
LifeLineNode sourceNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getSource().getModel());
LifeLineNode targetNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getTarget().getModel());
if (sourceNode.equals(targetNode)) {
Point point = new Point(sourceNode.getX() + sourceNode.getWidth() / 2,
((AbstractView) connection.getModel()).getY());
connection.getFigure().translateToAbsolute(point);
return new XYAnchor(point);
} else {
return new MessageOutgoingConnectionAnchor(getFigure(), connection);
}
} else {
return new MessageOutgoingConnectionAnchor(getFigure(), connection);
}
}
示例12: getTargetConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
/**
* @see nexcore.tool.uml.ui.core.diagram.edit.part.AbstractNotationNodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*/
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
if (connection instanceof AttachementEditPart) {
return new ChopboxAnchor(getFigure());
}
if (connection.getTarget() != null && connection.getSource() != null) {
LifeLineNode sourceNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getSource().getModel());
LifeLineNode targetNode = SequenceUtil.getLifeLineNode((AbstractNode) connection.getTarget().getModel());
if (sourceNode.equals(targetNode)) {
Point point = new Point(targetNode.getX() + targetNode.getWidth() / 2,
((AbstractView) connection.getModel()).getY() + 10);
connection.getFigure().translateToAbsolute(point);
return new XYAnchor(point);
} else {
return new MessageIncommingConnectionAnchor(getFigure(), connection);
}
} else {
return new MessageIncommingConnectionAnchor(getFigure(), connection);
}
}
示例13: getSourceConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart editPart) {
if (!(editPart instanceof RelationEditPart)) {
return super.getSourceConnectionAnchor(editPart);
}
final Relationship relation = (Relationship) editPart.getModel();
final Rectangle bounds = getFigure().getBounds();
final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
if (relation.getSourceXp() != -1 && relation.getSourceYp() != -1) {
anchor.setLocation(new Point(bounds.x + (bounds.width * relation.getSourceXp() / 100),
bounds.y + (bounds.height * relation.getSourceYp() / 100)));
}
return anchor;
}
示例14: getTargetConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart editPart) {
if (!(editPart instanceof RelationEditPart)) {
return super.getTargetConnectionAnchor(editPart);
}
final Relationship relation = (Relationship) editPart.getModel();
final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
final Rectangle bounds = getFigure().getBounds();
if (relation.getTargetXp() != -1 && relation.getTargetYp() != -1) {
anchor.setLocation(new Point(bounds.x + (bounds.width * relation.getTargetXp() / 100),
bounds.y + (bounds.height * relation.getTargetYp() / 100)));
}
return anchor;
}
示例15: getSourceConnectionAnchor
import org.eclipse.draw2d.ConnectionAnchor; //导入依赖的package包/类
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
Object model = connection.getModel();
if (model instanceof BinaryTemporalConstraint) {
BinaryTemporalConstraint r = (BinaryTemporalConstraint) model;
return new TimepointConnectionAnchor(r.getPointA().getEndpoint(), getFigure());
} else
if (model instanceof TemporalChainLink) {
return new TimepointConnectionAnchor(Timepoint.END, getFigure());
} else
if (model instanceof TemporalBoundLink) {
PeriodicTemporalConstraint b = ((TemporalBoundLink)model).getTarget();
return new TimepointConnectionAnchor(b.getPoint().getEndpoint(), getFigure());
}
return null;
}