Java Code Examples for org.eclipse.draw2d.geometry.PrecisionPoint#preciseY()

The following examples show how to use org.eclipse.draw2d.geometry.PrecisionPoint#preciseY() . 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: GeometryUtil.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public double getParameterAt(Straight s, PrecisionPoint p) {
	if (!contains(s, p)) {
		throw new IllegalArgumentException(
				"The given position Vector has to be on this Straight: getParameterAt(" + s + ", " + p + ")");
	}

	if (Math.abs(s.direction.preciseX()) > Math.abs(s.direction.preciseY())) {
		return (p.preciseX() - s.position.preciseX()) / s.direction.preciseX();
	}
	if (s.direction.preciseY() != 0) {
		return (p.preciseY() - s.position.preciseY()) / s.direction.preciseY();
	}

	throw new IllegalStateException(
			"The direction Vector of this Straight may not be (0, 0) for this computation: getParameterAt(" + s
					+ ", " + p + ")");
}
 
Example 2
Source File: ROIFigure.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private PrecisionRectangle getGeoBoundsFromROI(Rectangle roiDataBounds){
	PrecisionPoint lt = ((GraphArea)getParent()).getGeoLocation(roiDataBounds.preciseX()-intensityGraphFigure.getCropLeft(), 
			roiDataBounds.preciseY()-intensityGraphFigure.getCropTop());
	PrecisionPoint rb = ((GraphArea)getParent()).getGeoLocation(
			roiDataBounds.preciseX() + roiDataBounds.preciseWidth() -intensityGraphFigure.getCropLeft(), 
			roiDataBounds.preciseY() + roiDataBounds.preciseHeight() -intensityGraphFigure.getCropTop());
	return new PrecisionRectangle(lt.preciseX()-getBounds().x, lt.preciseY()-getBounds().y, rb.preciseX() - lt.preciseX(), rb.preciseY() - lt.preciseY());			
}
 
Example 3
Source File: ConnData.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private MaxMoveDelta getMaxMoveDelta(Rectangle bounds, boolean isVerticalSegment, PrecisionPoint anchorPoint) {
		if (isVerticalSegment) {
			// move in X
			double x = anchorPoint.preciseX();
			double bx = bounds.preciseX() + SideDistance;
			double bx2 = (bx + bounds.preciseWidth()) - SideDistance - SideDistance;
			if (x <= bx) {
				x = bx + 1;
			}
			if (x >= bx2) {
				x = bx2 - 1;
			}
			return new MaxMoveDelta(false, x - bx2, x - bx);
		} else {
			// move in Y
			double y = anchorPoint.preciseY();
			double by = bounds.preciseY() + SideDistance;
			double by2 = (by + bounds.preciseHeight()) - SideDistance - SideDistance;
//			System.out.println("Y at " + y + ", by=" + by + " to " + by2);
			if (y <= by) {
				y = by + 1;
			}
			if (y >= by2) {
				y = by2 - 1;
			}
			return new MaxMoveDelta(true, y - by2, y - by);
		}
	}
 
Example 4
Source File: AdjustIdentityAnchorCommand.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
protected Point getAnchorRelativePoint(PrecisionPoint currentAnchorPoint, Rectangle bounds) {
	return new PrecisionPoint(bounds.width() * currentAnchorPoint.preciseX(),
			bounds.height() * currentAnchorPoint.preciseY());
}
 
Example 5
Source File: FixedConnectionAnchor.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public FixedConnectionAnchor(IFigure owner, PrecisionPoint offset) {
	this(owner, offset.preciseX(), offset.preciseY());
}
 
Example 6
Source File: GeometryUtil.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public PrecisionPoint getAdded(PrecisionPoint p, double dx, double dy) {
	return new PrecisionPoint(p.preciseX() + dx, p.preciseY() + dy);
}
 
Example 7
Source File: GeometryUtil.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
public PrecisionPoint getSubtracted(PrecisionPoint v, PrecisionPoint w) {
	return new PrecisionPoint(v.preciseX() - w.preciseX(), v.preciseY() - w.preciseY());
}
 
Example 8
Source File: CustomAnchor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public Point getOrthogonalLocation(Point orthoReference) {
    PrecisionPoint ownReference = new PrecisionPoint(getReferencePoint());
    //      PrecisionRectangle bounds = new PrecisionRectangle(getBox());
    PrecisionRectangle bounds = new PrecisionRectangle(CustomRectilinearRouter.getAnchorableFigureBounds(getOwner()));
    getOwner().translateToAbsolute(bounds);
    bounds.expand(0.000001, 0.000001);
    PrecisionPoint preciseOrthoReference = new PrecisionPoint(orthoReference);
    int orientation = PositionConstants.NONE;
    if (bounds.contains(preciseOrthoReference)) {
        int side = getClosestSide(ownReference, bounds);
        switch (side) {
            case PositionConstants.LEFT:
            case PositionConstants.RIGHT:
                ownReference.preciseY = preciseOrthoReference.preciseY();
                orientation = PositionConstants.HORIZONTAL;
                break;
            case PositionConstants.TOP:
            case PositionConstants.BOTTOM:
                ownReference.preciseX = preciseOrthoReference.preciseX();
                orientation = PositionConstants.VERTICAL;
                break;
        }
    } else if (preciseOrthoReference.preciseX >= bounds.preciseX
            && preciseOrthoReference.preciseX <= bounds.preciseX + bounds.preciseWidth) {
        ownReference.preciseX = preciseOrthoReference.preciseX;
        orientation = PositionConstants.VERTICAL;
    } else if (preciseOrthoReference.preciseY >= bounds.preciseY
            && preciseOrthoReference.preciseY <= bounds.preciseY + bounds.preciseHeight) {
        ownReference.preciseY = preciseOrthoReference.preciseY;
        orientation = PositionConstants.HORIZONTAL;
    }
    ownReference.updateInts();

    Point location = getLocation(ownReference, preciseOrthoReference);
    if (location == null) {
        location = getLocation(orthoReference);
        orientation = PositionConstants.NONE;
    }

    if (orientation != PositionConstants.NONE) {
        PrecisionPoint loc = new PrecisionPoint(location);
        if (orientation == PositionConstants.VERTICAL) {
            loc.preciseX = preciseOrthoReference.preciseX;
        } else {
            loc.preciseY = preciseOrthoReference.preciseY;
        }
        loc.updateInts();
        location = loc;
    }

    return location;
}