Exemplo n.º 1
0
 /**
  * Removes the first control that is an instance of the given class.
  *
  * @see Spatial#addControl(com.jme3.scene.control.Control)
  */
 public void removeControl(Class<? extends Control> controlType) {
   for (int i = 0; i < controls.size(); i++) {
     if (controlType.isAssignableFrom(controls.get(i).getClass())) {
       Control control = controls.remove(i);
       control.setSpatial(null);
     }
   }
 }
Exemplo n.º 2
0
 /**
  * Returns the first control that is an instance of the given class, or null if no such control
  * exists.
  *
  * @param controlType The superclass of the control to look for.
  * @return The first instance in the list of the controlType class, or null.
  * @see Spatial#addControl(com.jme3.scene.control.Control)
  */
 public <T extends Control> T getControl(Class<T> controlType) {
   for (Control c : controls.getArray()) {
     if (controlType.isAssignableFrom(c.getClass())) {
       return (T) c;
     }
   }
   return null;
 }
Exemplo n.º 3
0
  /**
   * Note that we are <i>matching</i> the pattern, therefore the pattern must match the entire
   * pattern (i.e. it behaves as if it is sandwiched between "^" and "$"). You can set regex modes,
   * like case insensitivity, by using the (?X) or (?X:Y) constructs.
   *
   * @param spatialSubclass Subclass which this must implement. Null causes all Spatials to qualify.
   * @param nameRegex Regular expression to match this name against. Null causes all Names to
   *     qualify.
   * @return true if this implements the specified class and this's name matches the specified
   *     pattern.
   * @see java.util.regex.Pattern
   */
  public boolean matches(Class<? extends Spatial> spatialSubclass, String nameRegex) {
    if (spatialSubclass != null && !spatialSubclass.isInstance(this)) {
      return false;
    }

    if (nameRegex != null && (name == null || !name.matches(nameRegex))) {
      return false;
    }

    return true;
  }