public class VecBuffer
extends java.lang.Object
BufferWrapper
to interpret its contents as a series of vector
tuples (rather than individual primitive types). The number of coordinates in each logical vector is specified by the
property coordsPerElem
. For example, if a VecBuffer is composed of (x, y, z) tuples then coordsPerElem
would be 3.Modifier and Type | Class and Description |
---|---|
protected class |
VecBuffer.BasicIterator<T> |
protected class |
VecBuffer.CoordAccessor |
protected static interface |
VecBuffer.ElementAccessor<T> |
protected class |
VecBuffer.LocationAccessor |
protected class |
VecBuffer.PositionAccessor |
protected class |
VecBuffer.ReverseIterator<T> |
protected class |
VecBuffer.VectorAccessor |
Modifier and Type | Field and Description |
---|---|
protected BufferWrapper |
buffer |
protected int |
coordsPerVec |
Constructor and Description |
---|
VecBuffer(int coordsPerVec,
BufferWrapper buffer)
Constructs a new VecBuffer with the specified vector size, and backing BufferWrapper.
|
Modifier and Type | Method and Description |
---|---|
void |
bindAsColorBuffer(DrawContext dc)
Binds this buffer as the source of color values to use when rendering OpenGL primitives.
|
void |
bindAsNormalBuffer(DrawContext dc)
Binds this buffer as the source of normal coordinates to use when rendering OpenGL primitives.
|
void |
bindAsTexCoordBuffer(DrawContext dc)
Binds this buffer as the source of texture coordinates to use when rendering OpenGL primitives.
|
void |
bindAsVertexBuffer(DrawContext dc)
Binds this buffer as the source of vertex coordinates to use when rendering OpenGL primitives.
|
VecBuffer |
copyOf(int newSize)
Returns a copy of this VecBuffer with the specified new size.
|
void |
drawArrays(DrawContext dc,
int drawMode)
Renders
getSize() elements from the currently bounds OpenGL coordinate buffers, beginning with
element 0. |
static VecBuffer |
emptyVecBuffer(int coordsPerVec)
Returns the empty VecBuffer.
|
double[] |
get(int position,
double[] array)
Returns the vector element at the specified position.
|
BufferWrapper |
getBufferWrapper()
Returns the backing BufferWrapper.
|
java.lang.Iterable<double[]> |
getCoords()
Returns an iterator over this buffer's logical vectors, as double[] coordinate arrays.
|
java.lang.Iterable<double[]> |
getCoords(int minCoordsPerVec)
Returns an iterator over this buffer's logical vectors, as double[] coordinate arrays.
|
int |
getCoordsPerVec()
Returns the number of coordinates per logical vector element.
|
float[] |
getFloat(int position,
float[] array)
Returns the vector element at the specified position.
|
LatLon |
getLocation(int position)
Returns the vector element at the specified position, as a geographic
LatLon . |
java.lang.Iterable<LatLon> |
getLocations()
Returns an iterator over this buffer's logical vectors, as LatLon locations.
|
Position |
getPosition(int position)
Returns the vector element at the specified position, as a geographic
Position . |
java.lang.Iterable<Position> |
getPositions()
Returns an iterator over this buffer's logical vectors, as geographic Positions.
|
java.lang.Iterable<double[]> |
getReverseCoords(int minCoordsPerVec)
Returns a reverse iterator over this buffer's logical vectors, as double[] coordinate arrays.
|
java.lang.Iterable<LatLon> |
getReverseLocations()
Returns a reverse iterator over this buffer's logical vectors, as LatLon locations.
|
java.lang.Iterable<Position> |
getReversePositions()
Returns a reverse iterator over this buffer's logical vectors, as geographic Positions.
|
java.lang.Iterable<Vec4> |
getReverseVectors()
Returns a reverse iterator over this buffer's logical vectors, as Vec4 references.
|
int |
getSize()
Returns the number of logical vector elements contained in the VecBuffer.
|
VecBuffer |
getSubBuffer(int position,
int size)
Returns a new VecBuffer which is a subsequence of this buffer.
|
Vec4 |
getVector(int position)
Returns the vector element at the specified position, as a
Vec4 . |
java.lang.Iterable<Vec4> |
getVectors()
Returns an iterator over this buffer's logical vectors, as Vec4 references.
|
protected int |
indexFromVectorPosition(int position)
Maps the logical vector position to a physical buffer index.
|
void |
put(int position,
double[] array)
Sets the vector element at the specified position.
|
void |
putAll(int position,
double[] array,
int count)
Sets the vector elements starting at the specified position, and ending at the specified position + count.
|
void |
putCoords(int position,
java.lang.Iterable<double[]> iterable)
Sets a subsequence of this buffer with the contents of the specified Iterable.
|
void |
putFloat(int position,
float[] array)
Sets the vector element at the specified position.
|
void |
putLocation(int position,
LatLon ll)
Sets the vector element at the specified position, as a geographic LatLon.
|
void |
putLocations(int position,
java.lang.Iterable<? extends LatLon> iterable)
Sets a subsequence of this buffer with the contents of the specified Iterable.
|
void |
putPosition(int position,
Position p)
Sets the vector element at the specified position, as a geographic Position.
|
void |
putPositions(int position,
java.lang.Iterable<? extends Position> iterable)
Sets a subsequence of this buffer with the contents of the specified Iterable.
|
void |
putSubBuffer(int position,
VecBuffer buffer)
Sets a subsequence of this buffer with the contents of the specified buffer.
|
void |
putSubBuffer(int position,
VecBuffer buffer,
int offset,
int size)
Sets a subsequence of this buffer with the contents of the specified buffer.
|
void |
putVector(int position,
Vec4 vec)
Sets the vector element at the specified position, as a Vec4.
|
void |
putVectors(int position,
java.lang.Iterable<? extends Vec4> iterable)
Sets a subsequence of this buffer with the contents of the specified Iterable.
|
protected int |
vectorPositionFromIndex(int index)
Maps the physical buffer index to a logical vector position.
|
protected BufferWrapper buffer
protected int coordsPerVec
public VecBuffer(int coordsPerVec, BufferWrapper buffer)
coordsPerVec
- the number of coordinates per logical vector.buffer
- the backing BufferWrapper.java.lang.IllegalArgumentException
- if coordsPerElem is 0 or negative, or if the buffer is null.public void bindAsColorBuffer(DrawContext dc)
Buffer
. This buffer's vector size must be 3, or 4.dc
- the current DrawContext
.java.lang.IllegalArgumentException
- if the DrawContext is null, or if this buffer is not compatible as a color
buffer.public void bindAsNormalBuffer(DrawContext dc)
Buffer
. This buffer's vector size must be 3.dc
- the current DrawContext
.java.lang.IllegalArgumentException
- if the DrawContext is null, or if this buffer is not compatible as a normal
buffer.public void bindAsTexCoordBuffer(DrawContext dc)
dc
- the current DrawContext.java.lang.IllegalArgumentException
- if the DrawContext is null, or if this buffer is not compatible as a normal
buffer.public void bindAsVertexBuffer(DrawContext dc)
dc
- the current DrawContext.java.lang.IllegalArgumentException
- if the DrawContext is null, or if this buffer is not compatible as a vertex
buffer.public VecBuffer copyOf(int newSize)
newSize
- the new buffer's size.public void drawArrays(DrawContext dc, int drawMode)
getSize()
elements from the currently bounds OpenGL coordinate buffers, beginning with
element 0. The specified drawMode indicates which type of OpenGL primitives to render.dc
- the current DrawContext.drawMode
- the type of OpenGL primtives to render.java.lang.IllegalArgumentException
- if the DrawContext is null.public static VecBuffer emptyVecBuffer(int coordsPerVec)
coordsPerVec
- the number of coordinates per logical vector.public double[] get(int position, double[] array)
position
- the logical vector position.array
- the destination array.java.lang.IllegalArgumentException
- if the position is out of range, or if the array is null.public BufferWrapper getBufferWrapper()
public java.lang.Iterable<double[]> getCoords()
public java.lang.Iterable<double[]> getCoords(int minCoordsPerVec)
minCoordsPerVec
- the minimum number of coordinates returned in each double[] array.public int getCoordsPerVec()
public float[] getFloat(int position, float[] array)
position
- the logical vector position.array
- the destination array.java.lang.IllegalArgumentException
- if the position is out of range, or if the array is null.public LatLon getLocation(int position)
LatLon
. This buffer's logical
vector size must be at least 2.position
- the logical vector position.java.lang.IllegalArgumentException
- if the position is out of range, or if this buffer cannot store a LatLon.public java.lang.Iterable<LatLon> getLocations()
public Position getPosition(int position)
Position
. This buffer's logical
vector size must be at least 2.position
- the logical vector position.java.lang.IllegalArgumentException
- if the position is out of range, or if this buffer cannot store a Position.public java.lang.Iterable<Position> getPositions()
public java.lang.Iterable<double[]> getReverseCoords(int minCoordsPerVec)
minCoordsPerVec
- the minimum number of coordinates returned in each double[] array.public java.lang.Iterable<LatLon> getReverseLocations()
public java.lang.Iterable<Position> getReversePositions()
public java.lang.Iterable<Vec4> getReverseVectors()
public int getSize()
public VecBuffer getSubBuffer(int position, int size)
position
- the new buffer's staring position, in logical vectors.size
- the new buffer's size, in logical vectors.public Vec4 getVector(int position)
Vec4
. This buffer's logical vector size must
be either 2, 3 or 4.position
- the logical vector position.java.lang.IllegalArgumentException
- if the position is out of range, or if this buffer cannot store a Vec4.public java.lang.Iterable<Vec4> getVectors()
protected int indexFromVectorPosition(int position)
position
- the vector position.public void put(int position, double[] array)
position
- the logical vector position.array
- the source array.java.lang.IllegalArgumentException
- if the position is out of range, or if the array is null.public void putAll(int position, double[] array, int count)
position
- the starting logical vector position.array
- the source array.count
- the number of logical arrays to set.java.lang.IllegalArgumentException
- if the position is out of range, if the array is null, or if the array has
insufficient length.public void putCoords(int position, java.lang.Iterable<double[]> iterable)
position
- the starting vector position to set.iterable
- iterator over the elements to set.java.lang.IllegalArgumentException
- if the position is out of range, or if the iterable is null.public void putFloat(int position, float[] array)
position
- the logical vector position.array
- the source array.java.lang.IllegalArgumentException
- if the position is out of range, or if the array is null.public void putLocation(int position, LatLon ll)
position
- the logical vector position.ll
- the geographic location to set.java.lang.IllegalArgumentException
- if the position is out of range, if the LatLon is null, or if this buffer cannot
store a LatLon.public void putLocations(int position, java.lang.Iterable<? extends LatLon> iterable)
position
- the starting vector position to set.iterable
- iterator over the elements to set.java.lang.IllegalArgumentException
- if the position is out of range, if the iterable is null, or if this buffer
cannot store a LatLon.public void putPosition(int position, Position p)
position
- the logical vector position.p
- the geographic Position to set.java.lang.IllegalArgumentException
- if the position is out of range, if the Position is null, or if this buffer
cannot store a Position.public void putPositions(int position, java.lang.Iterable<? extends Position> iterable)
position
- the starting vector position to set.iterable
- iterator over the elements to set.java.lang.IllegalArgumentException
- if the position is out of range, if the iterable is null, or if this buffer
cannot store a LatLon.public void putSubBuffer(int position, VecBuffer buffer)
position
- the starting vector position to set.buffer
- the input buffer.java.lang.IllegalArgumentException
- if the position is out of range, if the buffer is null or incompatible, or if
this buffer has insufficient length to store the sub-buffer at the specified
position.public void putSubBuffer(int position, VecBuffer buffer, int offset, int size)
position
- the starting vector position to set.buffer
- the input buffer.offset
- the vector position to start copying values from the specified buffer.size
- the number of vectors to read copy form the specified buffer.java.lang.IllegalArgumentException
- if the position is out of range, if the buffer is null or incompatible, if this
buffer has insufficient length to store the sub-buffer at the specified
position, or if the specified offset and size define a range outside of the
specified buffer.public void putVector(int position, Vec4 vec)
position
- the logical vector position.vec
- the vector to set.java.lang.IllegalArgumentException
- if the position is out of range, if the vector is null, or if this buffer cannot
store a Vec4.public void putVectors(int position, java.lang.Iterable<? extends Vec4> iterable)
position
- the starting vector position to set.iterable
- iterator over the elements to set.java.lang.IllegalArgumentException
- if the position is out of range, if the iterable is null, or if this buffer
cannot store a Vec4.protected int vectorPositionFromIndex(int index)
index
- the physical buffer index.