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