Class CommonTexture<P extends CommonPatch>

java.lang.Object
net.mtrop.doom.texture.CommonTexture<P>
Type Parameters:
P - the contained CommonPatch type.
All Implemented Interfaces:
Comparable<CommonTexture<?>>, Iterable<P>, BinaryObject
Direct Known Subclasses:
DoomTextureList.Texture, StrifeTextureList.Texture

public abstract class CommonTexture<P extends CommonPatch> extends Object implements BinaryObject, Iterable<P>, Comparable<CommonTexture<?>>
Common contents of texture definitions.
Author:
Matthew Tropiano
  • Field Details

    • name

      protected String name
      Texture name.
    • width

      protected int width
      Width of texture.
    • height

      protected int height
      Height of texture.
    • patches

      protected List<P extends CommonPatch> patches
      List of patches.
  • Constructor Details

    • CommonTexture

      protected CommonTexture()
      Creates a new blank texture.
    • CommonTexture

      public CommonTexture(String name)
      Creates a new texture.
      Parameters:
      name - the new texture name.
      Throws:
      IllegalArgumentException - if the texture name is invalid.
  • Method Details

    • getName

      public String getName()
      Returns:
      the name of this texture.
    • getWidth

      public int getWidth()
      Returns:
      the width of this texture in pixels.
    • setWidth

      public void setWidth(int width)
      Sets the width of this texture in pixels.
      Parameters:
      width - the new texture width.
      Throws:
      IllegalArgumentException - if the width is outside the range 0 to 65535.
    • getHeight

      public int getHeight()
      Returns:
      the height of this texture in pixels.
    • setHeight

      public void setHeight(int height)
      Sets the height of this texture in pixels.
      Parameters:
      height - the new texture height.
      Throws:
      IllegalArgumentException - if the height is outside the range 0 to 65535.
    • createPatch

      public abstract P createPatch()
      Creates a new patch entry on this texture, at the end of the list. The patch has no information set on it, including its name index value and offsets.
      Returns:
      a newly-added Patch object.
    • shiftPatch

      public void shiftPatch(int index, int newIndex)
      Shifts the ordering of a patch on this texture. The ordering of the patches in this texture will change depending on the indexes provided.
      Parameters:
      index - the index to shift.
      newIndex - the destination index.
    • removePatch

      public P removePatch(int i)
      Removes a patch entry from this texture by index. The ordering of the patches in this texture will change depending on the index provided.
      Parameters:
      i - the index of the patch to remove.
      Returns:
      the patch removed, or null if no patch at that index.
    • getPatch

      public P getPatch(int i)
      Gets a patch from this texture.
      Parameters:
      i - the index of the patch.
      Returns:
      the corresponding patch, or null if no patch at that index.
    • getPatchCount

      public int getPatchCount()
      Returns:
      the amount of patches on this texture.
    • iterator

      public Iterator<P> iterator()
      Specified by:
      iterator in interface Iterable<P extends CommonPatch>
    • compareTo

      public int compareTo(CommonTexture<?> o)
      Specified by:
      compareTo in interface Comparable<P extends CommonPatch>