01: /*
02: * $RCSfile: WakeupOnTransformChange.java,v $
03: *
04: * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
06: *
07: * This code is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU General Public License version 2 only, as
09: * published by the Free Software Foundation. Sun designates this
10: * particular file as subject to the "Classpath" exception as provided
11: * by Sun in the LICENSE file that accompanied this code.
12: *
13: * This code is distributed in the hope that it will be useful, but WITHOUT
14: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16: * version 2 for more details (a copy is included in the LICENSE file that
17: * accompanied this code).
18: *
19: * You should have received a copy of the GNU General Public License version
20: * 2 along with this work; if not, write to the Free Software Foundation,
21: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
22: *
23: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
24: * CA 95054 USA or visit www.sun.com if you need additional information or
25: * have any questions.
26: *
27: * $Revision: 1.5 $
28: * $Date: 2008/02/28 20:17:33 $
29: * $State: Exp $
30: */
31:
32: package javax.media.j3d;
33:
34: import java.util.ArrayList;
35:
36: /**
37: * Class specifying a wakeup when the transform within a specified
38: * TransformGroup changes
39: */
40: public final class WakeupOnTransformChange extends WakeupCriterion {
41:
42: // different types of WakeupIndexedList that use in BehaviorStructure
43: static final int COND_IN_BS_LIST = 0;
44:
45: // total number of different IndexedUnorderedSet types
46: static final int TOTAL_INDEXED_UNORDER_SET_TYPES = 1;
47:
48: TransformGroupRetained transform;
49:
50: /**
51: * Constructs a new WakeupOnTransformChange criterion.
52: *
53: * @param node the TransformGroup node that will trigger a wakeup if
54: * its transform is modified
55: */
56: public WakeupOnTransformChange(TransformGroup node) {
57: this .transform = (TransformGroupRetained) node.retained;
58: synchronized (transform) {
59: if (transform.transformChange == null) {
60: transform.transformChange = new WakeupIndexedList(1,
61: WakeupOnTransformChange.class,
62: WakeupOnTransformChange.COND_IN_BS_LIST,
63: transform.universe);
64: }
65: }
66: WakeupIndexedList.init(this , TOTAL_INDEXED_UNORDER_SET_TYPES);
67: }
68:
69: /**
70: * Returns the TransformGroup node used in creating this WakeupCriterion
71: * @return the TransformGroup used in this criterion's construction
72: */
73: public TransformGroup getTransformGroup() {
74: return (TransformGroup) this .transform.source;
75: }
76:
77: /**
78: * This is a callback from BehaviorStructure. It is
79: * used to add wakeupCondition to behavior structure.
80: */
81: void addBehaviorCondition(BehaviorStructure bs) {
82: transform.addCondition(this );
83: }
84:
85: /**
86: * This is a callback from BehaviorStructure. It is
87: * used to remove wakeupCondition from behavior structure.
88: */
89: void removeBehaviorCondition(BehaviorStructure bs) {
90: transform.removeCondition(this );
91: }
92:
93: /**
94: * Perform task in addBehaviorCondition() that has to be
95: * set every time the condition met.
96: */
97: void resetBehaviorCondition(BehaviorStructure bs) {
98: }
99: }
|