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
  • 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

      protected void addCreatedTexture(T texture)
      Adds a created texture to this texture list. Must be called from createTexture(String).
      Parameters:
      texture - the texture to add.
    • clear

      public void clear()
      Clears this list of textures.
    • indexOf

      public int indexOf(String name)
      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

      public T getTextureByIndex(int index)
      Gets a texture entry in this list by its index.
      Parameters:
      index - the index to use.
      Returns:
      a valid texture if found, or null if no texture at that index.
    • getTextureByName

      public T getTextureByName(String name)
      Gets 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.
    • remove

      public T remove(String name)
      Attempts to remove a texture entry by its name. Note that this will shift the indices of the other entries.
      Parameters:
      name - the name of the entry.
      Returns:
      true if removed, false if not.
    • removeIndex

      public T removeIndex(int index)
      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 null if no entry at that index.
    • sort

      public void sort()
      Sorts the textures in this texture list using natural ordering.
    • sort

      public void sort(Comparator<? super T> comp)
      Sorts the textures in this texture list using the provided comparator.
      Parameters:
      comp - the comparator to use.
    • createTexture

      public abstract T createTexture(String name)
      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

      public void writeBytes(OutputStream out) throws IOException
      Description copied from interface: BinaryObject
      Writes this object to an OutputStream.
      Specified by:
      writeBytes in interface BinaryObject
      Parameters:
      out - the OutputStream to write to.
      Throws:
      IOException - if a write error occurs.
    • iterator

      public Iterator<T> iterator()
      Specified by:
      iterator in interface Iterable<T extends CommonTexture<?>>
    • size

      public int size()
      Specified by:
      size in interface Sizable
      Returns:
      the amount of individual objects that this object contains.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Sizable
      Returns if this object contains no objects. The general policy of this method is that this returns true if and only if Sizable.size() returns 0.
      Specified by:
      isEmpty in interface Sizable
      Returns:
      true if so, false otherwise.