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


Java ConnectionWidget.getSourceAnchor方法代码示例

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


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

示例1: 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

示例2: collectObstacles

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
private int collectObstacles(List<Rectangle> colrects, List<Widget> colwidgets , ConnectionWidget cw){        
    int count=0;                        
    Anchor sourceAnchor = cw.getSourceAnchor();
    Anchor targetAnchor = cw.getTargetAnchor();
    Widget sourceWidget = sourceAnchor.getRelatedWidget();
    Widget targetWidget = targetAnchor.getRelatedWidget(); 
    Point start = sourceAnchor.compute(cw.getSourceAnchorEntry()).getAnchorSceneLocation();
    Point end =   targetAnchor.compute(cw.getTargetAnchorEntry()).getAnchorSceneLocation();
                    
    for(Widget w : colwidgets){
        
        if(w==sourceWidget || w == targetWidget) continue;
       
        Rectangle r = w.convertLocalToScene(w.getBounds());
        r.grow(HEXPAND, VEXPAND);
        if(r.intersectsLine(start.x,start.y,end.x,end.y))
            count++;
        colrects.add(r);
    }
    return count;
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:22,代码来源:PolylineRouterV2.java

示例3: 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) {
        list.add (sourceAnchor.compute(widget.getSourceAnchorEntry ()).getAnchorSceneLocation());
        list.add (targetAnchor.compute(widget.getTargetAnchorEntry ()).getAnchorSceneLocation());
    }

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

示例4: routeConnection

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
public List<Point> routeConnection(final ConnectionWidget widget) {       
    if(!widget.isVisible()) return Collections.<Point>emptyList();
   
    Anchor sourceAnchor = widget.getSourceAnchor();
    Anchor targetAnchor = widget.getTargetAnchor();
     
    if(sourceAnchor == null || targetAnchor == null) 
        return null;
    
    Point start = sourceAnchor.compute(widget.getSourceAnchorEntry()).getAnchorSceneLocation();
    Point end =   targetAnchor.compute(widget.getTargetAnchorEntry()).getAnchorSceneLocation();
    
    Widget sourceWidget = sourceAnchor.getRelatedWidget();
    Widget targetWidget = targetAnchor.getRelatedWidget();  
    
    
    if(sourceWidget == targetWidget){//reflexive edges doesnt need any path      
        return Collections.<Point>emptyList();
    }
       
    List<Widget> nodeWidgets = new ArrayList<>();
    
    if(collector != null){
        collector.collectCollisions(nodeWidgets);    
        //source and target widget are not treatet as obstacle
        nodeWidgets.remove(sourceWidget);
        nodeWidgets.remove(targetWidget);
    }
                        
    List<Point> controlPoints = optimize(nodeWidgets, widget, start, end); 
          
    //size==2 => straight line
    //size==3 => ensures a collision between cp0 and cp2 therefore its not possible to simplify it
    if(controlPoints.size() > 3)
        controlPoints = simplify(nodeWidgets, controlPoints);
    
    return controlPoints;        
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:39,代码来源:PolylineRouter.java

示例5: routeConnection

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
@Override
public List<Point> routeConnection(ConnectionWidget widget) {
    List<Point> points = new ArrayList<Point>();

    Anchor source = widget.getSourceAnchor();
    Anchor target = widget.getTargetAnchor();
    if(source != null && target != null) {
        Point sl = source.compute(widget.getSourceAnchorEntry()).getAnchorSceneLocation();
        Point tl = target.compute(widget.getTargetAnchorEntry()).getAnchorSceneLocation();
        fillPoints(points, sl, tl);
    }
    
    return points;
}
 
开发者ID:Depter,项目名称:JRLib,代码行数:15,代码来源:JRLibSceneRouter.java

示例6: routeConnection

import org.netbeans.api.visual.widget.ConnectionWidget; //导入方法依赖的package包/类
public List<Point> routeConnection(final ConnectionWidget widget) {       
        if(!widget.isVisible()) return Collections.<Point>emptyList();
   
        Anchor sourceAnchor = widget.getSourceAnchor();
        Anchor targetAnchor = widget.getTargetAnchor();
         
        if(sourceAnchor == null || targetAnchor == null) 
            return null;
        
        Point start = sourceAnchor.compute(widget.getSourceAnchorEntry()).getAnchorSceneLocation();
        Point end =   targetAnchor.compute(widget.getTargetAnchorEntry()).getAnchorSceneLocation();

        Widget sourceWidget = sourceAnchor.getRelatedWidget();
        Widget targetWidget = targetAnchor.getRelatedWidget(); 
        
               
        if(sourceWidget == targetWidget){//reflexive edges doesnt need any path      
            return Collections.<Point>emptyList();
        }
        
        
        Point srcCenter = this.getSceneLocation(sourceWidget);
        Point tarCenter = this.getSceneLocation(targetWidget);
        
        List<Widget> widgetObstacles = new ArrayList<>();
        
        if(collector != null){
            collector.collectCollisions(widgetObstacles);                    
        }
        
        List<Rectangle> obstacles = new ArrayList<>(widgetObstacles.size());
        this.collectObstacles(obstacles, widgetObstacles, widget);
       
                    
        List<Point> controlPoints = optimize(obstacles, srcCenter, tarCenter);     
//        size==2 => straight line
//        size==3 => ensures a collision between cp0 and cp2 therefore its not possible to simplify it
        if(controlPoints.size() > 3){
            Point rstart = this.computateAnchorPosition(sourceWidget, controlPoints.get(1));            
            Point rend  = this.computateAnchorPosition(targetWidget, controlPoints.get(controlPoints.size()-2)); 
            controlPoints.set(0, rstart);           
            controlPoints.set(controlPoints.size()-1, rend);       
            controlPoints = simplify(obstacles, controlPoints);
        } else if (controlPoints.size()>=2){
                //use old points
            controlPoints.set(0, start);           
            controlPoints.set(controlPoints.size()-1, end);           
        
        }
        return controlPoints;        
    }
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:52,代码来源:PolylineRouterV2.java

示例7: 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.getSourceAnchor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。