Java Code Examples for org.eclipse.gef.requests.BendpointRequest#getLocation()

The following examples show how to use org.eclipse.gef.requests.BendpointRequest#getLocation() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ERDiagramBendpointEditPolicy.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getCreateBendpointCommand(final BendpointRequest bendpointrequest) {
    final AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) getHost();
    final ConnectionElement connection = (ConnectionElement) connectionEditPart.getModel();

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

    final Point point = bendpointrequest.getLocation();
    getConnection().translateToRelative(point);

    final CreateBendpointCommand createBendpointCommand = new CreateBendpointCommand(connection, point.x, point.y, bendpointrequest.getIndex());

    return createBendpointCommand;
}
 
Example 2
Source File: ERDiagramBendpointEditPolicy.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected Command getCreateBendpointCommand(BendpointRequest bendpointrequest) {
    final AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) getHost();
    final WalkerConnection connection = (WalkerConnection) connectionEditPart.getModel();

    if (connection.getSourceWalker() == connection.getTargetWalker()) {
        return null;
    }

    final Point point = bendpointrequest.getLocation();
    getConnection().translateToRelative(point);

    final CreateBendpointCommand createBendpointCommand =
            new CreateBendpointCommand(connection, point.x, point.y, bendpointrequest.getIndex());

    return createBendpointCommand;
}
 
Example 3
Source File: ERDiagramBendpointEditPolicy.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getCreateBendpointCommand(
		BendpointRequest bendpointrequest) {
	AbstractConnectionEditPart connectionEditPart = (AbstractConnectionEditPart) this
			.getHost();
	ConnectionElement connection = (ConnectionElement) connectionEditPart
			.getModel();

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

	Point point = bendpointrequest.getLocation();
	this.getConnection().translateToRelative(point);

	CreateBendpointCommand createBendpointCommand = new CreateBendpointCommand(
			connection, point.x, point.y, bendpointrequest.getIndex());

	return createBendpointCommand;
}
 
Example 4
Source File: ERDiagramBendpointEditPolicy.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getMoveBendpointCommand(final BendpointRequest bendpointrequest) {
    final ConnectionEditPart editPart = (ConnectionEditPart) getHost();

    final Point point = bendpointrequest.getLocation();
    getConnection().translateToRelative(point);

    final MoveBendpointCommand command = new MoveBendpointCommand(editPart, point.x, point.y, bendpointrequest.getIndex());

    return command;
}
 
Example 5
Source File: ERDiagramBendpointEditPolicy.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected Command getMoveBendpointCommand(BendpointRequest bendpointrequest) {
    final ConnectionEditPart editPart = (ConnectionEditPart) getHost();

    final Point point = bendpointrequest.getLocation();
    getConnection().translateToRelative(point);

    final MoveBendpointCommand command = new MoveBendpointCommand(editPart, point.x, point.y, bendpointrequest.getIndex());

    return command;
}
 
Example 6
Source File: ERDiagramBendpointEditPolicy.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected Command getMoveBendpointCommand(BendpointRequest bendpointrequest) {
	ConnectionEditPart editPart = (ConnectionEditPart) this.getHost();

	Point point = bendpointrequest.getLocation();
	this.getConnection().translateToRelative(point);

	MoveBendpointCommand command = new MoveBendpointCommand(editPart,
			point.x, point.y, bendpointrequest.getIndex());

	return command;
}
 
Example 7
Source File: RelationBendpointEditPolicy.java    From ermasterr with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(final BendpointRequest bendpointrequest) {
    final Relation relation = (Relation) getHost().getModel();
    final RelationEditPart editPart = (RelationEditPart) getHost();

    if (relation.getSource() == relation.getTarget()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        final Point point = bendpointrequest.getLocation();
        getConnection().translateToRelative(point);
        final Bendpoint rate = getRate(point);
        rate.setRelative(true);

        final float rateX = (100f - (rate.getX() / 2)) / 100;
        final float rateY = (100f - (rate.getY() / 2)) / 100;

        final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
        final Rectangle bounds = tableEditPart.getFigure().getBounds();

        final Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = bounds.width * rate.getX() / 100;
        rect.height = bounds.height * rate.getY() / 100;

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        final LayerManager manager = (LayerManager) tableEditPart.getRoot();
        final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        getFeedbackLayer().setBounds(layer.getBounds());

        final List children = getFeedbackLayer().getChildren();
        children.clear();
        getFeedbackLayer().repaint();

        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }

}
 
Example 8
Source File: RelationBendpointEditPolicy.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
    final Relationship relation = (Relationship) getHost().getModel();
    final RelationEditPart editPart = (RelationEditPart) getHost();

    if (relation.getSourceWalker() == relation.getTargetWalker()) {
        if (bendpointrequest.getIndex() != 1) {
            return;
        }
        final Point point = bendpointrequest.getLocation();
        getConnection().translateToRelative(point);
        final Bendpoint rate = getRate(point);
        rate.setRelative(true);

        final float rateX = (100f - (rate.getX() / 2)) / 100;
        final float rateY = (100f - (rate.getY() / 2)) / 100;

        final ERTableEditPart tableEditPart = (ERTableEditPart) editPart.getSource();
        final Rectangle bounds = tableEditPart.getFigure().getBounds();

        final Rectangle rect = new Rectangle();
        rect.x = (int) (bounds.x + (bounds.width * rateX));
        rect.y = (int) (bounds.y + (bounds.height * rateY));
        rect.width = (int) (bounds.width * rate.getX() / 100);
        rect.height = (int) (bounds.height * rate.getY() / 100);

        relation.setSourceLocationp(100, (int) (100 * rateY));

        relation.setTargetLocationp((int) (100 * rateX), 100);

        final LayerManager manager = (LayerManager) tableEditPart.getRoot();
        final IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
        getFeedbackLayer().setBounds(layer.getBounds());

        final List<?> children = getFeedbackLayer().getChildren();
        children.clear();
        getFeedbackLayer().repaint();

        final ZoomManager zoomManager = ((ScalableFreeformRootEditPart) getHost().getRoot()).getZoomManager();
        final double zoom = zoomManager.getZoom();

        final Polyline feedbackFigure = new Polyline();
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) ((rect.y + rect.height) * zoom)));
        feedbackFigure.addPoint(new Point((int) ((rect.x + rect.width) * zoom), (int) (rect.y * zoom)));
        feedbackFigure.addPoint(new Point((int) (rect.x * zoom), (int) (rect.y * zoom)));

        feedbackFigure.setLineStyle(SWT.LINE_DASH);

        feedbackFigure.translateToRelative(feedbackFigure.getLocation());

        addFeedback(feedbackFigure);

    } else {
        super.showMoveBendpointFeedback(bendpointrequest);
    }
}
 
Example 9
Source File: RelationBendpointEditPolicy.java    From ermaster-b with Apache License 2.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void showMoveBendpointFeedback(BendpointRequest bendpointrequest) {
	Relation relation = (Relation) getHost().getModel();
	RelationEditPart editPart = (RelationEditPart) this.getHost();

	if (relation.getSource() == relation.getTarget()) {
		if (bendpointrequest.getIndex() != 1) {
			return;
		}
		Point point = bendpointrequest.getLocation();
		this.getConnection().translateToRelative(point);
		Bendpoint rate = this.getRate(point);
		rate.setRelative(true);

		float rateX = (100f - (rate.getX() / 2)) / 100;
		float rateY = (100f - (rate.getY() / 2)) / 100;

		ERTableEditPart tableEditPart = (ERTableEditPart) editPart
				.getSource();
		Rectangle bounds = tableEditPart.getFigure().getBounds();

		Rectangle rect = new Rectangle();
		rect.x = (int) (bounds.x + (bounds.width * rateX));
		rect.y = (int) (bounds.y + (bounds.height * rateY));
		rect.width = (int) (bounds.width * rate.getX() / 100);
		rect.height = (int) (bounds.height * rate.getY() / 100);

		relation.setSourceLocationp(100, (int) (100 * rateY));

		relation.setTargetLocationp((int) (100 * rateX), 100);

		LayerManager manager = (LayerManager) tableEditPart.getRoot();
		IFigure layer = manager.getLayer(LayerConstants.PRIMARY_LAYER);
		this.getFeedbackLayer().setBounds(layer.getBounds());

		List children = this.getFeedbackLayer().getChildren();
		children.clear();
		this.getFeedbackLayer().repaint();

		ZoomManager zoomManager = ((ScalableFreeformRootEditPart) this
				.getHost().getRoot()).getZoomManager();
		double zoom = zoomManager.getZoom();

		Polyline feedbackFigure = new Polyline();
		feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
				(int) (rect.y * zoom)));
		feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
				(int) ((rect.y + rect.height) * zoom)));
		feedbackFigure.addPoint(new Point(
				(int) ((rect.x + rect.width) * zoom),
				(int) ((rect.y + rect.height) * zoom)));
		feedbackFigure
				.addPoint(new Point((int) ((rect.x + rect.width) * zoom),
						(int) (rect.y * zoom)));
		feedbackFigure.addPoint(new Point((int) (rect.x * zoom),
				(int) (rect.y * zoom)));

		feedbackFigure.setLineStyle(SWT.LINE_DASH);

		feedbackFigure.translateToRelative(feedbackFigure.getLocation());

		this.addFeedback(feedbackFigure);

	} else {
		super.showMoveBendpointFeedback(bendpointrequest);
	}

}