Package net.mtrop.doom.texture
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
-
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>
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Creates a new blank texture.CommonTexture
(String name) Creates a new texture. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(CommonTexture<?> o) abstract P
Creates a new patch entry on this texture, at the end of the list.int
getName()
getPatch
(int i) Gets a patch from this texture.int
int
getWidth()
iterator()
removePatch
(int i) Removes a patch entry from this texture by index.void
setHeight
(int height) Sets the height of this texture in pixels.void
setWidth
(int width) Sets the width of this texture in pixels.void
shiftPatch
(int index, int newIndex) Shifts the ordering of a patch on this texture.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.mtrop.doom.object.BinaryObject
fromBytes, readBytes, readFile, toBytes, writeBytes, writeFile, writeFile
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
name
Texture name. -
width
protected int widthWidth of texture. -
height
protected int heightHeight of texture. -
patches
List of patches.
-
-
Constructor Details
-
CommonTexture
protected CommonTexture()Creates a new blank texture. -
CommonTexture
Creates a new texture.- Parameters:
name
- the new texture name.- Throws:
IllegalArgumentException
- if the texture name is invalid.
-
-
Method Details
-
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
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
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
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
- Specified by:
iterator
in interfaceIterable<P extends CommonPatch>
-
compareTo
- Specified by:
compareTo
in interfaceComparable<P extends CommonPatch>
-