当前位置: 首页>>代码示例>>Java>>正文


Java ReconnectRequest.getLocation方法代码示例

本文整理汇总了Java中org.eclipse.gef.requests.ReconnectRequest.getLocation方法的典型用法代码示例。如果您正苦于以下问题:Java ReconnectRequest.getLocation方法的具体用法?Java ReconnectRequest.getLocation怎么用?Java ReconnectRequest.getLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.gef.requests.ReconnectRequest的用法示例。


在下文中一共展示了ReconnectRequest.getLocation方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getReconnectSourceCommand

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Command getReconnectSourceCommand(final ReconnectRequest reconnectrequest) {
    final ConnectionElement connection = (ConnectionElement) reconnectrequest.getConnectionEditPart().getModel();

    if (connection.getSource() == connection.getTarget()) {
        return null;
    }

    final NodeElement newSource = (NodeElement) reconnectrequest.getTarget().getModel();
    if (connection.getSource() != newSource) {
        return null;
    }

    final NodeElementEditPart sourceEditPart = (NodeElementEditPart) reconnectrequest.getConnectionEditPart().getSource();

    final Point location = new Point(reconnectrequest.getLocation());

    final IFigure sourceFigure = sourceEditPart.getFigure();
    sourceFigure.translateToRelative(location);

    int xp = -1;
    int yp = -1;

    final Rectangle bounds = sourceFigure.getBounds();

    final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

    if (!centerRectangle.contains(location)) {
        final Point point = NodeElementEditPart.getIntersectionPoint(location, sourceFigure);
        xp = 100 * (point.x - bounds.x) / bounds.width;
        yp = 100 * (point.y - bounds.y) / bounds.height;
    }

    final ReconnectSourceCommand command = new ReconnectSourceCommand(connection, xp, yp);

    return command;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:41,代码来源:NodeElementGraphicalNodeEditPolicy.java

示例2: getReconnectTargetCommand

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Command getReconnectTargetCommand(final ReconnectRequest reconnectrequest) {
    final ConnectionElement connection = (ConnectionElement) reconnectrequest.getConnectionEditPart().getModel();

    if (connection.getSource() == connection.getTarget()) {
        return null;
    }

    final NodeElement newTarget = (NodeElement) reconnectrequest.getTarget().getModel();
    if (connection.getTarget() != newTarget) {
        return null;
    }

    final NodeElementEditPart targetEditPart = (NodeElementEditPart) reconnectrequest.getConnectionEditPart().getTarget();

    final Point location = new Point(reconnectrequest.getLocation());

    final IFigure targetFigure = targetEditPart.getFigure();
    targetFigure.translateToRelative(location);

    int xp = -1;
    int yp = -1;

    final Rectangle bounds = targetFigure.getBounds();

    final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

    if (!centerRectangle.contains(location)) {
        final Point point = NodeElementEditPart.getIntersectionPoint(location, targetFigure);

        xp = 100 * (point.x - bounds.x) / bounds.width;
        yp = 100 * (point.y - bounds.y) / bounds.height;
    }
    final ReconnectTargetCommand command = new ReconnectTargetCommand(connection, xp, yp);

    return command;
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:41,代码来源:NodeElementGraphicalNodeEditPolicy.java

示例3: getReconnectSourceCommand

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
@Override
protected Command getReconnectSourceCommand(ReconnectRequest reconnectrequest) {
    final WalkerConnection connection = (WalkerConnection) reconnectrequest.getConnectionEditPart().getModel();
    if (!(connection instanceof Relationship)) {
        return null;
    }
    final Relationship relation = (Relationship) connection;
    if (relation.getSourceWalker() == relation.getTargetWalker()) {
        return null;
    }
    final DiagramWalker newSource = ((DiagramWalker) reconnectrequest.getTarget().getModel()).toMaterialize();
    if (!relation.getSourceWalker().equals(newSource)) {
        return null;
    }
    final DiagramWalkerEditPart sourceEditPart = (DiagramWalkerEditPart) reconnectrequest.getConnectionEditPart().getSource();
    final Point location = new Point(reconnectrequest.getLocation());
    final IFigure sourceFigure = sourceEditPart.getFigure();
    sourceFigure.translateToRelative(location);
    int xp = -1;
    int yp = -1;
    final Rectangle bounds = sourceFigure.getBounds();
    final Rectangle centerRectangle =
            new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
    if (!centerRectangle.contains(location)) {
        final Point point = ERTableEditPart.getIntersectionPoint(location, sourceFigure);
        xp = 100 * (point.x - bounds.x) / bounds.width;
        yp = 100 * (point.y - bounds.y) / bounds.height;
    }
    final ReconnectSourceCommand command = new ReconnectSourceCommand(relation, xp, yp);
    return command;
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:32,代码来源:DiagramWalkerGraphicalNodeEditPolicy.java

示例4: getReconnectTargetCommand

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
@Override
protected Command getReconnectTargetCommand(ReconnectRequest reconnectrequest) {
    final WalkerConnection connection = (WalkerConnection) reconnectrequest.getConnectionEditPart().getModel();
    if (!(connection instanceof Relationship)) {
        return null;
    }
    final Relationship relation = (Relationship) connection;
    if (relation.getSourceWalker() == relation.getTargetWalker()) {
        return null;
    }
    final DiagramWalker newTarget = ((DiagramWalker) reconnectrequest.getTarget().getModel()).toMaterialize();
    if (!relation.getTargetWalker().equals(newTarget)) {
        return null;
    }
    final DiagramWalkerEditPart targetEditPart = (DiagramWalkerEditPart) reconnectrequest.getConnectionEditPart().getTarget();
    final Point location = new Point(reconnectrequest.getLocation());
    final IFigure targetFigure = targetEditPart.getFigure();
    targetFigure.translateToRelative(location);
    int xp = -1;
    int yp = -1;
    final Rectangle bounds = targetFigure.getBounds();
    final Rectangle centerRectangle =
            new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);
    if (!centerRectangle.contains(location)) {
        final Point point = ERTableEditPart.getIntersectionPoint(location, targetFigure);
        xp = 100 * (point.x - bounds.x) / bounds.width;
        yp = 100 * (point.y - bounds.y) / bounds.height;
    }
    final ReconnectTargetCommand command = new ReconnectTargetCommand(relation, xp, yp);
    return command;
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:32,代码来源:DiagramWalkerGraphicalNodeEditPolicy.java

示例5: getSourceConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
    //return new ChopboxAnchor(getFigure());
	if(request instanceof ReconnectRequest) {
		ReconnectRequest r = (ReconnectRequest)request;
		NodeConnectionEditPart con =(NodeConnectionEditPart) r.getConnectionEditPart();
		NodeConnection conModel = (NodeConnection)con.getModel();
		BorderAnchor anchor = con.getSourceAnchor();
		GraphicalEditPart part = (GraphicalEditPart)r.getTarget();
		if(anchor == null || anchor.getOwner() != part.getFigure()) {
		    anchor = new RectangleBorderAnchor(getFigure());
			anchor.setAngle(conModel.getSourceAngle());
			con.setSourceAnchor(anchor);
		}
		
		Point loc = r.getLocation();
		Rectangle rect = Rectangle.SINGLETON;
		rect.setBounds(getFigure().getBounds());
		getFigure().translateToAbsolute(rect);
		Point ref = rect.getCenter();
		double dx = loc.x - ref.x;
		double dy = loc.y - ref.y;
		anchor.setAngle(Math.atan2(dy, dx));
		con.setSourceAnchor(anchor);
		conModel.setSourceAngle(anchor.getAngle());
		return anchor;		
	} else {
			return new RectangleBorderAnchor(getFigure());
	}
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:30,代码来源:BONodeEditPart.java

示例6: getTargetConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
    //return new ChopboxAnchor(getFigure());

    //return new ChopboxAnchor(getFigure());
	if(request instanceof ReconnectRequest) {
		ReconnectRequest r = (ReconnectRequest)request;
		NodeConnectionEditPart con =(NodeConnectionEditPart) r.getConnectionEditPart();
		NodeConnection conModel = (NodeConnection)con.getModel();
		BorderAnchor anchor = con.getTargetAnchor();
		GraphicalEditPart part = (GraphicalEditPart)r.getTarget();
		if(anchor == null || anchor.getOwner() != part.getFigure()) {
		    anchor = new RectangleBorderAnchor(getFigure());
			anchor.setAngle(conModel.getTargetAngle());
			con.setTargetAnchor(anchor);
		}
		
		Point loc = r.getLocation();
		Rectangle rect = Rectangle.SINGLETON;
		rect.setBounds(getFigure().getBounds());
		getFigure().translateToAbsolute(rect);
		Point ref = rect.getCenter();
		double dx = loc.x - ref.x;
		double dy = loc.y - ref.y;
		anchor.setAngle(Math.atan2(dy, dx));
		con.setTargetAnchor(anchor);
		conModel.setTargetAngle(anchor.getAngle());
		return anchor;		
	} else {
			return new RectangleBorderAnchor(getFigure());
	}

}
 
开发者ID:winture,项目名称:wt-studio,代码行数:33,代码来源:BONodeEditPart.java

示例7: getSourceConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
	if(request instanceof ReconnectRequest) {
		ReconnectRequest r = (ReconnectRequest)request;
		ColumnConnectionEditPart con =(ColumnConnectionEditPart) r.getConnectionEditPart();
		ColumnConnection conModel = (ColumnConnection)con.getModel();
		BorderAnchor anchor = con.getSourceAnchor();
		GraphicalEditPart part = (GraphicalEditPart)r.getTarget();
		if(anchor == null || anchor.getOwner() != part.getFigure()) {
		    anchor = new RectangleBorderAnchor(getFigure());
			anchor.setAngle(conModel.getSourceAngle());
			con.setSourceAnchor(anchor);
		}
		
		Point loc = r.getLocation();
		Rectangle rect = Rectangle.SINGLETON;
		rect.setBounds(getFigure().getBounds());
		getFigure().translateToAbsolute(rect);
		Point ref = rect.getCenter();
		double dx = loc.x - ref.x;
		double dy = loc.y - ref.y;
		anchor.setAngle(Math.atan2(dy, dx));
		con.setSourceAnchor(anchor);
		conModel.setSourceAngle(anchor.getAngle());
		return anchor;		
	} else {
			return new RectangleBorderAnchor(getFigure());
	}
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:29,代码来源:FunctionColumnModelEditPart.java

示例8: getTargetConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
	if(request instanceof ReconnectRequest) {
		ReconnectRequest r = (ReconnectRequest)request;
		ColumnConnectionEditPart con =(ColumnConnectionEditPart) r.getConnectionEditPart();
		ColumnConnection conModel = (ColumnConnection)con.getModel();
		BorderAnchor anchor = con.getTargetAnchor();
		GraphicalEditPart part = (GraphicalEditPart)r.getTarget();
		if(anchor == null || anchor.getOwner() != part.getFigure()) {
		    anchor = new RectangleBorderAnchor(getFigure());
			anchor.setAngle(conModel.getTargetAngle());
			con.setTargetAnchor(anchor);
		}
		
		Point loc = r.getLocation();
		Rectangle rect = Rectangle.SINGLETON;
		rect.setBounds(getFigure().getBounds());
		getFigure().translateToAbsolute(rect);
		Point ref = rect.getCenter();
		double dx = loc.x - ref.x;
		double dy = loc.y - ref.y;
		anchor.setAngle(Math.atan2(dy, dx));
		con.setTargetAnchor(anchor);
		conModel.setTargetAngle(anchor.getAngle());
		return anchor;		
	} else {
			return new RectangleBorderAnchor(getFigure());
	}
}
 
开发者ID:winture,项目名称:wt-studio,代码行数:29,代码来源:FunctionColumnModelEditPart.java

示例9: getSourceConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getSourceConnectionAnchor(final Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;

        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();

        // if (!(connectionEditPart instanceof RelationEditPart)) {
        // return super.getSourceConnectionAnchor(request);
        // }

        final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();
        if (connection.getSource() == connection.getTarget()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();

        if (editPart == null || !editPart.getModel().equals(connection.getSource())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);
        final IFigure sourceFigure = ((TableViewEditPart) connectionEditPart.getSource()).getFigure();

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());

        final Rectangle bounds = sourceFigure.getBounds();

        final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, sourceFigure);
            anchor.setLocation(point);
        }

        return anchor;

    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

        final Command command = connectionRequest.getStartCommand();

        if (command instanceof CreateCommentConnectionCommand) {
            return new ChopboxAnchor(getFigure());
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:55,代码来源:NodeElementEditPart.java

示例10: getTargetConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public ConnectionAnchor getTargetConnectionAnchor(final Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;

        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();

        // if (!(connectionEditPart instanceof RelationEditPart)) {
        // return super.getTargetConnectionAnchor(request);
        // }

        final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();
        if (connection.getSource() == connection.getTarget()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();

        if (editPart == null || !editPart.getModel().equals(connection.getTarget())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);
        final IFigure targetFigure = ((AbstractModelEditPart) connectionEditPart.getTarget()).getFigure();

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());

        final Rectangle bounds = targetFigure.getBounds();

        final Rectangle centerRectangle = new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, targetFigure);
            anchor.setLocation(point);
        }

        return anchor;

    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

        final Command command = connectionRequest.getStartCommand();

        if (command instanceof CreateCommentConnectionCommand) {
            return new ChopboxAnchor(getFigure());
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
开发者ID:roundrop,项目名称:ermasterr,代码行数:55,代码来源:NodeElementEditPart.java

示例11: getSourceConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
	if (request instanceof ReconnectRequest) {
		ReconnectRequest reconnectRequest = (ReconnectRequest) request;

		ConnectionEditPart connectionEditPart = reconnectRequest
				.getConnectionEditPart();

		// if (!(connectionEditPart instanceof RelationEditPart)) {
		// return super.getSourceConnectionAnchor(request);
		// }

		ConnectionElement connection = (ConnectionElement) connectionEditPart
				.getModel();
		if (connection.getSource() == connection.getTarget()) {
			return new XYChopboxAnchor(this.getFigure());
		}

		EditPart editPart = reconnectRequest.getTarget();

		if (editPart == null
				|| !editPart.getModel().equals(connection.getSource())) {
			return new XYChopboxAnchor(this.getFigure());
		}

		Point location = new Point(reconnectRequest.getLocation());
		this.getFigure().translateToRelative(location);
		IFigure sourceFigure = ((TableViewEditPart) connectionEditPart
				.getSource()).getFigure();

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

		Rectangle bounds = sourceFigure.getBounds();

		Rectangle centerRectangle = new Rectangle(bounds.x
				+ (bounds.width / 4), bounds.y + (bounds.height / 4),
				bounds.width / 2, bounds.height / 2);

		if (!centerRectangle.contains(location)) {
			Point point = getIntersectionPoint(location, sourceFigure);
			anchor.setLocation(point);
		}

		return anchor;

	} else if (request instanceof CreateConnectionRequest) {
		CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

		Command command = connectionRequest.getStartCommand();

		if (command instanceof CreateCommentConnectionCommand) {
			return new ChopboxAnchor(this.getFigure());
		}
	}

	return new XYChopboxAnchor(this.getFigure());
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:60,代码来源:NodeElementEditPart.java

示例12: getTargetConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public ConnectionAnchor getTargetConnectionAnchor(Request request) {
	if (request instanceof ReconnectRequest) {
		ReconnectRequest reconnectRequest = (ReconnectRequest) request;

		ConnectionEditPart connectionEditPart = reconnectRequest
				.getConnectionEditPart();

		// if (!(connectionEditPart instanceof RelationEditPart)) {
		// return super.getTargetConnectionAnchor(request);
		// }

		ConnectionElement connection = (ConnectionElement) connectionEditPart
				.getModel();
		if (connection.getSource() == connection.getTarget()) {
			return new XYChopboxAnchor(this.getFigure());
		}

		EditPart editPart = reconnectRequest.getTarget();

		if (editPart == null
				|| !editPart.getModel().equals(connection.getTarget())) {
			return new XYChopboxAnchor(this.getFigure());
		}

		Point location = new Point(reconnectRequest.getLocation());
		this.getFigure().translateToRelative(location);
		IFigure targetFigure = ((AbstractModelEditPart) connectionEditPart
				.getTarget()).getFigure();

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

		Rectangle bounds = targetFigure.getBounds();

		Rectangle centerRectangle = new Rectangle(bounds.x
				+ (bounds.width / 4), bounds.y + (bounds.height / 4),
				bounds.width / 2, bounds.height / 2);

		if (!centerRectangle.contains(location)) {
			Point point = getIntersectionPoint(location, targetFigure);
			anchor.setLocation(point);
		}

		return anchor;

	} else if (request instanceof CreateConnectionRequest) {
		CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;

		Command command = connectionRequest.getStartCommand();

		if (command instanceof CreateCommentConnectionCommand) {
			return new ChopboxAnchor(this.getFigure());
		}
	}

	return new XYChopboxAnchor(this.getFigure());
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:60,代码来源:NodeElementEditPart.java

示例13: getReconnectSourceCommand

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Command getReconnectSourceCommand(
		ReconnectRequest reconnectrequest) {
	ConnectionElement connection = (ConnectionElement) reconnectrequest
			.getConnectionEditPart().getModel();

	if (connection.getSource() == connection.getTarget()) {
		return null;
	}

	NodeElement newSource = (NodeElement) reconnectrequest.getTarget()
			.getModel();
	if (connection.getSource() != newSource) {
		return null;
	}

	NodeElementEditPart sourceEditPart = (NodeElementEditPart) reconnectrequest
			.getConnectionEditPart().getSource();

	Point location = new Point(reconnectrequest.getLocation());

	IFigure sourceFigure = sourceEditPart.getFigure();
	sourceFigure.translateToRelative(location);

	int xp = -1;
	int yp = -1;

	Rectangle bounds = sourceFigure.getBounds();

	Rectangle centerRectangle = new Rectangle(
			bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4),
			bounds.width / 2, bounds.height / 2);

	if (!centerRectangle.contains(location)) {
		Point point = ERTableEditPart.getIntersectionPoint(location,
				sourceFigure);
		xp = 100 * (point.x - bounds.x) / bounds.width;
		yp = 100 * (point.y - bounds.y) / bounds.height;
	}

	ReconnectSourceCommand command = new ReconnectSourceCommand(
			diagram, connection, xp, yp);

	return command;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:49,代码来源:NodeElementGraphicalNodeEditPolicy.java

示例14: getReconnectTargetCommand

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected Command getReconnectTargetCommand(
		ReconnectRequest reconnectrequest) {
	ConnectionElement connection = (ConnectionElement) reconnectrequest
			.getConnectionEditPart().getModel();

	if (connection.getSource() == connection.getTarget()) {
		return null;
	}

	NodeElement newTarget = (NodeElement) reconnectrequest.getTarget()
			.getModel();
	if (connection.getTarget() != newTarget) {
		return null;
	}

	NodeElementEditPart targetEditPart = (NodeElementEditPart) reconnectrequest
			.getConnectionEditPart().getTarget();

	Point location = new Point(reconnectrequest.getLocation());

	IFigure targetFigure = targetEditPart.getFigure();
	targetFigure.translateToRelative(location);

	int xp = -1;
	int yp = -1;

	Rectangle bounds = targetFigure.getBounds();

	Rectangle centerRectangle = new Rectangle(
			bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4),
			bounds.width / 2, bounds.height / 2);

	if (!centerRectangle.contains(location)) {
		Point point = ERTableEditPart.getIntersectionPoint(location,
				targetFigure);

		xp = 100 * (point.x - bounds.x) / bounds.width;
		yp = 100 * (point.y - bounds.y) / bounds.height;
	}
	ReconnectTargetCommand command = new ReconnectTargetCommand(
			diagram, connection, xp, yp);

	return command;
}
 
开发者ID:kozake,项目名称:ermaster-k,代码行数:49,代码来源:NodeElementGraphicalNodeEditPolicy.java

示例15: getSourceConnectionAnchor

import org.eclipse.gef.requests.ReconnectRequest; //导入方法依赖的package包/类
@Override
public ConnectionAnchor getSourceConnectionAnchor(Request request) {
    if (request instanceof ReconnectRequest) {
        final ReconnectRequest reconnectRequest = (ReconnectRequest) request;
        final ConnectionEditPart connectionEditPart = reconnectRequest.getConnectionEditPart();
        if (!(connectionEditPart instanceof RelationEditPart)) {
            return super.getSourceConnectionAnchor(request);
        }

        final Relationship relation = (Relationship) connectionEditPart.getModel();
        if (relation.getSourceWalker() == relation.getTargetWalker()) {
            return new XYChopboxAnchor(getFigure());
        }

        final EditPart editPart = reconnectRequest.getTarget();
        if (editPart == null || !editPart.getModel().equals(relation.getSourceWalker())) {
            return new XYChopboxAnchor(getFigure());
        }

        final Point location = new Point(reconnectRequest.getLocation());
        getFigure().translateToRelative(location);

        final IFigure sourceFigure = ((TableViewEditPart) connectionEditPart.getSource()).getFigure();
        final Rectangle bounds = sourceFigure.getBounds();
        final Rectangle centerRectangle =
                new Rectangle(bounds.x + (bounds.width / 4), bounds.y + (bounds.height / 4), bounds.width / 2, bounds.height / 2);

        final XYChopboxAnchor anchor = new XYChopboxAnchor(getFigure());
        if (!centerRectangle.contains(location)) {
            final Point point = getIntersectionPoint(location, sourceFigure);
            anchor.setLocation(point);
        }

        return anchor;
    } else if (request instanceof CreateConnectionRequest) {
        final CreateConnectionRequest connectionRequest = (CreateConnectionRequest) request;
        final Command command = connectionRequest.getStartCommand();
        if (command instanceof CreateCommentConnectionCommand) {
            return super.getTargetConnectionAnchor(request);
        }
    }

    return new XYChopboxAnchor(getFigure());
}
 
开发者ID:dbflute-session,项目名称:erflute,代码行数:45,代码来源:TableViewEditPart.java


注:本文中的org.eclipse.gef.requests.ReconnectRequest.getLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。