Java 类org.eclipse.draw2d.ConnectionAnchor 实例源码

项目:seg.jUCMNav    文件:AndForkJoinEditPart.java   
/**
 * 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());
    }

}
项目:Hydrograph    文件:NodeConnectionEditPolicy.java   
@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;

}
项目:Hydrograph    文件:NodeConnectionEditPolicy.java   
@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;
}
项目:Hydrograph    文件:NodeConnectionEditPolicy.java   
@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;
}
项目:Hydrograph    文件:NodeConnectionEditPolicy.java   
@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;
}
项目:subclipse    文件:GraphEditPart.java   
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;
}
项目:ermasterr    文件:NodeElementEditPart.java   
/**
 * {@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;
}
项目:ermasterr    文件:NodeElementEditPart.java   
/**
 * {@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;
}
项目:ermaster-k    文件:NodeElementEditPart.java   
/**
 * {@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;
}
项目:ermaster-k    文件:NodeElementEditPart.java   
/**
 * {@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;
}
项目:NEXCORE-UML-Modeler    文件:LifeLineBehaviorEditPart.java   
/**
 * @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);
    }
}
项目:NEXCORE-UML-Modeler    文件:LifeLineBehaviorEditPart.java   
/**
 * @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);
    }
}
项目:erflute    文件:TableViewEditPart.java   
@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;
}
项目:erflute    文件:TableViewEditPart.java   
@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;
}
项目:OpenSPIFe    文件:TemporalNodeEditPart.java   
@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;
}
项目:ermaster-nhit    文件:NodeElementEditPart.java   
/**
 * {@inheritDoc}
 */
public ConnectionAnchor getSourceConnectionAnchor(
        ConnectionEditPart editPart) {
    // if (!(editPart instanceof RelationEditPart)) {
    // return super.getSourceConnectionAnchor(editPart);
    // }

    ConnectionElement connection = (ConnectionElement) editPart.getModel();

    Rectangle bounds = this.getFigure().getBounds();

    XYChopboxAnchor anchor = new XYChopboxAnchor(this.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;
}
项目:ermaster-nhit    文件:NodeElementEditPart.java   
/**
 * {@inheritDoc}
 */
public ConnectionAnchor getTargetConnectionAnchor(
        ConnectionEditPart editPart) {
    // if (!(editPart instanceof RelationEditPart)) {
    // return new ChopboxAnchor(this.getFigure());
    // }

    ConnectionElement connection = (ConnectionElement) editPart.getModel();

    XYChopboxAnchor anchor = new XYChopboxAnchor(this.getFigure());

    Rectangle bounds = this.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;
}
项目:jive    文件:LifelineEditPart.java   
@Override
public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection)
{
  // source for a found message
  if (connection instanceof InitiatorMessageEditPart)
  {
    return new ChopboxAnchor(getFigure())
      {
        @Override
        public Point getLocation(final Point reference)
        {
          final Rectangle bounds = Rectangle.SINGLETON;
          bounds.setBounds(getBox());
          getOwner().translateToAbsolute(bounds);
          final Point result = bounds.getTopLeft();
          result.y = reference.y;
          return result;
        }
      };
  }
  throw new IllegalArgumentException("Unsupported connection:  " + connection);
}
项目:jive    文件:LifelineEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection)
{
  // target for a lost message
  if (connection instanceof TerminatorMessageEditPart)
  {
    return new ChopboxAnchor(getFigure())
      {
        @Override
        public Point getLocation(final Point reference)
        {
          final Rectangle bounds = Rectangle.SINGLETON;
          bounds.setBounds(getBox());
          getOwner().translateToAbsolute(bounds);
          final Point result = bounds.getBottomLeft(); // bounds.getTopRight();
          result.y = reference.y;
          return result;
        }
      };
  }
  throw new IllegalArgumentException("Unsupported connection:  " + connection);
}
项目:jive    文件:ExecutionOccurrenceEditPart.java   
@Override
public ConnectionAnchor getSourceConnectionAnchor(final ConnectionEditPart connection)
{
  final Message message = (Message) connection.getModel();
  // this execution can be the source for multiple initiators
  if (connection instanceof InitiatorMessageEditPart)
  {
    return new MethodCallSourceConnectionAnchor();
  }
  // this execution can be the source for at most one terminator
  else if (connection instanceof TerminatorMessageEditPart)
  {
    if (message.kind() == MessageKind.MK_LOST_BROKEN)
    {
      return new MethodBrokenReturnConnectionAnchor(message);
    }
    return new MethodReturnSourceConnectionAnchor();
  }
  throw new IllegalArgumentException("Unsupported connection:  " + connection);
}
项目:jive    文件:ExecutionOccurrenceEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(final ConnectionEditPart connection)
{
  final Message message = (Message) connection.getModel();
  // this execution can be the target for one initiator
  if (connection instanceof InitiatorMessageEditPart)
  {
    if (message.kind() == MessageKind.MK_FOUND_BROKEN)
    {
      return new MethodBrokenCallTargetConnectionAnchor(message);
    }
    return new MethodCallTargetConnectionAnchor();
  }
  // this execution can be the target for multiple terminators
  else if (connection instanceof TerminatorMessageEditPart)
  {
    return new MethodReturnTargetConnectionAnchor();
  }
  throw new IllegalArgumentException("Unsupported connection:  " + connection);
}
项目:Hydrograph    文件:ComponentFigure.java   
/**
 * Gets the connection anchor name.
 * 
 * @param connectionAnchor
 *            the connectionAnchor
 * @return the connection anchor name
 */
public String getConnectionAnchorName(ConnectionAnchor connectionAnchor) {

    Set<String> keys = connectionAnchors.keySet();
    String key;
    Iterator<String> it = keys.iterator();

    while (it.hasNext()) {
        key = it.next();
        if (connectionAnchors.get(key).equals(connectionAnchor))
            return key;
    }
    return null;
}
项目:Hydrograph    文件:ComponentFigure.java   
private ConnectionAnchor closestAnchor(Point p, List<FixedConnectionAnchor> connectionAnchors) {
    ConnectionAnchor closest = null;
    double min = Double.MAX_VALUE;
    for (ConnectionAnchor c : connectionAnchors) {
        double d = p.getDistance(c.getLocation(null));
        if (d < min) {
            min = d;
            closest = c;
        }
    }
    return closest;
}
项目:Hydrograph    文件:ComponentEditPart.java   
@Override
public ConnectionAnchor getSourceConnectionAnchor(
        ConnectionEditPart connection) {

    Link wire = (Link) connection.getModel();
    return getComponentFigure().getConnectionAnchor(
            wire.getSourceTerminal());
}
项目:Hydrograph    文件:ComponentEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(
        ConnectionEditPart connection) {

    Link wire = (Link) connection.getModel();
    return getComponentFigure().getConnectionAnchor(
            wire.getTargetTerminal());
}
项目:bdf2    文件:TableEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
    if (request instanceof CreateConnectionRequest) {
        CreateConnectionRequest crequest = (CreateConnectionRequest) request;
        Table table = (Table) crequest.getSourceEditPart().getModel();
        Column c = table.getFirstPkColumn();
        if (c == null) {
            MessageDialog.openWarning(Display.getCurrent().getActiveShell(), "提示", "此表没有主键,请先设置主键!");
            crequest.setStartCommand(null);
        }
    }
    return new ChopboxAnchor(getFigure());
}
项目:pandionj    文件:ObjectContainer.java   
public void addObjectAndPointer(IReferenceModel ref, ConnectionAnchor sourceAnchor) {
    IEntityModel target = ref.getModelTarget();
    PandionJFigure<?> targetFig = null;
    ConnectionAnchor targetAnchor = null;
    if(!target.isNull()) {
        targetFig = addObject(target, ref.getIndex());
        targetAnchor = targetFig.getIncommingAnchor();
    }
    RuntimeViewer.getInstance().addPointer(ref, sourceAnchor, targetAnchor, this, this);
    updateIllustration(ref, null);
}
项目:pandionj    文件:RuntimeViewer.java   
public void addPointer(IReferenceModel ref, ConnectionAnchor sourceAnchor, ConnectionAnchor targetAnchor, ObjectContainer container, Object owner) {
    assert ref != null;
    IEntityModel target = ref.getModelTarget();
    PolylineConnection pointer = new PolylineConnection();
    pointer.setVisible(!target.isNull());
    pointer.setSourceAnchor(sourceAnchor);
    pointer.setTargetAnchor(target.isNull() ? sourceAnchor : targetAnchor);
    Utils.addArrowDecoration(pointer);
    addPointerObserver(ref, pointer, container);
    addPointer(ref, pointer, owner);
}
项目:DarwinSPL    文件:DwParentChildConnectionEditPart.java   
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
    if(!figure.isVisible()){
        return null;
    }

    return ((DwParentChildConnectionFigure)getFigure()).getAnchor();
}
项目:DarwinSPL    文件:DwParentChildConnectionEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
    if(!figure.isVisible()){
        return null;
    }

    return ((DwParentChildConnectionFigure)getFigure()).getAnchor();
}
项目:DarwinSPL    文件:DwParentChildConnectionEditPart.java   
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
    if(!figure.isVisible()){
        return null;
    }

    return ((DwParentChildConnectionFigure)getFigure()).getAnchor();
}
项目:DarwinSPL    文件:DwParentChildConnectionEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
    if(!figure.isVisible()){
        return null;
    }

    return ((DwParentChildConnectionFigure)getFigure()).getAnchor();
}
项目:NEXCORE-UML-Modeler    文件:DiagramGraphicalNodeEditPolicy.java   
/**
 * @see org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy#getConnectionCreateCommand(org.eclipse.gef.requests.CreateConnectionRequest)
 */
@Override
protected Command getConnectionCreateCommand(CreateConnectionRequest request) {

    CreateConnectionCommand command = new CreateConnectionCommand();
    AbstractConnection connection = (AbstractConnection) request.getNewObject();

    AbstractView objNode = (AbstractNode) (getHost().getModel());

    if (objNode instanceof AbstractConnection) {
        return null;
    }
    AbstractNode abstractNode = (AbstractNode) objNode;

    if (!UMLPolicyManager.isConnectableFromSource(connection.getRelationType(), abstractNode.getNodeType())) {
        return null;
    }

    ConnectionAnchor sourceAnchor = ((NodeEditPart) getHost()).getSourceConnectionAnchor(request);
    command.setSourceAnchorPoint(sourceAnchor.getLocation(request.getLocation()));

    command.setConnection(connection);
    command.setSource((AbstractNode) getHost().getModel());
    request.setStartCommand(command);
    request.setSourceEditPart(getHost());

    return command;

}
项目:txtUML    文件:DiagramElementsModifierTest.java   
/**
 * Test for setConnectionAnchors
 */
@Test
public void setConnectionAnchorsTest() {
    Pair<String, Class<?>> A = new Pair<String, Class<?>>("ClassA",
            org.eclipse.uml2.uml.Class.class);
    Pair<String, Class<?>> B = new Pair<String, Class<?>>("ClassB",
            org.eclipse.uml2.uml.Class.class);

    List<Pair<String, Class<?>>> objects = Arrays.asList(A, B);
    List<Pair<Pair<String, Class<?>>, Pair<String, Class<?>>>> associations = Arrays
            .asList(new Pair<Pair<String, Class<?>>, Pair<String, Class<?>>>(
                    A, B));

    init(objects, associations);
    @SuppressWarnings("unchecked")
    List<EditPart> eps = getDiagramEditPart().getChildren();
    ClassEditPart classAEp = (ClassEditPart) eps.get(0);
    ClassEditPart classBEp = (ClassEditPart) eps.get(1);

    @SuppressWarnings("unchecked")
    List<ConnectionEditPart> conns = classBEp.getSourceConnections();
    ConnectionEditPart assoc = conns.get(0);
    DiagramElementsModifier.setConnectionAnchors(assoc, "(1, 0.5)",
            "(0, 0.5)");

    ConnectionAnchor source = classAEp.getSourceConnectionAnchor(assoc);
    ConnectionAnchor target = classBEp.getTargetConnectionAnchor(assoc);
    Point sourceReferencePoint = ((SlidableAnchor) source)
            .getReferencePoint();
    Point targetReferencePoint = ((SlidableAnchor) target)
            .getReferencePoint();
    PrecisionPoint sourceAnchor = SlidableAnchor.getAnchorRelativeLocation(
            sourceReferencePoint, source.getOwner().getBounds());
    PrecisionPoint targetAnchor = SlidableAnchor.getAnchorRelativeLocation(
            targetReferencePoint, target.getOwner().getBounds());

    Assert.assertEquals(new PrecisionPoint(1, 0.5), sourceAnchor);
    Assert.assertEquals(new PrecisionPoint(0, 0.5), targetAnchor);
}
项目:OpenSPIFe    文件:TemporalNodeEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
    Object model = connection.getModel();
    if (model instanceof BinaryTemporalConstraint) {
        BinaryTemporalConstraint r = (BinaryTemporalConstraint) model;
        return new TimepointConnectionAnchor(r.getPointB().getEndpoint(), getFigure());
    } else
    if (model instanceof TemporalChainLink) {
        return new TimepointConnectionAnchor(Timepoint.START, getFigure());
    }
    return null;
}
项目:OpenSPIFe    文件:TemporalBoundEditPart.java   
@Override
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
    if (connection.getModel() instanceof TemporalBoundLink) {
        return new ChopboxAnchor(getFigure());
    }
    return null;
}
项目:gef-gwt    文件:AbstractConnectionEditPart.java   
/**
 * Returns the <code>ConnectionAnchor</code> for the <i>source</i> end of
 * the connection. If the source is an instance of {@link NodeEditPart},
 * that interface will be used to determine the proper ConnectionAnchor. If
 * the source is not an instance of <code>NodeEditPart</code>, this method
 * should be overridden to return the correct ConnectionAnchor. Failure to
 * do this will cause a default anchor to be used so that the connection
 * figure will be made visible to the developer.
 * 
 * @return ConnectionAnchor for the source end of the Connection
 */
protected ConnectionAnchor getSourceConnectionAnchor() {
    if (getSource() != null) {
        if (getSource() instanceof NodeEditPart) {
            NodeEditPart editPart = (NodeEditPart) getSource();
            return editPart.getSourceConnectionAnchor(this);
        }
        IFigure f = ((GraphicalEditPart) getSource()).getFigure();
        return new ChopboxAnchor(f);
    }
    return DEFAULT_SOURCE_ANCHOR;
}
项目:gef-gwt    文件:AbstractConnectionEditPart.java   
/**
 * Returns the <code>ConnectionAnchor</code> for the <i>target</i> end of
 * the connection. If the target is an instance of {@link NodeEditPart},
 * that interface will be used to determine the proper ConnectionAnchor. If
 * the target is not an instance of <code>NodeEditPart</code>, this method
 * should be overridden to return the correct ConnectionAnchor. Failure to
 * do this will cause a default anchor to be used so that the connection
 * figure will be made visible to the developer.
 * 
 * @return ConnectionAnchor for the target end of the Connection
 */
protected ConnectionAnchor getTargetConnectionAnchor() {
    if (getTarget() != null) {
        if (getTarget() instanceof NodeEditPart) {
            NodeEditPart editPart = (NodeEditPart) getTarget();
            return editPart.getTargetConnectionAnchor(this);
        }
        IFigure f = ((GraphicalEditPart) getTarget()).getFigure();
        return new ChopboxAnchor(f);
    }
    return DEFAULT_TARGET_ANCHOR;
}
项目:gef-gwt    文件:FeedbackHelper.java   
/**
 * Sets the anchor for the end being moved.
 * 
 * @param anchor
 *            the new anchor
 */
protected void setAnchor(ConnectionAnchor anchor) {
    if (isMovingStartAnchor())
        getConnection().setSourceAnchor(anchor);
    else
        getConnection().setTargetAnchor(anchor);
}
项目:FRaMED    文件:ORMRelationEditPart.java   
/** {@inheritDoc} */
@Override
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
  Shape shape = ((Relation) getModel()).getConnectionAnchor();
  if (shape != null) {
    return getConnectionAnchorFromChildShape(shape);
  }
  return null;
}