01: /*
02: * $RCSfile: DepthComponent.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.6 $
28: * $Date: 2008/02/28 20:17:20 $
29: * $State: Exp $
30: */
31:
32: package javax.media.j3d;
33:
34: /**
35: * Abstract base class that defines a 2D array of depth (Z) values.
36: */
37:
38: public abstract class DepthComponent extends NodeComponent {
39: /**
40: * Specifies that this DepthComponent object allows reading its
41: * size component information (width and height).
42: */
43: public static final int ALLOW_SIZE_READ = CapabilityBits.DEPTH_COMPONENT_ALLOW_SIZE_READ;
44:
45: /**
46: * Specifies that this DepthComponent object allows reading its
47: * depth data component information.
48: */
49: public static final int ALLOW_DATA_READ = CapabilityBits.DEPTH_COMPONENT_ALLOW_DATA_READ;
50:
51: // Array for setting default read capabilities
52: private static final int[] readCapabilities = { ALLOW_SIZE_READ,
53: ALLOW_DATA_READ };
54:
55: /**
56: * default constructor
57: */
58: DepthComponent() {
59: // set default read capabilities
60: setDefaultReadCapabilities(readCapabilities);
61: }
62:
63: /**
64: * Retrieves the width of this depth component object.
65: * @return the width of the array of depth values
66: * @exception CapabilityNotSetException if appropriate capability is
67: * not set and this object is part of live or compiled scene graph
68: */
69: public int getWidth() {
70: if (isLiveOrCompiled())
71: if (!this .getCapability(ALLOW_SIZE_READ))
72: throw new CapabilityNotSetException(J3dI18N
73: .getString("DepthComponent0"));
74: return ((DepthComponentRetained) this .retained).getWidth();
75: }
76:
77: /**
78: * Retrieves the height of this depth component object.
79: * @return the height of the array of depth values
80: * @exception CapabilityNotSetException if appropriate capability is
81: * not set and this object is part of live or compiled scene graph
82: */
83: public int getHeight() {
84: if (isLiveOrCompiled())
85: if (!this .getCapability(ALLOW_SIZE_READ))
86: throw new CapabilityNotSetException(J3dI18N
87: .getString("DepthComponent0"));
88: return ((DepthComponentRetained) this.retained).getHeight();
89: }
90:
91: }
|