blob: d0c0883b6e4a6ef0bf4b729a8c356faccf10407c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2016 Fundación Tecnalia Research & Innovation.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Huascar Espinoza - initial API and implementation
* Alejandra Ruíz - initial API and implementation
* Idoya Del Río - initial API and implementation
* Mari Carmen Palacios - initial API and implementation
* Angel López - initial API and implementation
*******************************************************************************/
package org.eclipse.opencert.sam.arg.ui.figures;
import org.eclipse.draw2d.AbstractConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PrecisionPoint;
import org.eclipse.draw2d.geometry.Rectangle;
public class FixedConnectionAnchor extends AbstractConnectionAnchor {
private double xOffset;
private double yOffset;
@SuppressWarnings("deprecation")
public FixedConnectionAnchor(IFigure owner, PrecisionPoint offset) {
this(owner, offset.preciseX, offset.preciseY);
}
public FixedConnectionAnchor(IFigure owner, double xOffset, double yOffset) {
super(owner);
this.xOffset = xOffset;
this.yOffset = yOffset;
}
@Override
public Point getLocation(Point point) {
return getLocation();
}
public Point getLocation() {
Rectangle r = getOwner().getBounds();
Point p = new PrecisionPoint(r.x + r.width*xOffset, r.y + r.height*yOffset);
getOwner().translateToAbsolute(p);
return p;
}
}