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


Java Anchor.Result方法代码示例

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


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

示例1: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
public Result compute(Entry entry) {
    Point relatedLocation = getRelatedSceneLocation();
    Point oppositeLocation = null;

    if (oppositeLocation == null) {
        oppositeLocation = getOppositeSceneLocation(entry);
    }
    
    Result boundaryIntersection =
            computeBoundaryIntersectionPoint(relatedLocation, oppositeLocation);

    if (boundaryIntersection == null) {
        return new Anchor.Result(relatedLocation, Anchor.DIRECTION_ANY);
    }
    
    return boundaryIntersection ;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RectangularAnchor.java

示例2: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
public Result compute (Entry entry) {
    Point relatedLocation = getRelatedSceneLocation ();
    Point oppositeLocation = getOppositeSceneLocation (entry);

    Widget widget = getRelatedWidget ();
    Rectangle bounds = widget.convertLocalToScene (widget.getBounds ());
    Point center = GeomUtil.center (bounds);

    switch (kind) {
        case HORIZONTAL:
            if (relatedLocation.x >= oppositeLocation.x)
                return new Anchor.Result (new Point (bounds.x - gap, center.y), Direction.LEFT);
            else
                return new Anchor.Result (new Point (bounds.x + bounds.width + gap, center.y), Direction.RIGHT);
        case VERTICAL:
            if (relatedLocation.y >= oppositeLocation.y)
                return new Anchor.Result (new Point (center.x, bounds.y - gap), Direction.TOP);
            else
                return new Anchor.Result (new Point (center.x, bounds.y + bounds.height + gap), Direction.BOTTOM);
    }
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DirectionalAnchor.java

示例3: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
    Widget widget = getRelatedWidget();
    Widget otherWidget = entry.getOppositeAnchor().getRelatedWidget();
    Rectangle bounds = widget.convertLocalToScene(widget.getBounds());
    Rectangle otherBounds = otherWidget.convertLocalToScene(otherWidget.getBounds());
    Point center = getCenter(bounds);
    int leftBound = bounds.x;
    int rightBound = bounds.x + bounds.width;
    int oppositeLeftBound = otherBounds.x;
    int oppositeRightBound = otherBounds.x + otherBounds.width;
    if (leftBound >= oppositeRightBound) {
        return new Anchor.Result(new Point(leftBound, center.y), Direction.LEFT);
    } else if (rightBound <= oppositeLeftBound) {
        return new Anchor.Result(new Point(rightBound, center.y), Direction.RIGHT);
    } else {
        int leftDist = Math.abs(leftBound - oppositeLeftBound);
        int rightDist = Math.abs(rightBound - oppositeRightBound);
        if (leftDist <= rightDist) {
            return new Anchor.Result(new Point(leftBound, center.y), Direction.LEFT);
        } else {
            return new Anchor.Result(new Point(rightBound, center.y), Direction.RIGHT);
        }
    }
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:26,代码来源:BestPathAnchor.java

示例4: computeBoundaryIntersectionPoint

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:RectangularAnchor.java

示例5: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
public Result compute (Entry entry) {
    Point relatedLocation = getRelatedSceneLocation ();
    Point oppositeLocation = getOppositeSceneLocation (entry);

    double angle = Math.atan2 (oppositeLocation.y - relatedLocation.y, oppositeLocation.x - relatedLocation.x);

    Point location = new Point (relatedLocation.x + (int) (radius * Math.cos (angle)), relatedLocation.y + (int) (radius * Math.sin (angle)));
    return new Anchor.Result (location, Anchor.DIRECTION_ANY); // TODO - resolve direction
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:CircularAnchor.java

示例6: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
    Point relatedLocation = getRelatedSceneLocation();
    Point oppositeLocation = getOppositeSceneLocation(entry);

    Widget widget = getRelatedWidget();
    Rectangle bounds = widget.convertLocalToScene(widget.getBounds());

    if (relatedLocation.x >= oppositeLocation.x) {
        return new Anchor.Result(new Point(bounds.x, bounds.y + ShedWidget.height / 2), Direction.LEFT);
    } else {
        return new Anchor.Result(new Point(bounds.x + bounds.width, bounds.y + ShedWidget.height / 2), Direction.RIGHT);
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:ShedSenseWidget.java

示例7: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
    Widget widget = getRelatedWidget();
    Point sceneLocation = widget.convertLocalToScene(localLocation);

    return new Anchor.Result(new Point(sceneLocation), direction);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:ArrowWidget.java

示例8: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
    public Result compute(Entry entry) {
//          NodeWidget nodeWidget = (NodeWidget)getRelatedWidget().getParentWidget();
        Point relatedLocation = getRelatedSceneLocation();
        Point oppositeLocation = null;

        java.util.List<Point> points = entry.getAttachedConnectionWidget().getControlPoints();

        if (entry.getAttachedConnectionWidget() instanceof IFlowEdgeWidget) {
            IFlowEdgeWidget flowEdgeWidget = (IFlowEdgeWidget) entry.getAttachedConnectionWidget();
            INodeWidget sourceNodeWidget = (INodeWidget) flowEdgeWidget.getSourceWidget();
            INodeWidget targetNodeWidget = (INodeWidget) flowEdgeWidget.getTargetWidget();
            if (!sourceNodeWidget.isAnchorEnable() && !targetNodeWidget.isAnchorEnable() && !points.isEmpty()) {        //if edge both nodes anchor not enabled (if any one is allowed then calculated[means this if condition failed])
                if (entry.isAttachedToConnectionSource()) {
                    return new Anchor.Result(points.get(0), Anchor.DIRECTION_ANY); //return current
                } else {
                    return new Anchor.Result(points.get(points.size() - 1), Anchor.DIRECTION_ANY); //return current
                }
            }
        }

        if (points.size() > 2) {
            if (entry.isAttachedToConnectionSource()) {
                oppositeLocation = points.get(1);
                type = "SOURCE";
            } else {
                oppositeLocation = points.get(points.size() - 2);
                type = "TARGET";
            }
        } else {
            oppositeLocation = getOppositeSceneLocation(entry);
            type = "NONE";
        }

        return computeBoundaryIntersectionPoint((int) nodeWidget.getBounds().getWidth() / 2, relatedLocation, oppositeLocation);
    }
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:37,代码来源:CustomCircularAnchor.java

示例9: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
public List<Point> compute(List<Point> points) {
    ArrayList<Point> bestPoints = new ArrayList<Point>(points);
    Point relatedLocation = getRelatedSceneLocation();

    int direction = 1;
    int index = 0;

    //the related location is the center of this anchor. It is possible that
    //the list of points started at the opposite anchor (other end of connection).
    Point endPoint = bestPoints.get(index);
    if (!endPoint.equals(relatedLocation)) {
        index = bestPoints.size() - 1;
        endPoint = bestPoints.get(index);
        direction = -1;
    }

    Widget widget = getRelatedWidget();
    Rectangle bounds = widget.getBounds();
    bounds = widget.convertLocalToScene(bounds);

    Point neighbor = bestPoints.get(index + direction);

    //moving the end point to the end of the anchor from the interior
    while (bounds.contains(neighbor)) {
        bestPoints.remove(index);
        endPoint = bestPoints.get(index);
        neighbor = bestPoints.get(index + direction);
    }

    Anchor.Result intersection = this.computeBoundaryIntersectionPoint(endPoint, neighbor);

    bestPoints.remove(index);
    bestPoints.add(index, intersection.getAnchorSceneLocation());

    return bestPoints;
}
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:38,代码来源:CustomPathAnchor.java

示例10: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
    Widget widget = getRelatedWidget();
    Rectangle bounds = widget.convertLocalToScene(widget.getBounds());
    Point center = getCenter(bounds);
    int leftBound = bounds.x;
    int rightBound = bounds.x + bounds.width;
    if (direction == Direction.LEFT) {
        return new Anchor.Result(new Point(leftBound, center.y), Direction.LEFT);
    } else {
        return new Anchor.Result(new Point(rightBound, center.y), Direction.RIGHT);
    }
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:14,代码来源:FixedPathAnchor.java

示例11: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
public Result compute(Entry entry) {
    Widget widget = getRelatedWidget();
    Widget otherWidget = entry.getOppositeAnchor().getRelatedWidget();
    Rectangle bounds = widget.convertLocalToScene(widget.getBounds());
    Rectangle otherBounds = otherWidget.convertLocalToScene(otherWidget.getBounds());
    Point center = getCenter(bounds);
    Connection minimum = getMin(new Connection(bounds.x, otherBounds.x, Direction.LEFT), new Connection(bounds.x, otherBounds.x + otherBounds.width, Direction.LEFT));
    minimum = getMin(minimum, new Connection(bounds.x + bounds.width, otherBounds.x, Direction.RIGHT));
    minimum = getMin(minimum, new Connection(bounds.x + bounds.width, otherBounds.x + otherBounds.width, Direction.RIGHT));
    return new Anchor.Result(new Point(minimum.getStartX(), center.y), minimum.getDirection());
}
 
开发者ID:donatellosantoro,项目名称:Llunatic,代码行数:13,代码来源:BestPathObjectAnchor.java

示例12: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
public Anchor.Result compute (Anchor.Entry entry) {
    return anchors[index].compute (entry);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:4,代码来源:ProxyAnchor.java

示例13: computeBoundaryIntersectionPoint

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
private Result computeBoundaryIntersectionPoint(int radius, Point relatedLocation, Point oppositeLocation) { //Source Center , Target Center
    double angle = Math.atan2(oppositeLocation.y - relatedLocation.y, oppositeLocation.x - relatedLocation.x);
    Point location = new Point(relatedLocation.x + (int) (radius * Math.cos(angle)), relatedLocation.y + (int) (radius * Math.sin(angle)));
    type = "NONE";
    return new Anchor.Result(location, Anchor.DIRECTION_ANY); // TODO - resolve direction
}
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:7,代码来源:CustomCircularAnchor.java

示例14: computeBoundaryIntersectionPoint

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
private Result computeBoundaryIntersectionPoint(Point relatedLocation, Point oppositeLocation) { //Source Center , Target Center

        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));

//        if(direction== Direction.BOTTOM){
//            point.y = point.y - margin;
//        } else if(direction== Direction.TOP){
//            point.y = point.y + margin;
//        } else if(direction== Direction.LEFT){
//            point.x = point.x + margin;
//        } else if(direction== Direction.RIGHT){
//            point.x = point.x - margin;
//        }
        SvgNodeWidget imageWidget = (SvgNodeWidget) widget;
        Point movePo = null;
        if (imageWidget.getTransform() != null) {

            Shape shape = imageWidget.getTransform().createTransformedShape(imageWidget.getOutlineShape());
            Point widgetLoc = widget.convertLocalToScene(widget.getLocation());
            ClosestSegment cs = GeometryClosestPointManager.getClosetsPoint(shape, new Point2D.Double(point.x - widgetLoc.x, point.y - widgetLoc.y));
            int padX = 0;//padding
            int padY = 0;
            if (direction == Direction.TOP) {
                padY = - 2;
            } else if (direction == Direction.RIGHT) {
                padX = +2;
            } else if (direction == Direction.BOTTOM) {
                padY = +2;
            } else if (direction == Direction.LEFT) {
                padX = - 2;
            }

            movePo = new Point(widgetLoc.x + (int) cs.getBestPoint().getX() + padX, widgetLoc.y + (int) cs.getBestPoint().getY() + padY);

//            movePo = Util.getComputedPoint(oppositeLocation, movePo, 10);
        } else {
            movePo = point;
        }
        type = "NONE";
        return new Anchor.Result(movePo, direction);
    }
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:73,代码来源:CustomPathAnchor.java

示例15: compute

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
@Override
    public Result compute(Entry entry) {
//           NodeWidget nodeWidget = (NodeWidget)getRelatedWidget().getParentWidget();
        Point relatedLocation = getRelatedSceneLocation();
        Point oppositeLocation = null;
        List<Point> points = entry.getAttachedConnectionWidget().getControlPoints();

        if (entry.getAttachedConnectionWidget() instanceof IFlowEdgeWidget) {
            IFlowEdgeWidget flowEdgeWidget = (IFlowEdgeWidget) entry.getAttachedConnectionWidget();
            INodeWidget sourceNodeWidget = (INodeWidget) flowEdgeWidget.getSourceWidget();
            INodeWidget targetNodeWidget = (INodeWidget) flowEdgeWidget.getTargetWidget();
            if (sourceNodeWidget != null && targetNodeWidget != null && !sourceNodeWidget.isAnchorEnable() && !targetNodeWidget.isAnchorEnable() && !points.isEmpty()) {        //if edge both nodes anchor not enabled (if any one is allowed then calculated[means this if condition failed])
                if (entry.isAttachedToConnectionSource()) {
                    return new Anchor.Result(points.get(0), Anchor.DIRECTION_ANY); //return current
                } else {
                    return new Anchor.Result(points.get(points.size() - 1), Anchor.DIRECTION_ANY); //return current
                }
            }
        }
        if (points.size() > 2) {
            if (entry.isAttachedToConnectionSource()) {
                oppositeLocation = points.get(1);
                type = "SOURCE";
            } else {
                oppositeLocation = points.get(points.size() - 2);
                type = "TARGET";
            }
        } else {
            oppositeLocation = getOppositeSceneLocation(entry);
            type = "NONE";
        }

        Result boundaryIntersection
                = computeBoundaryIntersectionPoint(relatedLocation, oppositeLocation);

        if (boundaryIntersection == null) {
            return new Anchor.Result(relatedLocation, Anchor.DIRECTION_ANY);
        }

        return boundaryIntersection;
    }
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:42,代码来源:CustomRectangularAnchor.java


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