com.ardor3d.scenegraph.Node.hasAncestor()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(4.7k)|赞(0)|评价(0)|浏览(234)

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

Node.hasAncestor介绍

暂无

代码示例

代码示例来源:origin: com.ardor3d/ardor3d-core

  1. /**
  2. * determines if the provided Node is the parent, or parent's parent, etc. of this Spatial.
  3. *
  4. * @param ancestor
  5. * the ancestor object to look for.
  6. * @return true if the ancestor is found, false otherwise.
  7. */
  8. public boolean hasAncestor(final Node ancestor) {
  9. if (_parent == null) {
  10. return false;
  11. } else if (_parent.equals(ancestor)) {
  12. return true;
  13. } else {
  14. return _parent.hasAncestor(ancestor);
  15. }
  16. }

代码示例来源:origin: Renanse/Ardor3D

  1. /**
  2. * determines if the provided Node is the parent, or parent's parent, etc. of this Spatial.
  3. *
  4. * @param ancestor
  5. * the ancestor object to look for.
  6. * @return true if the ancestor is found, false otherwise.
  7. */
  8. public boolean hasAncestor(final Node ancestor) {
  9. if (_parent == null) {
  10. return false;
  11. } else if (_parent.equals(ancestor)) {
  12. return true;
  13. } else {
  14. return _parent.hasAncestor(ancestor);
  15. }
  16. }

代码示例来源:origin: com.ardor3d/ardor3d-core

  1. /**
  2. *
  3. * <code>attachChild</code> attaches a child to this node. This node becomes the child's parent. The current number
  4. * of children maintained is returned. <br>
  5. * If the child already had a parent it is detached from that former parent.
  6. *
  7. * @param child
  8. * the child to attach to this node.
  9. * @return the number of children maintained by this node.
  10. */
  11. public int attachChild(final Spatial child) {
  12. if (child != null) {
  13. if (child == this || (child instanceof Node && hasAncestor((Node) child))) {
  14. throw new IllegalArgumentException("Child is already part of this hierarchy.");
  15. }
  16. if (child.getParent() != this) {
  17. if (child.getParent() != null) {
  18. child.getParent().detachChild(child);
  19. }
  20. child.setParent(this);
  21. _children.add(child);
  22. child.markDirty(DirtyType.Attached);
  23. if (logger.isLoggable(Level.FINE)) {
  24. logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")");
  25. }
  26. }
  27. }
  28. return _children.size();
  29. }

代码示例来源:origin: com.ardor3d/ardor3d-core

  1. /**
  2. *
  3. * <code>attachChildAt</code> attaches a child to this node at an index. This node becomes the child's parent. The
  4. * current number of children maintained is returned. <br>
  5. * If the child already had a parent it is detached from that former parent.
  6. *
  7. * @param child
  8. * the child to attach to this node.
  9. * @return the number of children maintained by this node.
  10. */
  11. public int attachChildAt(final Spatial child, final int index) {
  12. if (child != null) {
  13. if (child == this || (child instanceof Node && hasAncestor((Node) child))) {
  14. throw new IllegalArgumentException("Child is already part of this hierarchy.");
  15. }
  16. if (child.getParent() != this) {
  17. if (child.getParent() != null) {
  18. child.getParent().detachChild(child);
  19. }
  20. child.setParent(this);
  21. _children.add(index, child);
  22. child.markDirty(DirtyType.Attached);
  23. if (logger.isLoggable(Level.FINE)) {
  24. logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")");
  25. }
  26. }
  27. }
  28. return _children.size();
  29. }

代码示例来源:origin: Renanse/Ardor3D

  1. /**
  2. *
  3. * <code>attachChildAt</code> attaches a child to this node at an index. This node becomes the child's parent. The
  4. * current number of children maintained is returned. <br>
  5. * If the child already had a parent it is detached from that former parent.
  6. *
  7. * @param child
  8. * the child to attach to this node.
  9. * @return the number of children maintained by this node.
  10. */
  11. public int attachChildAt(final Spatial child, final int index) {
  12. if (child != null) {
  13. if (child == this || (child instanceof Node && hasAncestor((Node) child))) {
  14. throw new IllegalArgumentException("Child is already part of this hierarchy.");
  15. }
  16. if (child.getParent() != this) {
  17. if (child.getParent() != null) {
  18. child.getParent().detachChild(child);
  19. }
  20. child.setParent(this);
  21. _children.add(index, child);
  22. child.markDirty(DirtyType.Attached);
  23. if (logger.isLoggable(Level.FINE)) {
  24. logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")");
  25. }
  26. }
  27. }
  28. return _children.size();
  29. }

代码示例来源:origin: Renanse/Ardor3D

  1. /**
  2. *
  3. * <code>attachChild</code> attaches a child to this node. This node becomes the child's parent. The current number
  4. * of children maintained is returned. <br>
  5. * If the child already had a parent it is detached from that former parent.
  6. *
  7. * @param child
  8. * the child to attach to this node.
  9. * @return the number of children maintained by this node.
  10. */
  11. public int attachChild(final Spatial child) {
  12. if (child != null) {
  13. if (child == this || (child instanceof Node && hasAncestor((Node) child))) {
  14. throw new IllegalArgumentException("Child is already part of this hierarchy.");
  15. }
  16. if (child.getParent() != this) {
  17. if (child.getParent() != null) {
  18. child.getParent().detachChild(child);
  19. }
  20. child.setParent(this);
  21. _children.add(child);
  22. child.markDirty(DirtyType.Attached);
  23. if (logger.isLoggable(Level.FINE)) {
  24. logger.fine("Child (" + child.getName() + ") attached to this" + " node (" + getName() + ")");
  25. }
  26. }
  27. }
  28. return _children.size();
  29. }

相关文章