Java Code Examples for org.netbeans.api.visual.anchor.Anchor#Direction

The following examples show how to use org.netbeans.api.visual.anchor.Anchor#Direction . 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: OrthogonalSearchRouterRegion.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public OrthogonalSearchRouterRegion (/*OrthogonalLinkRouterRegion parentRegion, */int x, int y, int width, int height, Anchor.Direction direction, int depth) {
        super (x, y, width, height);
//        this.parent = parentRegion;
        this.direction = direction;
        switch (direction) {
            case LEFT:
            case RIGHT:
                horizontal = true;
                break;
            case TOP:
            case BOTTOM:
                horizontal = false;
                break;
            default:
                throw new IllegalArgumentException ();
        }
        this.depth = depth;
    }
 
Example 2
Source File: OrthogonalSearchRouterRegion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private OrthogonalSearchRouterRegion cloneWithEdge (/*OrthogonalLinkRouterRegion parent, */Anchor.Direction dir, int depth) {
    switch (dir) {
        case LEFT:
            return new OrthogonalSearchRouterRegion (/*parent, */x, y, 0, height, dir, depth);
        case RIGHT:
            return new OrthogonalSearchRouterRegion (/*parent, */x + width, y, 0, height, dir, depth);
        case TOP:
            return new OrthogonalSearchRouterRegion (/*parent, */x, y, width, 0, dir, depth);
        case BOTTOM:
            return new OrthogonalSearchRouterRegion (/*parent, */x, y + height, width, 0, dir, depth);
        default:
            throw new IllegalArgumentException ();
    }
}
 
Example 3
Source File: OrthogonalSearchRouterRegion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Anchor.Direction getCounterClockWiseDirection (Anchor.Direction direction) {
    switch (direction) {
        case LEFT:
            return Anchor.Direction.BOTTOM;
        case RIGHT:
            return Anchor.Direction.TOP;
        case TOP:
            return Anchor.Direction.LEFT;
        case BOTTOM:
            return Anchor.Direction.RIGHT;
        default:
            throw new IllegalArgumentException ();
    }
}
 
Example 4
Source File: OrthogonalSearchRouterRegion.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static Anchor.Direction getClockWiseDirection (Anchor.Direction direction) {
    switch (direction) {
        case LEFT:
            return Anchor.Direction.TOP;
        case RIGHT:
            return Anchor.Direction.BOTTOM;
        case TOP:
            return Anchor.Direction.RIGHT;
        case BOTTOM:
            return Anchor.Direction.LEFT;
        default:
            throw new IllegalArgumentException ();
    }
}
 
Example 5
Source File: OrthogonalSearchRouterCore.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public OrthogonalSearchRouterCore (Scene scene, ArrayList<Rectangle> verticalCollisions, ArrayList<Rectangle> horizontalCollisions, Point sourcePoint, Anchor.Direction sourceDirection, Point targetPoint, Anchor.Direction targetDirection) {
    this.scene = scene;
    this.verticalCollisions = verticalCollisions;
    this.horizontalCollisions = horizontalCollisions;
    this.sourcePoint = sourcePoint;
    this.sourceDirection = sourceDirection;
    this.targetPoint = targetPoint;
    this.targetDirection = targetDirection;
}
 
Example 6
Source File: RectangularAnchor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private Result computeBoundaryIntersectionPoint(Point relatedLocation, Point oppositeLocation) {
    
    Widget widget = getRelatedWidget();
    Rectangle bounds = widget.getBounds();
    if (!includeBorders) {
        Insets insets = widget.getBorder().getInsets();
        bounds.x += insets.left;
        bounds.y += insets.top;
        bounds.width -= insets.left + insets.right;
        bounds.height -= insets.top + insets.bottom;
    }
    bounds = widget.convertLocalToScene(bounds);

    if (bounds.isEmpty() || relatedLocation.equals(oppositeLocation)) {
        return null;
    }
    float dx = oppositeLocation.x - relatedLocation.x;
    float dy = oppositeLocation.y - relatedLocation.y;

    float ddx = Math.abs(dx) / (float) bounds.width;
    float ddy = Math.abs(dy) / (float) bounds.height;

    Anchor.Direction direction;

    if (ddx >= ddy) {
        direction = dx >= 0.0f ? Direction.RIGHT : Direction.LEFT;
    } else {
        direction = dy >= 0.0f ? Direction.BOTTOM : Direction.TOP;
    }

    float scale = 0.5f / Math.max(ddx, ddy);

    Point point = new Point(Math.round(relatedLocation.x + scale * dx), 
            Math.round(relatedLocation.y + scale * dy));
    
    return new Anchor.Result(point, direction);
}
 
Example 7
Source File: OrthogonalSearchRouterRegion.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public Anchor.Direction getDirection () {
    return direction;
}