Class CommonTextureList<T extends CommonTexture<?>>
java.lang.Object
net.mtrop.doom.texture.CommonTextureList<T>
- Type Parameters:
T- the contained CommonTexture type.
- All Implemented Interfaces:
Iterable<T>,BinaryObject,Sizable
- Direct Known Subclasses:
DoomTextureList,StrifeTextureList
public abstract class CommonTextureList<T extends CommonTexture<?>>
extends Object
implements BinaryObject, Iterable<T>, Sizable
This is the lump that contains a collection of textures.
All textures are stored in here, usually named TEXTURE1 or TEXTURE2 in a WAD.
Most creation methods in this object are factory-style, due to the diversity of implemented texture formats.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject> -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new TextureList with a default starting capacity.CommonTextureList(int capacity) Creates a new TextureList with a specific starting capacity. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCreatedTexture(T texture) Adds a created texture to this texture list.voidclear()Clears this list of textures.abstract TcreateTexture(String name) Creates a new texture in this list with no patches, at the end of the list.getTextureByIndex(int index) Gets a texture entry in this list by its index.getTextureByName(String name) Gets a texture in this list by its name.intGets the index of a texture in this list by its name.booleanisEmpty()Returns if this object contains no objects.iterator()Attempts to remove a texture entry by its name.removeIndex(int index) Removes a texture entry at an index.intsize()voidsort()Sorts the textures in this texture list using natural ordering.voidsort(Comparator<? super T> comp) Sorts the textures in this texture list using the provided comparator.voidwriteBytes(OutputStream out) Writes this object to anOutputStream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.mtrop.doom.object.BinaryObject
fromBytes, readBytes, readFile, toBytes, writeFile, writeFileMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
CommonTextureList
public CommonTextureList()Creates a new TextureList with a default starting capacity. -
CommonTextureList
public CommonTextureList(int capacity) Creates a new TextureList with a specific starting capacity.- Parameters:
capacity- the starting capacity.
-
-
Method Details
-
addCreatedTexture
Adds a created texture to this texture list. Must be called fromcreateTexture(String).- Parameters:
texture- the texture to add.
-
clear
public void clear()Clears this list of textures. -
indexOf
Gets the index of a texture in this list by its name.- Parameters:
name- the name of the texture.- Returns:
- a valid index if found, or -1 if not.
-
getTextureByIndex
Gets a texture entry in this list by its index.- Parameters:
index- the index to use.- Returns:
- a valid texture if found, or
nullif no texture at that index.
-
getTextureByName
-
remove
-
removeIndex
Removes a texture entry at an index. Note that this will shift the indices of the other entries.- Parameters:
index- the index to use.- Returns:
- the entry removed, or
nullif no entry at that index.
-
sort
public void sort()Sorts the textures in this texture list using natural ordering. -
sort
Sorts the textures in this texture list using the provided comparator.- Parameters:
comp- the comparator to use.
-
createTexture
Creates a new texture in this list with no patches, at the end of the list.- Parameters:
name- the name of the texture.- Returns:
- a new, empty texture object added to this list.
- Throws:
IllegalArgumentException- if the provided name is not a valid name for a texture.- See Also:
-
writeBytes
Description copied from interface:BinaryObjectWrites this object to anOutputStream.- Specified by:
writeBytesin interfaceBinaryObject- Parameters:
out- theOutputStreamto write to.- Throws:
IOException- if a write error occurs.
-
iterator
-
size
-
isEmpty
public boolean isEmpty()Description copied from interface:SizableReturns if this object contains no objects. The general policy of this method is that this returns true if and only ifSizable.size()returns 0.
-