001: /*
002: * $RCSfile: IndexedLineArray.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.6 $
028: * $Date: 2008/02/28 20:17:24 $
029: * $State: Exp $
030: */
031:
032: package javax.media.j3d;
033:
034: /**
035: * The IndexedLineArray object draws the array of vertices as individual
036: * line segments. Each pair of vertices defines a line to be drawn.
037: */
038:
039: public class IndexedLineArray extends IndexedGeometryArray {
040: /**
041: * Package scoped default constructor.
042: */
043: IndexedLineArray() {
044: }
045:
046: /**
047: * Constructs an empty IndexedLineArray object using the specified
048: * parameters.
049: *
050: * @param vertexCount
051: * see {@link GeometryArray#GeometryArray(int,int)}
052: * for a description of this parameter.
053: *
054: * @param vertexFormat
055: * see {@link GeometryArray#GeometryArray(int,int)}
056: * for a description of this parameter.
057: *
058: * @param indexCount
059: * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int)}
060: * for a description of this parameter.
061: *
062: * @exception IllegalArgumentException if vertexCount is less than 1,
063: * or indexCount is less than 2, or indexCount is <i>not</i>
064: * a multiple of 2
065: * ;<br>
066: * See {@link GeometryArray#GeometryArray(int,int)}
067: * for more exceptions that can be thrown
068: */
069: public IndexedLineArray(int vertexCount, int vertexFormat,
070: int indexCount) {
071: super (vertexCount, vertexFormat, indexCount);
072:
073: if (vertexCount < 1)
074: throw new IllegalArgumentException(J3dI18N
075: .getString("IndexedLineArray0"));
076:
077: if (indexCount < 2 || ((indexCount % 2) != 0))
078: throw new IllegalArgumentException(J3dI18N
079: .getString("IndexedLineArray1"));
080: }
081:
082: /**
083: * Constructs an empty IndexedLineArray object using the specified
084: * parameters.
085: *
086: * @param vertexCount
087: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
088: * for a description of this parameter.
089: *
090: * @param vertexFormat
091: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
092: * for a description of this parameter.
093: *
094: * @param texCoordSetCount
095: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
096: * for a description of this parameter.
097: *
098: * @param texCoordSetMap
099: * see {@link GeometryArray#GeometryArray(int,int,int,int[])}
100: * for a description of this parameter.
101: *
102: * @param indexCount
103: * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int)}
104: * for a description of this parameter.
105: *
106: * @exception IllegalArgumentException if vertexCount is less than 1,
107: * or indexCount is less than 2, or indexCount is <i>not</i>
108: * a multiple of 2
109: * ;<br>
110: * See {@link GeometryArray#GeometryArray(int,int,int,int[])}
111: * for more exceptions that can be thrown
112: *
113: * @since Java 3D 1.2
114: */
115: public IndexedLineArray(int vertexCount, int vertexFormat,
116: int texCoordSetCount, int[] texCoordSetMap, int indexCount) {
117:
118: super (vertexCount, vertexFormat, texCoordSetCount,
119: texCoordSetMap, indexCount);
120:
121: if (vertexCount < 1)
122: throw new IllegalArgumentException(J3dI18N
123: .getString("IndexedLineArray0"));
124:
125: if (indexCount < 2 || ((indexCount % 2) != 0))
126: throw new IllegalArgumentException(J3dI18N
127: .getString("IndexedLineArray1"));
128: }
129:
130: /**
131: * Constructs an empty IndexedLineArray object using the specified
132: * parameters.
133: *
134: * @param vertexCount
135: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
136: * for a description of this parameter.
137: *
138: * @param vertexFormat
139: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
140: * for a description of this parameter.
141: *
142: * @param texCoordSetMap
143: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
144: * for a description of this parameter.
145: *
146: * @param vertexAttrCount
147: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
148: * for a description of this parameter.
149: *
150: * @param vertexAttrSizes
151: * see {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
152: * for a description of this parameter.
153: *
154: * @param indexCount
155: * see {@link IndexedGeometryArray#IndexedGeometryArray(int,int,int,int[],int,int[],int)}
156: * for a description of this parameter.
157: *
158: * @exception IllegalArgumentException if vertexCount is less than 1,
159: * or indexCount is less than 2, or indexCount is <i>not</i>
160: * a multiple of 2
161: * ;<br>
162: * See {@link GeometryArray#GeometryArray(int,int,int,int[],int,int[])}
163: * for more exceptions that can be thrown
164: *
165: * @since Java 3D 1.4
166: */
167: public IndexedLineArray(int vertexCount, int vertexFormat,
168: int texCoordSetCount, int[] texCoordSetMap,
169: int vertexAttrCount, int[] vertexAttrSizes, int indexCount) {
170:
171: super (vertexCount, vertexFormat, texCoordSetCount,
172: texCoordSetMap, vertexAttrCount, vertexAttrSizes,
173: indexCount);
174:
175: if (vertexCount < 1)
176: throw new IllegalArgumentException(J3dI18N
177: .getString("IndexedLineArray0"));
178:
179: if (indexCount < 2 || ((indexCount % 2) != 0))
180: throw new IllegalArgumentException(J3dI18N
181: .getString("IndexedLineArray1"));
182: }
183:
184: /**
185: * Creates the retained mode IndexedLineArrayRetained object that this
186: * IndexedLineArray object will point to.
187: */
188: void createRetained() {
189: this .retained = new IndexedLineArrayRetained();
190: this .retained.setSource(this );
191: }
192:
193: /**
194: * @deprecated replaced with cloneNodeComponent(boolean forceDuplicate)
195: */
196: public NodeComponent cloneNodeComponent() {
197: IndexedLineArrayRetained rt = (IndexedLineArrayRetained) retained;
198: int texSetCount = rt.getTexCoordSetCount();
199: int[] texMap = null;
200: int vertexAttrCount = rt.getVertexAttrCount();
201: int[] vertexAttrSizes = null;
202: if (texSetCount > 0) {
203: texMap = new int[rt.getTexCoordSetMapLength()];
204: rt.getTexCoordSetMap(texMap);
205: }
206: if (vertexAttrCount > 0) {
207: vertexAttrSizes = new int[vertexAttrCount];
208: rt.getVertexAttrSizes(vertexAttrSizes);
209: }
210: IndexedLineArray l = new IndexedLineArray(rt.getVertexCount(),
211: rt.getVertexFormat(), texSetCount, texMap,
212: vertexAttrCount, vertexAttrSizes, rt.getIndexCount());
213: l.duplicateNodeComponent(this);
214: return l;
215: }
216: }
|