Exemplo n.º 1
0
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_PICKING_GEOMETRY:
        fieldData.clear();

        if (pPickingGeometry != null) fieldData.nodeValue = pPickingGeometry;
        else fieldData.nodeValue = vfPickingGeometry;

        fieldData.dataType = VRMLFieldData.NODE_DATA;
        break;

      case FIELD_PICK_TARGET:
        fieldData.clear();
        fieldData.nodeArrayValue = vfPickTarget;
        fieldData.dataType = VRMLFieldData.NODE_ARRAY_DATA;
        fieldData.numElements = numPickTarget;
        break;

      case FIELD_PICKED_GEOMETRY:
        fieldData.clear();
        fieldData.nodeArrayValue = vfPickedGeometry;
        fieldData.dataType = VRMLFieldData.NODE_ARRAY_DATA;
        fieldData.numElements = numPickedGeometry;
        break;

      case FIELD_INTERSECTION_TYPE:
        fieldData.clear();
        fieldData.stringValue = vfIntersectionType;
        fieldData.dataType = VRMLFieldData.STRING_DATA;
        break;

      case FIELD_SORT_ORDER:
        fieldData.clear();
        fieldData.stringValue = vfSortOrder;
        fieldData.dataType = VRMLFieldData.STRING_DATA;
        break;

      case FIELD_OBJECT_TYPE:
        fieldData.clear();
        fieldData.numElements = vfObjectType.length;
        fieldData.stringArrayValue = vfObjectType;
        fieldData.dataType = fieldData.STRING_ARRAY_DATA;
        break;

      default:
        super.getFieldValue(index);
    }

    return fieldData;
  }
Exemplo n.º 2
0
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_BBOX_SIZE:
        fieldData.clear();
        fieldData.floatArrayValue = bboxSize;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      case FIELD_BBOX_CENTER:
        fieldData.clear();
        fieldData.floatArrayValue = bboxCenter;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      case FIELD_CHILDREN:
        fieldData.clear();

        VRMLNodeType[] kids = new VRMLNodeType[vfChildren.size()];
        vfChildren.toArray(kids);

        fieldData.nodeArrayValue = kids;
        fieldData.dataType = VRMLFieldData.NODE_ARRAY_DATA;
        fieldData.numElements = childCount;
        break;

      default:
        super.getFieldValue(index);
    }

    return fieldData;
  }
Exemplo n.º 3
0
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_NAME:
        fieldData.clear();
        fieldData.numElements = 1;
        fieldData.dataType = VRMLFieldData.STRING_DATA;
        fieldData.stringValue = vfName;
        break;
      case FIELD_SHAPE:
        fieldData.clear();
        if (pShape != null) fieldData.nodeValue = pShape;
        else fieldData.nodeValue = vfShape;
        fieldData.dataType = VRMLFieldData.NODE_DATA;
        break;

      case FIELD_BBOX_SIZE:
        fieldData.clear();
        fieldData.floatArrayValue = vfBboxSize;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      case FIELD_BBOX_CENTER:
        fieldData.clear();
        fieldData.floatArrayValue = vfBboxCenter;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      default:
        super.getFieldValue(index);
    }

    return fieldData;
  }
Exemplo n.º 4
0
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_MODE:
        fieldData.clear();
        fieldData.stringArrayValue = vfMode;
        fieldData.dataType = VRMLFieldData.STRING_ARRAY_DATA;
        fieldData.numElements = vfMode.length;
        break;

      case FIELD_SOURCE:
        fieldData.clear();
        fieldData.stringArrayValue = vfSource;
        fieldData.dataType = VRMLFieldData.STRING_ARRAY_DATA;
        fieldData.numElements = vfSource.length;
        break;

      case FIELD_FUNCTION:
        fieldData.clear();
        fieldData.stringArrayValue = vfFunction;
        fieldData.dataType = VRMLFieldData.STRING_ARRAY_DATA;
        fieldData.numElements = vfFunction.length;
        break;

      case FIELD_TEXTURE:
        VRMLNodeType kids[] = new VRMLNodeType[vfTexture.size()];
        vfTexture.toArray(kids);
        fieldData.clear();
        fieldData.nodeArrayValue = kids;
        fieldData.dataType = VRMLFieldData.NODE_ARRAY_DATA;
        fieldData.numElements = kids.length;
        break;

      case FIELD_COLOR:
        fieldData.clear();
        fieldData.floatArrayValue = vfColor;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      case FIELD_ALPHA:
        fieldData.clear();
        fieldData.floatValue = vfAlpha;
        fieldData.dataType = VRMLFieldData.FLOAT_DATA;
        fieldData.numElements = 1;
        break;

      default:
        super.getFieldValue(index);
    }

    return fieldData;
  }
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_BOUNDARY_COLOR:
        fieldData.clear();
        fieldData.floatArrayValue = vfBoundaryColor;
        fieldData.dataType = VRMLFieldData.FLOAT_ARRAY_DATA;
        fieldData.numElements = 1;
        break;

      case FIELD_BOUNDARY_WIDTH:
        fieldData.clear();
        fieldData.intValue = vfBoundaryWidth;
        fieldData.dataType = VRMLFieldData.INT_DATA;
        break;

      case FIELD_MAGNIFICATION_FILTER:
        fieldData.clear();
        fieldData.stringValue = vfMagnificationFilter;
        fieldData.dataType = VRMLFieldData.STRING_DATA;
        break;

      case FIELD_MINIFICATION_FILTER:
        fieldData.clear();
        fieldData.stringValue = vfMinificationFilter;
        fieldData.dataType = VRMLFieldData.STRING_DATA;
        break;

      case FIELD_GENERATE_MIPMAPS:
        fieldData.clear();
        fieldData.booleanValue = vfGenerateMipMaps;
        fieldData.dataType = VRMLFieldData.BOOLEAN_DATA;
        break;

      case FIELD_ANISOTROPIC_MODE:
        fieldData.clear();
        fieldData.stringValue = vfAnisotropicMode;
        fieldData.dataType = VRMLFieldData.STRING_DATA;
        break;

      case FIELD_ANISOTROPIC_FILTER_DEGREE:
        fieldData.clear();
        fieldData.floatValue = vfAnisotropicFilterDegree;
        fieldData.dataType = VRMLFieldData.FLOAT_DATA;
        break;

      default:
        return (super.getFieldValue(index));
    }

    return fieldData;
  }
Exemplo n.º 6
0
  /**
   * Get the value of a field. If the field is a primitive type, it will return a class representing
   * the value. For arrays or nodes it will return the instance directly.
   *
   * @param index The index of the field to change.
   * @return The class representing the field value
   * @throws InvalidFieldException The field index is not known
   */
  public VRMLFieldData getFieldValue(int index) throws InvalidFieldException {
    VRMLFieldData fieldData = fieldLocalData.get();

    switch (index) {
      case FIELD_SPEED:
        fieldData.clear();
        fieldData.floatValue = vfSpeed;
        fieldData.dataType = VRMLFieldData.FLOAT_DATA;
        break;

      case FIELD_REPEAT_S:
        fieldData.clear();
        fieldData.booleanValue = vfRepeatS;
        fieldData.dataType = VRMLFieldData.BOOLEAN_DATA;
        break;

      case FIELD_REPEAT_T:
        fieldData.clear();
        fieldData.booleanValue = vfRepeatT;
        fieldData.dataType = VRMLFieldData.BOOLEAN_DATA;
        break;

      case FIELD_URL:
        fieldData.clear();
        fieldData.stringArrayValue = vfURL;
        fieldData.dataType = VRMLFieldData.STRING_ARRAY_DATA;
        fieldData.numElements = vfURL.length;
        break;

      case FIELD_DURATION:
        fieldData.clear();
        fieldData.doubleValue = vfDuration;
        fieldData.dataType = VRMLFieldData.DOUBLE_DATA;
        break;

      case FIELD_IS_ACTIVE:
        fieldData.clear();
        fieldData.booleanValue = vfIsActive;
        fieldData.dataType = VRMLFieldData.BOOLEAN_DATA;
        break;

      case FIELD_TEXTURE_PROPERTIES:
        if (vrmlMajorVersion <= 3 && vrmlMinorVersion < 2) {
          InvalidFieldException ife = new InvalidFieldException(TEXPROPS_VERSION_MSG);
          ife.setFieldName("TextureProperties");
          throw ife;
        }

        fieldData.clear();
        if (pTextureProperties != null) fieldData.nodeValue = pTextureProperties;
        else fieldData.nodeValue = vfTextureProperties;
        fieldData.dataType = VRMLFieldData.NODE_DATA;
        break;

      default:
        super.getFieldValue(index);
    }

    return fieldData;
  }