001: /*
002: * $RCSfile: WakeupOr.java,v $
003: *
004: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
006: *
007: * This code is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU General Public License version 2 only, as
009: * published by the Free Software Foundation. Sun designates this
010: * particular file as subject to the "Classpath" exception as provided
011: * by Sun in the LICENSE file that accompanied this code.
012: *
013: * This code is distributed in the hope that it will be useful, but WITHOUT
014: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
015: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
016: * version 2 for more details (a copy is included in the LICENSE file that
017: * accompanied this code).
018: *
019: * You should have received a copy of the GNU General Public License version
020: * 2 along with this work; if not, write to the Free Software Foundation,
021: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
022: *
023: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
024: * CA 95054 USA or visit www.sun.com if you need additional information or
025: * have any questions.
026: *
027: * $Revision: 1.5 $
028: * $Date: 2008/02/28 20:17:33 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: import java.util.Vector;
035:
036: /**
037: * Class specifying any number of wakeup conditions ORed together.
038: * This WakeupCondition object specifies that Java 3D should awaken
039: * this Behavior when any of the WakeupCondition's constituent wakeup
040: * criteria becomes valid.
041: * <p>
042: * Note that a unique WakeupCriterion object must be used
043: * for each individual element in the array of wakeup criteria.
044: */
045:
046: public final class WakeupOr extends WakeupCondition {
047:
048: WakeupCriterion conditions[];
049:
050: /**
051: * Constructs a new WakeupOr criterion.
052: * @param conditions a vector of individual Wakeup conditions
053: */
054: public WakeupOr(WakeupCriterion conditions[]) {
055: this .conditions = new WakeupCriterion[conditions.length];
056:
057: for (int i = 0; i < conditions.length; i++) {
058: this .conditions[i] = conditions[i];
059: }
060: }
061:
062: /**
063: * This sets the bit for the given child, then checks if the full condition is met
064: */
065: void setConditionMet(int id, Boolean checkSchedulingRegion) {
066: if (parent == null) {
067: super .setConditionMet(this .id, checkSchedulingRegion);
068: } else {
069: parent.setConditionMet(this .id, checkSchedulingRegion);
070: }
071: }
072:
073: /**
074: * This gets called when this condition is added to the AndOr tree.
075: */
076: void buildTree(WakeupCondition parent, int id, BehaviorRetained b) {
077: super .buildTree(parent, id, b);
078:
079: for (int i = 0; i < conditions.length; i++) {
080: if (conditions[i] != null) {
081: conditions[i].buildTree(this , i, b);
082: }
083: }
084: }
085:
086: /**
087: * This goes through the AndOr tree to remove the various criterion from the
088: * BehaviorStructure lists
089: */
090: void cleanTree(BehaviorStructure bs) {
091: for (int i = 0; i < conditions.length; i++) {
092: conditions[i].cleanTree(bs);
093: }
094: }
095:
096: void reInsertElapseTimeCond() {
097: super .reInsertElapseTimeCond();
098: for (int i = 0; i < conditions.length; i++) {
099: if (conditions[i] != null) {
100: conditions[i].reInsertElapseTimeCond();
101: }
102: }
103: }
104:
105: /**
106: * This goes through the AndOr tree to remove the various criterion from the
107: * BehaviorStructure.
108: */
109: void resetTree() {
110: super .resetTree();
111: for (int i = 0; i < conditions.length; i++) {
112: if (conditions[i] != null) {
113: conditions[i].resetTree();
114: }
115: }
116: }
117:
118: }
|