org.netbeans.api.visual.widget.Widget.getLocation()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(90)

本文整理了Java中org.netbeans.api.visual.widget.Widget.getLocation()方法的一些代码示例,展示了Widget.getLocation()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Widget.getLocation()方法的具体详情如下:
包路径:org.netbeans.api.visual.widget.Widget
类名称:Widget
方法名:getLocation

Widget.getLocation介绍

[英]Returns the resolved location of the widget. The location is specified relatively to the location of the parent widget.

The location is resolved/set by calling resolveBounds method which should be called from Layout interface implementation only. Therefore the corrent value is available only after the scene is validated (SceneListener.sceneValidated method). Before validation a previous/obsolete or [0,0] value could be returned. See Layout section in documentation.
[中]返回小部件的解析位置。该位置是相对于父窗口小部件的位置指定的。
通过调用resolveBounds方法解析/设置位置,该方法应仅从Layout接口实现调用。因此,只有在验证场景后,相应的值才可用(SceneListener.sceneValidated方法)。在验证之前,可以返回以前的/过时的或[0,0]值。请参阅文档中的布局部分。

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

/**
 * Converts a rectangle in the scene coordination system to the local coordination system.
 * @param sceneRectangle the scene rectangle
 * @return the local rectangle
 */
public final Rectangle convertSceneToLocal (Rectangle sceneRectangle) {
  Rectangle localRectangle = new Rectangle (sceneRectangle);
  Widget widget = this;
  while (widget != null) {
    if (widget == scene)
      break;
    Point location = widget.getLocation ();
    localRectangle.x -= location.x;
    localRectangle.y -= location.y;
    widget = widget.getParentWidget ();
  }
  return localRectangle;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

private Rectangle getTargetBounds()
  {
    Widget target = connection.getTargetAnchor().getRelatedWidget();
        
    if(target != null)
    {
      Point targetLocation = target.getLocation();
      Rectangle targetArea = target.getClientArea();
      return new Rectangle(targetLocation, targetArea.getSize());
    }
    
    return null;
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

private Rectangle getSourceBounds(ConnectionWidget connectionWidget) {
  Widget source = connectionWidget.getSourceAnchor().getRelatedWidget();
  if (source == null)
    return null;
  Point sourceLocation = source.getLocation();
  Rectangle clientArea = source.getClientArea();
  return new Rectangle(sourceLocation, clientArea.getSize());
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

private Rectangle getTargetBounds(ConnectionWidget connectionWidget) {
  Widget target = connectionWidget.getTargetAnchor().getRelatedWidget();
  if (target == null)
    return null;
  Point targetLocation = target.getLocation();
  Rectangle targetArea = target.getClientArea();
  return new Rectangle(targetLocation, targetArea.getSize());
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

private Rectangle getSourceBounds()
{
  Widget source = connection.getSourceAnchor().getRelatedWidget();
       if(source != null)
  {
    Point sourceLocation = source.getLocation();
    Rectangle clientArea = source.getClientArea();
    return new Rectangle(sourceLocation, clientArea.getSize());
  }
  
  return null;
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

private Rectangle getSourceBounds(ConnectionWidget connectionWidget) {
  Widget source = connectionWidget.getSourceAnchor().getRelatedWidget();
  if (source == null)
    return null;
  Point sourceLocation = source.getLocation();
  Rectangle clientArea = source.getClientArea();
  return new Rectangle(sourceLocation, clientArea.getSize());
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

private Rectangle getSourceBounds()
{
  Widget source = connection.getSourceAnchor().getRelatedWidget();
       if(source != null)
  {
    Point sourceLocation = source.getLocation();
    Rectangle clientArea = source.getClientArea();
    return new Rectangle(sourceLocation, clientArea.getSize());
  }
  
  return null;
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

private Rectangle getTargetBounds(ConnectionWidget connectionWidget) {
  Widget target = connectionWidget.getTargetAnchor().getRelatedWidget();
  if (target == null)
    return null;
  Point targetLocation = target.getLocation();
  Rectangle targetArea = target.getClientArea();
  return new Rectangle(targetLocation, targetArea.getSize());
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

private Rectangle getTargetBounds()
  {
    Widget target = connection.getTargetAnchor().getRelatedWidget();
        
    if(target != null)
    {
      Point targetLocation = target.getLocation();
      Rectangle targetArea = target.getClientArea();
      return new Rectangle(targetLocation, targetArea.getSize());
    }
    
    return null;
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

protected void performLayout () {
  devolveLayout.layout (widget);
  for (Widget child : widget.getChildren ()) {
    if (animate)
      widget.getScene ().getSceneAnimator ().animatePreferredLocation (child, child.getLocation ());
    else
      child.setPreferredLocation (child.getLocation ());
    child.revalidate ();
  }
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

protected void performLayout () {
  devolveLayout.layout (widget);
  for (Widget child : widget.getChildren ()) {
    if (animate)
      widget.getScene ().getSceneAnimator ().animatePreferredLocation (child, child.getLocation ());
    else
      child.setPreferredLocation (child.getLocation ());
    child.revalidate ();
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

private void translateView (int dx, int dy) {
  Widget v = getView ();
  if (v == null)
    return;
  Point location = view.getLocation ();
  location.translate (- dx, - dy);
  checkViewLocationInBounds (location, view, dx, dy);
  v.setPreferredLocation (location);
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

private void translateView (int dx, int dy) {
  Widget v = getView ();
  if (v == null)
    return;
  Point location = view.getLocation ();
  location.translate (- dx, - dy);
  checkViewLocationInBounds (location, view, dx, dy);
  v.setPreferredLocation (location);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-jsf-navigation

/**
   * Move a given page in the scene.  This allows arrow keys to move a page.
   **/
  public static void movePage(PageFlowScene scene, Page page, int horizontal, int vertical) {
    assert scene != null;
    assert page != null;

    Widget pageWidget = scene.findWidget(page);
    Point currentLocation = pageWidget.getLocation();
    currentLocation.translate(horizontal, vertical);
    pageWidget.setPreferredLocation(currentLocation);
    scene.validate();
  }
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

public void adjustmentValueChanged (AdjustmentEvent e) {
    Point location = view.getLocation ();
    if (vertical)
      location.y = - verticalScroll.getValue ();
    else
      location.x = - horizontalScroll.getValue ();
    view.setPreferredLocation (location);
    getScene ().validate ();
  }
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

public void adjustmentValueChanged (AdjustmentEvent e) {
    Point location = view.getLocation ();
    if (vertical)
      location.y = - verticalScroll.getValue ();
    else
      location.x = - horizontalScroll.getValue ();
    view.setPreferredLocation (location);
    getScene ().validate ();
  }
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

/**
 * Called to paint the children widgets only using the Graphics2D instance acquired from Scene.getGraphics method.
 */
protected void paintChildren () {
  if (checkClipping) {
    Rectangle clipBounds = scene.getGraphics ().getClipBounds ();
    for (Widget child : children) {
      Point location = child.getLocation ();
      Rectangle bounds = child.getBounds ();
      bounds.translate (location.x, location.y);
      if (bounds.intersects (clipBounds))
        child.paint ();
    }
  } else
    for (Widget child : children)
      child.paint ();
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

/**
 * Called to paint the children widgets only using the Graphics2D instance acquired from Scene.getGraphics method.
 */
protected void paintChildren () {
  if (checkClipping) {
    Rectangle clipBounds = scene.getGraphics ().getClipBounds ();
    for (Widget child : children) {
      Point location = child.getLocation ();
      Rectangle bounds = child.getBounds ();
      bounds.translate (location.x, location.y);
      if (clipBounds == null  ||  bounds.intersects (clipBounds))
        child.paint ();
    }
  } else
    for (Widget child : children)
      child.paint ();
}

代码示例来源:origin: org.netbeans.api/org-netbeans-api-visual

public void justify (Widget widget) {
  assert widget == cardLayoutWidget;
  if (activeChildWidget != null  &&  activeChildWidget.isVisible ())
    for (Widget child : cardLayoutWidget.getChildren ())
      if (child == activeChildWidget) {
        Rectangle bounds = widget.getClientArea ();
        Point location = child.getLocation ();
        Rectangle childBounds = child.getBounds ();
        bounds.translate (- location.x, - location.y);
        childBounds.add (bounds);
        child.resolveBounds (location, bounds);
        return;
      }
}

代码示例来源:origin: in.jlibs/org-netbeans-api-visual

public void justify (Widget widget) {
  assert widget == cardLayoutWidget;
  if (activeChildWidget != null  &&  activeChildWidget.isVisible ())
    for (Widget child : cardLayoutWidget.getChildren ())
      if (child == activeChildWidget) {
        Rectangle bounds = widget.getClientArea ();
        Point location = child.getLocation ();
        Rectangle childBounds = child.getBounds ();
        bounds.translate (- location.x, - location.y);
        childBounds.add (bounds);
        child.resolveBounds (location, bounds);
        return;
      }
}

相关文章