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


Java Widget.getBounds方法代码示例

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


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

示例1: mousePressed

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State mousePressed (Widget widget, WidgetMouseEvent event) {
    if (isLocked ())
        return State.createLocked (widget, this);
    if (event.getButton () == MouseEvent.BUTTON1  &&  event.getClickCount () == 1) {
        insets = widget.getBorder ().getInsets ();
        controlPoint = resolver.resolveControlPoint (widget, event.getPoint ());
        if (controlPoint != null) {
            resizingWidget = widget;
            originalSceneRectangle = null;
            if (widget.isPreferredBoundsSet ())
                originalSceneRectangle = widget.getPreferredBounds ();
            if (originalSceneRectangle == null)
                originalSceneRectangle = widget.getBounds ();
            if (originalSceneRectangle == null)
                originalSceneRectangle = widget.getPreferredBounds ();
            dragSceneLocation = widget.convertLocalToScene (event.getPoint ());
            provider.resizingStarted (widget);
            return State.createLocked (widget, this);
        }
    }
    return State.REJECTED;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:ResizeAction.java

示例2: locationSuggested

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public Point locationSuggested (Widget widget, Point originalLocation, Point suggestedLocation) {
    Point widgetLocation = widget.getLocation ();
    Rectangle widgetBounds = outerBounds ? widget.getBounds () : widget.getClientArea ();
    Rectangle bounds = widget.convertLocalToScene (widgetBounds);
    bounds.translate (suggestedLocation.x - widgetLocation.x, suggestedLocation.y - widgetLocation.y);
    Insets insets = widget.getBorder ().getInsets ();
    if (! outerBounds) {
        suggestedLocation.x += insets.left;
        suggestedLocation.y += insets.top;
    }
    Point point = super.locationSuggested (widget, bounds, widget.getParentWidget().convertLocalToScene(suggestedLocation), true, true, true, true);
    if (! outerBounds) {
        point.x -= insets.left;
        point.y -= insets.top;
    }
    return widget.getParentWidget ().convertSceneToLocal (point);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:AlignWithMoveStrategyProvider.java

示例3: keyPressed

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public State keyPressed (Widget widget, WidgetKeyEvent event) {
        if (event.getKeyCode () == KeyEvent.VK_CONTEXT_MENU  ||  ((event.getModifiers () & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK  &&  event.getKeyCode () == KeyEvent.VK_F10)) {
            JPopupMenu popupMenu = provider.getPopupMenu (widget, null);
            if (popupMenu != null) {
                JComponent view = widget.getScene ().getView ();
                if (view != null) {
//                    Rectangle visibleRect = view.getVisibleRect ();
//                    popupMenu.show (view, visibleRect.x + 10, visibleRect.y + 10);
                    Rectangle bounds = widget.getBounds ();
                    Point location = new Point (bounds.x + 5, bounds.y + 5);
                    location = widget.convertLocalToScene (location);
                    location = widget.getScene ().convertSceneToView (location);
                    popupMenu.show (view, location.x, location.y);
                }
            }
            return State.CONSUMED;
        }
        return State.REJECTED;
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:PopupMenuAction.java

示例4: findShedWidget

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private ShedWidget findShedWidget(Widget searchedEnvelope, Point scenePoint) {
    for (Widget searchedEnvelopeChild : searchedEnvelope.getChildren()) {
        ShedWidget foundWidget = findShedWidget(searchedEnvelopeChild, scenePoint);
        if (foundWidget != null) {
            return foundWidget;
        }
    }

    Rectangle localSearchedBounds = searchedEnvelope.getBounds();
    Rectangle sceneSearchedBounds = searchedEnvelope.convertLocalToScene(localSearchedBounds);

    if (sceneSearchedBounds.contains(scenePoint) && (searchedEnvelope instanceof ShedWidget)) {
        return (ShedWidget) searchedEnvelope;
    }
    return null;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:17,代码来源:ShedScene.java

示例5: computateAnchorPosition

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
 * Computates the Anchorposition like the Rectangular anchor for a
 * given widget as source/target and a controlpoint as opposit anchorposition
 */
 
private Point computateAnchorPosition(Widget relatedWidget, Point controlPoint) {
    Rectangle bounds = relatedWidget.getBounds();
    
    //todo: fix, center of widget must be cacluated trough the bounds 
    //since there are some wheird widgets where the location is not the center of the widget
    Point relatedLocation = relatedWidget.getLocation();//center of the widget
   
    if (bounds.isEmpty ()  || relatedLocation.equals (controlPoint))
        return relatedLocation;

    float dx = controlPoint.x - relatedLocation.x;
    float dy = controlPoint.y - relatedLocation.y;

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

    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 point;
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:28,代码来源:PolylineRouterV2.java

示例6: computateAnchorPosition

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
 * Computates the Anchorposition like the Rectangular anchor for a
 * given widget as source/target and a controlpoint as opposit anchorposition
 */
 
private Point computateAnchorPosition(Widget relatedWidget, Point controlPoint) {
    Rectangle bounds = relatedWidget.getBounds();
    Point relatedLocation = relatedWidget.getLocation();//center of the widget
   
    if (bounds.isEmpty ()  || relatedLocation.equals (controlPoint))
        return relatedLocation;

    float dx = controlPoint.x - relatedLocation.x;
    float dy = controlPoint.y - relatedLocation.y;

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

    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 point;
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:25,代码来源:PolylineRouter.java

示例7: performLayout

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
@Override
protected void performLayout() {
    Rectangle rectangle = null;
    List<? extends Widget> toFit = widgets != null ? widgets : depScene.getChildren();
    if (toFit == null) {
        return;
    }

    for (Widget widget : toFit) {
        Rectangle bounds = widget.getBounds();
        if (bounds == null) {
            continue;
        }
        if (rectangle == null) {
            rectangle = widget.convertLocalToScene(bounds);
        } else {
            rectangle = rectangle.union(widget.convertLocalToScene(bounds));
        }
    }
    // margin around
    if (widgets == null) {
        rectangle.grow(5, 5);
    } else {
        rectangle.grow(25, 25);
    }
    Dimension dim = rectangle.getSize();
    Dimension viewDim = parentScrollPane.getViewportBorderBounds().getSize ();
    double zf = Math.min ((double) viewDim.width / dim.width, (double) viewDim.height / dim.height);
    if (depScene.isAnimated()) {
        if (widgets == null) {
            depScene.getSceneAnimator().animateZoomFactor(zf);
        } else {
            CenteredZoomAnimator cza = new CenteredZoomAnimator(depScene.getSceneAnimator());
            cza.setZoomFactor(zf,
                    new Point((int)rectangle.getCenterX(), (int)rectangle.getCenterY()));
        }
    } else {
        depScene.setMyZoomFactor (zf);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:DependencyGraphScene.java

示例8: tick

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
protected void tick (double progress) {
    for (Map.Entry<Widget, Rectangle> entry : targetBounds.entrySet ()) {
        Widget widget = entry.getKey ();
        Rectangle sourceBoundary = sourceBounds.get (widget);
        if (sourceBoundary == null) {
            sourceBoundary = widget.getBounds ();
            if (sourceBoundary == null)
                sourceBoundary = new Rectangle ();
            sourceBounds.put (widget, sourceBoundary);
        }
        Rectangle targetBoundary = entry.getValue ();
        Rectangle boundary;
        if (progress >= 1.0) {
            boundary = nullBounds.get (widget) ? null : targetBoundary;
        } else
            boundary = new Rectangle (
                    (int) (sourceBoundary.x + progress * (targetBoundary.x - sourceBoundary.x)),
                    (int) (sourceBoundary.y + progress * (targetBoundary.y - sourceBoundary.y)),
                    (int) (sourceBoundary.width + progress * (targetBoundary.width - sourceBoundary.width)),
                    (int) (sourceBoundary.height + progress * (targetBoundary.height - sourceBoundary.height)));
        widget.setPreferredBounds (boundary);
    }
    if (progress >= 1.0) {
        sourceBounds.clear ();
        targetBounds.clear ();
        nullBounds.clear ();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:PreferredBoundsAnimator.java

示例9: resolveControlPoint

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public ResizeProvider.ControlPoint resolveControlPoint (Widget widget, Point point) {
    Rectangle bounds = widget.getBounds ();
    Insets insets = widget.getBorder ().getInsets ();
    Point center = GeomUtil.center (bounds);
    Dimension centerDimension = new Dimension (Math.max (insets.left, insets.right), Math.max (insets.top, insets.bottom));
    if (point.y >= bounds.y + bounds.height - insets.bottom && point.y < bounds.y + bounds.height) {

        if (point.x >= bounds.x + bounds.width - insets.right && point.x < bounds.x + bounds.width)
            return ResizeProvider.ControlPoint.BOTTOM_RIGHT;
        else if (point.x >= bounds.x && point.x < bounds.x + insets.left)
            return ResizeProvider.ControlPoint.BOTTOM_LEFT;
        else
        if (point.x >= center.x - centerDimension.height / 2 && point.x < center.x + centerDimension.height - centerDimension.height / 2)
            return ResizeProvider.ControlPoint.BOTTOM_CENTER;

    } else if (point.y >= bounds.y && point.y < bounds.y + insets.top) {

        if (point.x >= bounds.x + bounds.width - insets.right && point.x < bounds.x + bounds.width)
            return ResizeProvider.ControlPoint.TOP_RIGHT;
        else if (point.x >= bounds.x && point.x < bounds.x + insets.left)
            return ResizeProvider.ControlPoint.TOP_LEFT;
        else
        if (point.x >= center.x - centerDimension.height / 2 && point.x < center.x + centerDimension.height - centerDimension.height / 2)
            return ResizeProvider.ControlPoint.TOP_CENTER;

    } else
    if (point.y >= center.y - centerDimension.width / 2 && point.y < center.y + centerDimension.width - centerDimension.width / 2)
    {

        if (point.x >= bounds.x + bounds.width - insets.right && point.x < bounds.x + bounds.width)
            return ResizeProvider.ControlPoint.CENTER_RIGHT;
        else if (point.x >= bounds.x && point.x < bounds.x + insets.left)
            return ResizeProvider.ControlPoint.CENTER_LEFT;

    }
    // TODO - resolve CENTER points
    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ResizeCornersControlPointResolver.java

示例10: compute

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的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);
    }
    
    Result intersection = this.computeBoundaryIntersectionPoint(endPoint, neighbor);
            
    bestPoints.remove(index) ;
    bestPoints.add(index, intersection.getAnchorSceneLocation());
    
    return bestPoints ;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:RectangularAnchor.java

示例11: computeBoundaryIntersectionPoint

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

示例12: gotoSelection

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
public void gotoSelection(Set<Object> ids) {

        Rectangle overall = null;
        Set<Integer> hiddenNodes = new HashSet<>(this.getModel().getHiddenNodes());
        hiddenNodes.removeAll(ids);
        this.getModel().showNot(hiddenNodes);

        Set<Object> objects = idSetToObjectSet(ids);
        for (Object o : objects) {

            Widget w = getWidget(o);
            if (w != null) {
                Rectangle r = w.getBounds();
                Point p = w.convertLocalToScene(new Point(0, 0));

                Rectangle r2 = new Rectangle(p.x, p.y, r.width, r.height);

                if (overall == null) {
                    overall = r2;
                } else {
                    overall = overall.union(r2);
                }
            }
        }
        if (overall != null) {
            centerRectangle(overall);
        }

        setSelectedObjects(objects);
    }
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:31,代码来源:DiagramScene.java

示例13: getSceneLocation

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
/**
 * Returns the scene location of a related widget.
 * bounds might be null if the widget was not added to the scene
 * @return the scene location; null if no related widget is assigned
 */
public Point getSceneLocation (Widget relatedWidget) {
    if (relatedWidget != null) {
        Rectangle bounds = relatedWidget.getBounds ();
        if(bounds != null)
            return center(relatedWidget.convertLocalToScene(bounds));           
    }
    return null;
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:14,代码来源:PolylineRouterV2.java

示例14: centerWidget

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
private void centerWidget(Widget w) {
    Rectangle r = w.getBounds();
    Point p = w.getLocation();
    centerRectangle(new Rectangle(p.x, p.y, r.width, r.height));
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:6,代码来源:DiagramScene.java

示例15: createGraph

import org.netbeans.api.visual.widget.Widget; //导入方法依赖的package包/类
protected void createGraph() {
    for (E e : edges) {

        N source = uGraph.getEdgeSource(e);
        N target = uGraph.getEdgeTarget(e);

        Vertex sourceVertex = getVertex(source);
        Vertex targetVertex = getVertex(target);

        Edge edge = createEdge(sourceVertex, targetVertex, e);

        sourceVertex.addOutgoingEdge(edge);
        targetVertex.addIncomingEdge(edge);

        sourceVertex.addUpperNeighbor(targetVertex);
        targetVertex.addLowerNeighbor(sourceVertex);

    }

    for (N node : nodes) {
        Vertex vertex = getVertex(node);

        Widget widget = scene.findWidget(node);
        if (widget == null) continue ;  //why is it null
        Rectangle bounds = widget.getBounds();

        Dimension size = new Dimension(bounds.width, bounds.height);

        vertex.setSize(size);
    }


    findRootVertices();
//printGraph();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:DirectedGraph.java


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