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

项目:NEXCORE-UML-Modeler    文件:SequenceBendpointEditPolicy.java   
/**
 * setReferencePoints
 *  
 * @param request void
 */
private void setReferencePoints(BendpointRequest request) {
    PointList points = getConnection().getPoints();
    int bpIndex = -1;
    List bendPoints = (List)getConnection().getRoutingConstraint();
    Point bp = ((Bendpoint)bendPoints.get(request.getIndex())).getLocation();

    int smallestDistance = -1;

    for (int i = 0; i < points.size(); i++) {
        if (smallestDistance == -1
                || points.getPoint(i).getDistance2(bp) < smallestDistance) {
            bpIndex = i;
            smallestDistance = points.getPoint(i).getDistance2(bp);
            if (smallestDistance == 0)
                break;
        }
    }

    points.getPoint(ref1, bpIndex - 1);
    getConnection().translateToAbsolute(ref1);
    points.getPoint(ref2, bpIndex + 1);
    getConnection().translateToAbsolute(ref2);
}
项目:NEXCORE-UML-Modeler    文件:SequenceBendpointEditPolicy.java   
/**
 * Shows feedback when a bendpoint is being created.  The original figure is used for
 * feedback and the original constraint is saved, so that it can be restored when feedback
 * is erased.
 * @param request the BendpointRequest
 */
protected void showCreateBendpointFeedback(BendpointRequest request) {
    Point p = new Point(request.getLocation());
    List constraint;
    getConnection().translateToRelative(p);
    Bendpoint bp = new AbsoluteBendpoint(p);
    if (originalConstraint == null) {
        saveOriginalConstraint();
        constraint = (List)getConnection().getRoutingConstraint();
        constraint.add(request.getIndex(), bp);
    } else {
        constraint = (List)getConnection().getRoutingConstraint();
    }
    constraint.set(request.getIndex(), bp);
    getConnection().setRoutingConstraint(constraint);
}
项目:NEXCORE-UML-Modeler    文件:SequenceBendpointEditPolicy.java   
/**
 * Shows feedback when a bendpoint is being moved.  Also checks to see if the bendpoint 
 * should be deleted and then calls {@link #showDeleteBendpointFeedback(BendpointRequest)}
 * if needed.  The original figure is used for feedback and the original constraint is 
 * saved, so that it can be restored when feedback is erased.
 * @param request the BendpointRequest
 */
protected void showMoveBendpointFeedback(BendpointRequest request) {
    Point p = new Point(request.getLocation());
    if (!isDeleting)
        setReferencePoints(request);

    if (lineContainsPoint(ref1, ref2, p)) {
        if (!isDeleting) {
            isDeleting = true;
            eraseSourceFeedback(request);
            showDeleteBendpointFeedback(request);
        }
        return;
    }
    if (isDeleting) {
        isDeleting = false;
        eraseSourceFeedback(request);
    }
    if (originalConstraint == null)
        saveOriginalConstraint();
    List constraint = (List)getConnection().getRoutingConstraint();
    getConnection().translateToRelative(p);
    Bendpoint bp = new AbsoluteBendpoint(p);
    constraint.set(request.getIndex(), bp);
    getConnection().setRoutingConstraint(constraint);
}
项目:gef-gwt    文件:BendpointEditPolicy.java   
private void setReferencePoints(BendpointRequest request) {
    PointList points = getConnection().getPoints();
    int bpIndex = -1;
    List bendPoints = (List) getConnection().getRoutingConstraint();
    Point bp = ((Bendpoint) bendPoints.get(request.getIndex()))
            .getLocation();

    int smallestDistance = -1;

    for (int i = 0; i < points.size(); i++) {
        if (smallestDistance == -1
                || points.getPoint(i).getDistance2(bp) < smallestDistance) {
            bpIndex = i;
            smallestDistance = points.getPoint(i).getDistance2(bp);
            if (smallestDistance == 0)
                break;
        }
    }

    points.getPoint(ref1, bpIndex - 1);
    getConnection().translateToAbsolute(ref1);
    points.getPoint(ref2, bpIndex + 1);
    getConnection().translateToAbsolute(ref2);
}
项目:gef-gwt    文件:BendpointEditPolicy.java   
/**
 * Shows feedback when a bendpoint is being created. The original figure is
 * used for feedback and the original constraint is saved, so that it can be
 * restored when feedback is erased.
 * 
 * @param request
 *            the BendpointRequest
 */
protected void showCreateBendpointFeedback(BendpointRequest request) {
    Point p = new Point(request.getLocation());
    List constraint;
    getConnection().translateToRelative(p);
    Bendpoint bp = new AbsoluteBendpoint(p);
    if (originalConstraint == null) {
        saveOriginalConstraint();
        constraint = (List) getConnection().getRoutingConstraint();
        constraint.add(request.getIndex(), bp);
    } else {
        constraint = (List) getConnection().getRoutingConstraint();
    }
    constraint.set(request.getIndex(), bp);
    getConnection().setRoutingConstraint(constraint);
}
项目:gef-gwt    文件:BendpointEditPolicy.java   
/**
 * Shows feedback when a bendpoint is being moved. Also checks to see if the
 * bendpoint should be deleted and then calls
 * {@link #showDeleteBendpointFeedback(BendpointRequest)} if needed. The
 * original figure is used for feedback and the original constraint is
 * saved, so that it can be restored when feedback is erased.
 * 
 * @param request
 *            the BendpointRequest
 */
protected void showMoveBendpointFeedback(BendpointRequest request) {
    Point p = new Point(request.getLocation());
    if (!isDeleting)
        setReferencePoints(request);

    if (lineContainsPoint(ref1, ref2, p)) {
        if (!isDeleting) {
            isDeleting = true;
            eraseSourceFeedback(request);
            showDeleteBendpointFeedback(request);
        }
        return;
    }
    if (isDeleting) {
        isDeleting = false;
        eraseSourceFeedback(request);
    }
    if (originalConstraint == null)
        saveOriginalConstraint();
    List constraint = (List) getConnection().getRoutingConstraint();
    getConnection().translateToRelative(p);
    Bendpoint bp = new AbsoluteBendpoint(p);
    constraint.set(request.getIndex(), bp);
    getConnection().setRoutingConstraint(constraint);
}
项目:bdf2    文件:ConnectionEditPart.java   
protected void refreshBendpoints() {
    List<Bendpoint> modelConstraint = ((Connection) getModel()).getBendpoints();
    List<RelativeBendpoint> figureConstraint = new ArrayList<RelativeBendpoint>();
    for (int i = 0; i < modelConstraint.size(); i++) {
        ConnectionBendpoint connectionBendpoint = (ConnectionBendpoint) modelConstraint.get(i);
        RelativeBendpoint rbp = new RelativeBendpoint(getConnectionFigure());
        rbp.setRelativeDimensions(connectionBendpoint.getFirstRelativeDimension(), connectionBendpoint.getSecondRelativeDimension());
        rbp.setWeight((i + 1) / ((float) modelConstraint.size() + 1));
        figureConstraint.add(rbp);
    }
    getConnectionFigure().setRoutingConstraint(figureConstraint);
}
项目:bdf2    文件:ParseSchemaToXml.java   
private void writeBendpoints(Element elementConnection, List<Bendpoint> list) {
    ConnectionBendpoint b = null;
    for (Bendpoint bendpoint : list) {
        b = (ConnectionBendpoint) bendpoint;
        Element element = document.createElement(ConnectionBendpoint.SIMPLE_NAME);
        writeElement(element, ConnectionBendpoint.DX1, b.getFirstRelativeDimension().width);
        writeElement(element, ConnectionBendpoint.DY1, b.getFirstRelativeDimension().height);
        writeElement(element, ConnectionBendpoint.DX2, b.getSecondRelativeDimension().width);
        writeElement(element, ConnectionBendpoint.DY2, b.getSecondRelativeDimension().height);
        elementConnection.appendChild(element);
    }
}
项目:bdf2    文件:MoveBendpointCommand.java   
public void execute() {
    ConnectionBendpoint bp = new ConnectionBendpoint();
    bp.setRelativeDimensions(getFirstRelativeDimension(),
            getSecondRelativeDimension());
    setOldBendpoint((Bendpoint) getConn().getBendpoints().get(getIndex()));
    getConn().setBendpoint(getIndex(), bp);
    super.execute();
}
项目:NEXCORE-UML-Modeler    文件:SequenceBendpointEditPolicy.java   
/**
 * createHandlesForUserBendpoints
 *  
 * @return List
 */
private List createHandlesForUserBendpoints() {
    List list = new ArrayList();
    ConnectionEditPart connEP = (ConnectionEditPart)getHost();
    PointList points = getConnection().getPoints();
    List bendPoints = (List)getConnection().getRoutingConstraint();
    int bendPointIndex = 0;
    Point currBendPoint = null;

    if (bendPoints == null)
        bendPoints = NULL_CONSTRAINT;
    else if (!bendPoints.isEmpty())
        currBendPoint = ((Bendpoint)bendPoints.get(0)).getLocation();

    for (int i = 0; i < points.size() - 1; i++) {
        //Put a create handle on the middle of every segment
        list.add(new SequenceBendpointCreationHandle(connEP, bendPointIndex, i));

        //If the current user bendpoint matches a bend location, show a move handle
        if (i < points.size() - 1
                && bendPointIndex < bendPoints.size()
                && currBendPoint.equals(points.getPoint(i + 1))) {
            list.add(new SequenceBendpointCreationHandle(connEP, bendPointIndex, i + 1));

            //Go to the next user bendpoint
            bendPointIndex++;
            if (bendPointIndex < bendPoints.size())
                currBendPoint = ((Bendpoint)bendPoints.get(bendPointIndex)).getLocation();
        }
    }

    return list;
}
项目:gef-gwt    文件:BendpointEditPolicy.java   
private List createHandlesForUserBendpoints() {
    List list = new ArrayList();
    ConnectionEditPart connEP = (ConnectionEditPart) getHost();
    PointList points = getConnection().getPoints();
    List bendPoints = (List) getConnection().getRoutingConstraint();
    int bendPointIndex = 0;
    Point currBendPoint = null;

    if (bendPoints == null)
        bendPoints = NULL_CONSTRAINT;
    else if (!bendPoints.isEmpty())
        currBendPoint = ((Bendpoint) bendPoints.get(0)).getLocation();

    for (int i = 0; i < points.size() - 1; i++) {
        // Put a create handle on the middle of every segment
        list.add(new BendpointCreationHandle(connEP, bendPointIndex, i));

        // If the current user bendpoint matches a bend location, show a
        // move handle
        if (i < points.size() - 1 && bendPointIndex < bendPoints.size()
                && currBendPoint.equals(points.getPoint(i + 1))) {
            list.add(new BendpointMoveHandle(connEP, bendPointIndex, i + 1));

            // Go to the next user bendpoint
            bendPointIndex++;
            if (bendPointIndex < bendPoints.size())
                currBendPoint = ((Bendpoint) bendPoints.get(bendPointIndex))
                        .getLocation();
        }
    }

    return list;
}
项目:bdf2    文件:Connection.java   
public void insertBendpoint(int index, Bendpoint point) {
    getBendpoints().add(index, point);
    firePropertyChange(BENDPOINT, null, null);
}
项目:bdf2    文件:Connection.java   
public void setBendpoint(int index, Bendpoint point) {
    getBendpoints().set(index, point);
    firePropertyChange(BENDPOINT, null, null);
}
项目:bdf2    文件:Connection.java   
public List<Bendpoint> getBendpoints() {
    return bendpoints;
}
项目:bdf2    文件:Connection.java   
public void setBendpoints(List<Bendpoint> bendpoints) {
    this.bendpoints = bendpoints;
}
项目:bdf2    文件:DeleteBendpointCommand.java   
public void execute() {
    bendpoint = (Bendpoint) getConn().getBendpoints().get(getIndex());
    getConn().removeBendpoint(getIndex());
    super.execute();
}
项目:bdf2    文件:MoveBendpointCommand.java   
protected Bendpoint getOldBendpoint() {
    return oldBendpoint;
}
项目:bdf2    文件:MoveBendpointCommand.java   
public void setOldBendpoint(Bendpoint bp) {
    oldBendpoint = bp;
}