Пример #1
0
  /**
   * Check to make sure the picking target node being added is of the correct type. If not, issue an
   * error.
   *
   * @param target The node to check that it follows the requirements
   * @throws InvalidFieldValueException The node is not a grouping or shape node
   */
  protected void checkPickTargetType(VRMLNodeType target) throws InvalidFieldValueException {

    if ((target instanceof VRMLGroupingNodeType) || (target instanceof VRMLShapeNodeType)) return;

    if (!(target instanceof VRMLProtoInstance))
      throw new InvalidFieldValueException(
          "pickTarget node not a group or shape node type: " + target.getVRMLNodeName());

    VRMLProtoInstance proto = (VRMLProtoInstance) target;
    VRMLNodeType node = proto.getImplementationNode();

    while ((node != null) && (node instanceof VRMLProtoInstance))
      node = ((VRMLProtoInstance) node).getImplementationNode();

    if ((node != null)
        && (!(node instanceof VRMLGroupingNodeType) && !(node instanceof VRMLShapeNodeType)))
      throw new InvalidFieldValueException(
          "pickTarget proto instance not a group or shape node type: " + target.getVRMLNodeName());
  }