示例#1
0
  static {
    propertyNames = new HashSet();
    propertyNames.add("length");

    functionNames = new HashSet();
    functionNames.add("toString");
    functionNames.add("equals");

    jsUndefined = Context.getUndefinedValue();
  }
  /**
   * Set node content as replacement for the pickingGeometry field. This checks only for basic
   * geometry handling. If a concrete node needs a specific set of nodes, it should override this
   * method to check.
   *
   * @param app The new appearance. null will act like delete
   * @throws InvalidFieldValueException The node does not match the required type.
   */
  public void setPickingGeometry(VRMLNodeType child) throws InvalidFieldValueException {

    VRMLGeometryNodeType node;
    VRMLNodeType old_node;

    if (pPickingGeometry != null) old_node = pPickingGeometry;
    else old_node = vfPickingGeometry;

    if (child instanceof VRMLProtoInstance) {
      VRMLNodeType impl = ((VRMLProtoInstance) child).getImplementationNode();

      pPickingGeometry = (VRMLProtoInstance) child;

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

      if ((impl != null) && !(impl instanceof VRMLGeometryNodeType))
        throw new InvalidFieldValueException(GEOMETRY_PROTO_MSG);

      String name = impl.getVRMLNodeName();
      if (!validGeometryNodeNames.contains(name))
        throw new InvalidFieldValueException(PICK_GEOM_TYPE_MSG);

      node = (VRMLGeometryNodeType) impl;
    } else if (child instanceof VRMLGeometryNodeType) {
      String name = child.getVRMLNodeName();
      if (!validGeometryNodeNames.contains(name))
        throw new InvalidFieldValueException(PICK_GEOM_TYPE_MSG);

      pPickingGeometry = null;
      node = (VRMLGeometryNodeType) child;
    } else {
      throw new InvalidFieldValueException(GEOMETRY_NODE_MSG);
    }

    vfPickingGeometry = (VRMLGeometryNodeType) node;

    if (child != null) updateRefs(child, true);

    if (old_node != null) updateRefs(old_node, false);

    if (!inSetup) {
      if (old_node != null) stateManager.registerRemovedNode(old_node);

      if (child != null) stateManager.registerAddedNode(child);

      hasChanged[FIELD_PICKING_GEOMETRY] = true;
      fireFieldChanged(FIELD_PICKING_GEOMETRY);
    }
  }
示例#3
0
  /**
   * Check for the named property presence.
   *
   * @return true if it is a defined eventOut or field
   */
  public boolean has(String name, Scriptable start) {
    boolean ret_val = false;

    if (propertyNames.contains(name)) ret_val = true;
    else ret_val = super.has(name, start);

    return ret_val;
  }
示例#4
0
  /**
   * Get the value of the named function. If no function object is registex for this name, the
   * method will return null.
   *
   * @param name The variable name
   * @param start The object where the lookup began
   * @return the corresponding function object or null
   */
  public Object get(String name, Scriptable start) {
    Object ret_val = null;

    if (propertyNames.contains(name)) {
      ret_val = sizeInt;
    } else {
      ret_val = super.get(name, start);

      // it could be that this instance is dynamically created and so
      // the function name is not automatically registex by the
      // runtime. Let's check to see if it is a standard method for
      // this object and then create and return a corresponding Function
      // instance.
      if ((ret_val == null) && functionNames.contains(name)) ret_val = locateFunction(name);
    }

    if (ret_val == null) ret_val = NOT_FOUND;

    return ret_val;
  }