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

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

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

Widget.setPreferredLocation介绍

[英]Sets a preferred location of the widget.
[中]设置小部件的首选位置。

代码示例

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

public void setNewLocation (Widget widget, Point location) {
    widget.setPreferredLocation (location);
  }
};

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

public void setNewLocation (Widget widget, Point location) {
    widget.setPreferredLocation (location);
  }
};

代码示例来源:origin: net.sourceforge.javydreamercsw/Client-UI

/**
 * Organize the children.
 *
 * @param child
 */
private void placeChild(Widget parent, Widget child, boolean invert) {
  Point point = new Point(getChildX(parent, child),
      getChildY(parent, child));
  LOG.log(Level.INFO, "Children location: {0}", point);
  child.setPreferredLocation(point);
}

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

private void resolveSelectionWidgetLocationBounds () {
  selectionWidget.setPreferredLocation (selectionSceneRectangle.getLocation ());
  int w = selectionSceneRectangle.width;
  int h = selectionSceneRectangle.height;
  selectionWidget.setPreferredBounds (new Rectangle (w >= 0 ? 0 : w, h >= 0 ? 0 : h, w >= 0 ? w : -w, h >= 0 ? h : -h));
}

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

private void resolveSelectionWidgetLocationBounds () {
  selectionWidget.setPreferredLocation (selectionSceneRectangle.getLocation ());
  int w = selectionSceneRectangle.width;
  int h = selectionSceneRectangle.height;
  selectionWidget.setPreferredBounds (new Rectangle (w >= 0 ? 0 : w, h >= 0 ? 0 : h, w >= 0 ? w : -w, h >= 0 ? h : -h));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-callgraph

@Override
  public void run() {
    Widget to = findWidget(element);
    if (to == null) {
      to = addNode(element);
      to.setPreferredLocation(new Point(100, 100));
      doLayout();
    }
  }
};

代码示例来源:origin: nl.cloudfarming.client/geoviewer-editor

@Override
  public void actionPerformed(ActionEvent e) {
    assert SwingUtilities.isEventDispatchThread();
    Point p = localLocation;
    p.x = p.x - MARGIN_X;
    p.y = p.y - MARGIN_Y;
    GeoNode geoNode = new GeoNode(pointToCoordinate(localLocation));
    scene.addNode(geoNode).setPreferredLocation(coordinateToPoint(geoNode.getCoordinate()));
    scene.validate();
  }
});

代码示例来源: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.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: it.tidalwave.netbeans/it-tidalwave-netbeans-visual

@Override
 public void setNewLocation (final @Nonnull Widget widget, final @Nonnull Point location)
  {
   logger.fine("setNewLocation(%s, %s)", widget, location);
   widget.setPreferredLocation(location);
   final Point layerLocation = layer.convertLocalToScene(location);
   final Point viewLocation = scene.convertSceneToView(layerLocation);
   final Dimension dimension = widget.getPreferredSize();
   if (dimension != null)
    {
     viewLocation.translate(dimension.width / 2, dimension.height / 2);
    }
   dragBehaviour.nodeDragged(new DragEvent(node, widget, viewLocation));
  }
};

代码示例来源: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: 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: 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

private boolean move (Widget widget, Point newLocation) {
  Widget view = getView ();
  if (movingWidget != widget  ||  view == null)
    return false;
  newLocation = widget.convertLocalToScene (newLocation);
  int dx = 0, dy = 0;
  if (slider.isVertical ())
    dy = - (int) ((newLocation.y - dragSceneLocation.y) / slider.getPixelIncrement ());
  else
    dx = - (int) ((newLocation.x - dragSceneLocation.x) / slider.getPixelIncrement ());
  newLocation.x = originalSceneLocation.x + dx;
  newLocation.y = originalSceneLocation.y + dy;
  checkViewLocationInBounds (newLocation, view, - dx, - dy);
  view.setPreferredLocation (newLocation);
  return true;
}

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

private boolean move (Widget widget, Point newLocation) {
  Widget view = getView ();
  if (movingWidget != widget  ||  view == null)
    return false;
  newLocation = widget.convertLocalToScene (newLocation);
  int dx = 0, dy = 0;
  if (slider.isVertical ())
    dy = - (int) ((newLocation.y - dragSceneLocation.y) / slider.getPixelIncrement ());
  else
    dx = - (int) ((newLocation.x - dragSceneLocation.x) / slider.getPixelIncrement ());
  newLocation.x = originalSceneLocation.x + dx;
  newLocation.y = originalSceneLocation.y + dy;
  checkViewLocationInBounds (newLocation, view, - dx, - dy);
  view.setPreferredLocation (newLocation);
  return true;
}

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

public static final void performLayout(PageFlowScene scene) {
  final FreePlaceNodesLayouter layout = new FreePlaceNodesLayouter(scene, true);
  final Collection<Page> pages = scene.getNodes();
  for( Page page: pages){
    final Widget widget = scene.findWidget(page);
    widget.setPreferredLocation(null);
  }
  scene.validate(); /* to make sure the nodes are set in a different place*/
  layout.layoutNodesLocations(scene, scene.getNodes());
  scene.validate();
}

代码示例来源: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: in.jlibs/org-netbeans-api-visual

/**
 * Should be called to set a new resolved preferred location of a node.
 * @param graph the universal graph
 * @param node the node with resolved location
 * @param newPreferredLocation the new resolved location
 */
protected final void setResolvedNodeLocation (UniversalGraph<N,E> graph, N node, Point newPreferredLocation) {
  ObjectScene scene = graph.getScene ();
  Widget widget = scene.findWidget (node);
  if (widget == null)
    return;
  Point previousPreferredLocation = widget.getPreferredLocation ();
  if (animated)
    scene.getSceneAnimator ().animatePreferredLocation (widget, newPreferredLocation);
  else
    widget.setPreferredLocation (newPreferredLocation);
  GraphLayoutListener<N,E>[] listeners = createListenersCopy ();
  for (GraphLayoutListener<N,E> listener : listeners)
    listener.nodeLocationChanged (graph, node, previousPreferredLocation, newPreferredLocation);
}

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

/**
 * Should be called to set a new resolved preferred location of a node.
 * @param graph the universal graph
 * @param node the node with resolved location
 * @param newPreferredLocation the new resolved location
 */
protected final void setResolvedNodeLocation (UniversalGraph<N,E> graph, N node, Point newPreferredLocation) {
  ObjectScene scene = graph.getScene ();
  Widget widget = scene.findWidget (node);
  if (widget == null)
    return;
  Point previousPreferredLocation = widget.getPreferredLocation ();
  if (animated)
    scene.getSceneAnimator ().animatePreferredLocation (widget, newPreferredLocation);
  else
    widget.setPreferredLocation (newPreferredLocation);
  GraphLayoutListener<N,E>[] listeners = createListenersCopy ();
  for (GraphLayoutListener<N,E> listener : listeners)
    listener.nodeLocationChanged (graph, node, previousPreferredLocation, newPreferredLocation);
}

相关文章