Beispiel #1
0
  void printField(VRMLNode node, String fieldName, int indentLevel) {
    String indentStr;

    indentStr = X3DParser.getIndentSpace(indentLevel + 1);
    System.out.print(indentStr);

    int i = node.getFieldIndex(fieldName);
    VRMLFieldData data = ((VRMLNodeType) node).getFieldValue(i);

    if (data.dataType == VRMLFieldData.NODE_DATA) {
      System.out.println("[ " + fieldName + " ]");

      VRMLNode child = data.nodeValue;
      if (child != null) {
        printNodeSub(child, indentLevel + 2);
      }
    } else if (data.dataType == VRMLFieldData.NODE_ARRAY_DATA) {
      System.out.println("[ " + fieldName + " ]");

      VRMLNode[] children = data.nodeArrayValue;
      for (int ind = 0; ind < children.length; ind++) {
        VRMLNode child = children[ind];
        if (child != null) {
          printNodeSub(child, indentLevel + 2);
        }
      }
    } else {
      String dataString = MyX3DUtil.VRMLFieldDataToString(data);

      System.out.println("[ " + fieldName + " ] : " + dataString);
    }
  }
Beispiel #2
0
  void printNodeSub(VRMLNode node, int indentLevel) {
    String indentStr = X3DParser.getIndentSpace(indentLevel);
    System.out.print(indentStr);
    System.out.println(node.getVRMLNodeName());

    if (node instanceof BaseWorldRoot) {

      BaseWorldRoot root = (BaseWorldRoot) node;

      VRMLNodeType[] childNodes = root.getChildren();
      for (int i = 0; i < childNodes.length; i++) {
        VRMLNode child = childNodes[i];
        printNodeSub(child, indentLevel + 1);
      }
    } else {
      int n = node.getNumFields();

      //			System.out.print(indentStr);
      //			System.out.println(Integer.toString(n)+" fields");

      for (int i = 1; i < n; i++) {
        //				System.out.print(indentStr);
        //				System.out.print(i);

        VRMLFieldDeclaration decl = node.getFieldDeclaration(i);
        if (decl != null) {
          String fieldName = decl.getName(); // field name
          //					System.out.println(" "+fieldName);

          int fieldAccess = decl.getAccessType();
          if ((fieldAccess == FieldConstants.FIELD)
              || (fieldAccess == FieldConstants.EXPOSEDFIELD)) {
            printField(node, fieldName, indentLevel);
          }
        }
      }
    }
  }