Ejemplo n.º 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);
    }
  }
Ejemplo n.º 2
0
  // ---------------------------------------------
  //  get all field names belongs to node
  // ---------------------------------------------
  public String[] getFieldNames(VRMLNode node) {
    int i;
    int n = node.getNumFields();

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

    int nValidFields = 0;
    for (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)) {
          nValidFields++;
        }
      }
    }

    if (nValidFields <= 0) return null;
    String[] fieldNames = new String[nValidFields];

    int iField = 0;
    for (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)) {
          fieldNames[iField] = fieldName;
          iField++;
        }
      }
    }

    return fieldNames;
  }
Ejemplo n.º 3
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);
          }
        }
      }
    }
  }
Ejemplo n.º 4
0
  // ---------------------------------------------
  //  check if specified field is MFNode
  // ---------------------------------------------
  public boolean isMFNodeField(VRMLNode node, String fieldName) {
    int i = node.getFieldIndex(fieldName);
    VRMLFieldData data = ((VRMLNodeType) node).getFieldValue(i);

    return (data.dataType == VRMLFieldData.NODE_ARRAY_DATA);
  }
Ejemplo n.º 5
0
 // ---------------------------------------------
 //  get field value of node
 // ---------------------------------------------
 public VRMLFieldData getFieldValue(VRMLNode node, String fieldName) {
   int i = node.getFieldIndex(fieldName);
   VRMLFieldData data = ((VRMLNodeType) node).getFieldValue(i);
   return data;
 }