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


Java ConnectionWidget.getControlPoints方法代码示例

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


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

示例1: addRemoveControlPoint

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
/**
 * Adds or removes a control point on a specified location
 * @param widget the connection widget
 * @param localLocation the local location
 */
private void addRemoveControlPoint (ConnectionWidget widget, Point localLocation) {
    ArrayList<Point> list = new ArrayList<Point> (widget.getControlPoints ());
    if (!removeControlPoint (localLocation, list, deleteSensitivity)) {
        Point exPoint = null;
        int index = 0;
        for (Point elem : list) {
            if (exPoint != null) {
                Line2D l2d = new Line2D.Double (exPoint, elem);
                if (l2d.ptSegDist (localLocation) < createSensitivity) {
                    list.add (index, localLocation);
                    break;
                }
            }
            exPoint = elem;
            index++;
        }
    }
    if (routingPolicy != null)
        widget.setRoutingPolicy (routingPolicy);
    widget.setControlPoints (list, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:AddRemoveControlPointAction.java

示例2: routeConnection

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
public List<Point> routeConnection(ConnectionWidget widget) {
    ArrayList<Point> list = new ArrayList<Point> ();
    
    Anchor sourceAnchor = widget.getSourceAnchor();
    Anchor targetAnchor = widget.getTargetAnchor();
    if (sourceAnchor == null  ||  targetAnchor == null)
        return Collections.emptyList();

    list.add(sourceAnchor.compute(widget.getSourceAnchorEntry()).getAnchorSceneLocation());

    List<Point> oldControlPoints = widget.getControlPoints ();
    if(oldControlPoints !=null) {
        ArrayList<Point> oldList = new ArrayList<Point> (oldControlPoints);
        oldList.remove(widget.getFirstControlPoint());
        oldList.remove(widget.getLastControlPoint());
        list.addAll(oldList);
    }

    list.add(targetAnchor.compute(widget.getTargetAnchorEntry()).getAnchorSceneLocation());

    return list;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:FreeRouter.java

示例3: getOppositeSceneLocation

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
@Override
public Point getOppositeSceneLocation(Entry entry) {
    Point retVal = super.getOppositeSceneLocation(entry);

    // If the connection widget has connection points we need to find the 
    // connection point that is closes to the related widget.
    //
    // There are always two, one for the source and target ends.
    ConnectionWidget connection = entry.getAttachedConnectionWidget();
    if ((connection != null) && (connection.getControlPoints().size() > 2)) {
        List< Point> points = connection.getControlPoints();
        if (entry.isAttachedToConnectionSource() == true) {
            // The source end starts from the start of the collection of points.
            retVal = points.get(1);
        } else {
            // The target end starts from the end of the collection of points.
            retVal = points.get(points.size() - 2);
        }
    }

    return retVal;
}
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:23,代码来源:ShapeUniqueAnchor.java

示例4: getLocationPoint

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
protected Point getLocationPoint(double location) {
    ConnectionWidget connectionWidget = (ConnectionWidget) getRelatedWidget();

    java.util.List<Point> controlPoints = connectionWidget.getControlPoints();
    boolean empty = controlPoints == null || controlPoints.size() <= 0;

    double totalDistance = 0.0;
    double[] distances = new double[empty ? 0 : controlPoints.size() - 1];
    for (int i = 0; i < distances.length; i++) {
        distances[i] = totalDistance += GeomUtil.distanceSq(controlPoints.get(i), controlPoints.get(i + 1));
    }

    // For now I always want the center and the left and right sides of the
    // connectoin widget.
    double lineDistance = totalDistance * location;

    return getLinePointDistance(distances, (int) lineDistance, controlPoints);
}
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:19,代码来源:ConnectionAnchor.java

示例5: mousePressed

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (isLocked ())
        return State.createLocked (widget, this);
    if (event.getButton () == MouseEvent.BUTTON1  &&  event.getClickCount () == 1) {
        if (widget instanceof ConnectionWidget) {
            ConnectionWidget conn = (ConnectionWidget) widget;
            int index = conn.getControlPointHitAt (event.getPoint ());
            List<Point> controlPoints = conn.getControlPoints ();
            if (index == 0  &&  provider.isSourceReconnectable (conn)) {
                reconnectingSource = true;
            } else if (controlPoints != null  &&  index == controlPoints.size () - 1  && provider.isTargetReconnectable (conn)) {
                reconnectingSource = false;
            } else {
                return State.REJECTED;
            }

            floatPoint = new Point (event.getPoint ());
            replacementWidget = null;
            connectionWidget = conn;
            provider.reconnectingStarted (conn, reconnectingSource);
            if (reconnectingSource)
                originalAnchor = connectionWidget.getSourceAnchor ();
            else
                originalAnchor = connectionWidget.getTargetAnchor ();
            return State.createLocked (widget, this);
        }
    }
    return State.REJECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ReconnectAction.java

示例6: locationSuggested

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
public List<Point> locationSuggested(ConnectionWidget connectionWidget, int index, Point suggestedLocation) {
    List<Point> controlPoints = connectionWidget.getControlPoints();
    int cpSize=controlPoints.size()-1;
    ArrayList<Point> list = new ArrayList<Point> (controlPoints);
    if (index <= 0 || index >= cpSize)return null;
    if(index==1)list.set(0,connectionWidget.getSourceAnchor().compute(connectionWidget.getSourceAnchorEntry()).getAnchorSceneLocation());
    if(index==cpSize - 1)
        list.set(cpSize,connectionWidget.getTargetAnchor().compute(connectionWidget.getTargetAnchorEntry()).getAnchorSceneLocation());
    list.set(index, suggestedLocation);
    return list;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:FreeMoveControlPointProvider.java

示例7: layout

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
public void layout (Widget widget) {
    ConnectionWidget connectionWidget = (ConnectionWidget) widget;

    connectionWidget.calculateRouting ();
    java.util.List<Point> controlPoints = connectionWidget.getControlPoints ();
    boolean empty = controlPoints == null  ||  controlPoints.size () <= 0;

    double totalDistance = 0.0;
    double[] distances = new double[empty ? 0 : controlPoints.size () - 1];
    for (int i = 0; i < distances.length; i ++)
        distances[i] = totalDistance += GeomUtil.distanceSq (controlPoints.get (i), controlPoints.get (i + 1));

    ArrayList<Widget> childrenToResolve = new ArrayList<Widget> (widget.getChildren());
    for (Map.Entry<Placement,ArrayList<Widget>> entry : reverse.entrySet()) {
        Placement placement = entry.getKey ();
        ArrayList<Widget> currentlyResolving = null;
        for (Widget childWidget : entry.getValue()) {
            if (childWidget.getParentWidget() == widget  &&  childWidget.isVisible()) {
                if (currentlyResolving == null)
                    currentlyResolving = new ArrayList<Widget>();
                currentlyResolving.add(childWidget);
            }
        }
        if (currentlyResolving == null)
            continue;
        Point point;
        if (empty) {
            point = new Point();
        } else if (placement.isPercentage) {
            float percentage = placement.placementInPercentage;
            if (percentage <= 0.0)
                point = connectionWidget.getFirstControlPoint ();
            else if (percentage >= 1.0)
                point = connectionWidget.getLastControlPoint ();
            else
                point = getLinePointAtPercentage (distances, (int) (percentage * totalDistance), controlPoints);
        } else {
            int distance = placement.placementAtDistance;
            if (distance < 0)
                point = getLinePointAtPercentage (distances, distance + (int) totalDistance, controlPoints);
            else
                point = getLinePointAtPercentage (distances, distance, controlPoints);
        }
        layoutChildrenAt (point, placement.alignment, connectionWidget, currentlyResolving);
        childrenToResolve.removeAll (currentlyResolving);
    }
    if (! childrenToResolve.isEmpty())
        layoutChildrenAt (new Point (), null, connectionWidget, childrenToResolve);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:50,代码来源:ConnectionWidgetLayout.java

示例8: adjustControlPoints

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
/**
 * Adjust the control points of all selected connection widgets attached to
 * a node.
 *
 * @param widgets The list of widgets to update.
 * @param dx The distance in the x direction.
 * @param dy The distance in the y direction.
 */
public static void adjustControlPoints(List< Widget> widgets,
        int dx, int dy) {
    // Since child nodes are not part of the widgets (since they are moved
    // when the parent widget is moved), we need to first make sure
    // that we get not only the selected set of widgets, but also the
    // edges attached to all child nodes.  This is mostly for containers.
    List< ConnectionWidget> connections = includeAllConnections(widgets);

    ArrayList< Object> alreadyProcessed = new ArrayList< Object>();

    for (ConnectionWidget connection : connections) {
        GraphScene scene = (GraphScene) connection.getScene();
        Object data = scene.findObject(connection);

        if (alreadyProcessed.contains(data) == false) {
            if ((connection.getState().isSelected() == true)
                    || (widgets.contains(connection) == true)) {
                List<Point> points = connection.getControlPoints();
                for (int index = 1; index < points.size() - 1; index++) {
                    Point pt = points.get(index);
                    pt.x += dx;
                    pt.y += dy;
                }
            }

            // Each node also needs to be revalidated so that the anchor
            // gets a chance to update the end point
            Anchor sourceAnchor = connection.getSourceAnchor();
            if (sourceAnchor != null) {
                sourceAnchor.getRelatedWidget().revalidate();
            }

            Anchor targetAnchor = connection.getTargetAnchor();
            if (targetAnchor != null) {
                targetAnchor.getRelatedWidget().revalidate();
            }

            alreadyProcessed.add(data);
        }
    }
}
 
开发者ID:jeddict,项目名称:NBModeler,代码行数:50,代码来源:TransAlignWithMoveStrategyProvider.java


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