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


Java Anchor.getRelatedWidget方法代码示例

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


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

示例1: findArrows

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的package包/类
/**
 * Find all arrows in the scene that have one of anchors attached to the
 * @arrowEndpointWidget
 * @param arrowEndpointWidget Widget that is used for anchor of each returned arrow.
 * @return Set of found arrows
 */
List<Widget> findArrows(Set<Widget> arrowEndpointWidgets) {
    List<Widget> foundArrows = new LinkedList<Widget>();
    
    for (Widget arrow : connectionLayer.getChildren()) {
        ArrowWidget arrowWidget = (ArrowWidget) arrow;

        Anchor sourceAnchor = arrowWidget.getSourceAnchor();
        Widget sourceWidget = sourceAnchor.getRelatedWidget();

        Anchor targetAnchor = arrowWidget.getTargetAnchor();
        Widget targetWidget = targetAnchor.getRelatedWidget();

        if (arrowEndpointWidgets.contains(targetWidget) || arrowEndpointWidgets.contains(sourceWidget)) {
            foundArrows.add(arrow);
        }
    }
    return foundArrows;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:25,代码来源:ShedScene.java

示例2: collectObstacles

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的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.anchor.Anchor; //导入方法依赖的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

示例4: routeConnection

import org.netbeans.api.visual.anchor.Anchor; //导入方法依赖的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


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