Class Attributes
java.lang.Object
gaiasky.util.gdx.shader.attribute.Attributes
- All Implemented Interfaces:
Comparable<Attributes>
,Iterable<Attribute>
,Comparator<Attribute>
- Direct Known Subclasses:
Environment
,Material
public class Attributes
extends Object
implements Iterable<Attribute>, Comparator<Attribute>, Comparable<Attributes>
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
void
clear()
Removes all attributesfinal int
Used for sorting attributes by type (not by value)int
compareTo
(Attributes other) boolean
final Attribute
get
(int index) Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;final <T extends Attribute>
TExample usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;final Bits
getMask()
final boolean
has
(int index) final boolean
int
hashCode()
protected int
indexOf
(int index) iterator()
Used for iterating through the attributesfinal void
remove
(int index) final void
Removes the attribute from the material, i.e.: material.remove(BlendingAttribute.ID); Can also be used to remove multiple attributes also, i.e.final boolean
same
(Attributes other) final boolean
same
(Attributes other, boolean compareValues) Check if this collection has the same attributes as the other collection.final void
Add an attribute to this material.final void
Add an array of attributes to this material.final void
Add multiple attributes to this material.final void
Add multiple attributes to this material.final void
Add multiple attributes to this material.final void
Add an array of attributes to this material.int
size()
final void
sort()
Sort the attributes by their IDMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
attributes
-
mask
-
sorted
protected boolean sorted
-
-
Constructor Details
-
Attributes
public Attributes()
-
-
Method Details
-
sort
public final void sort()Sort the attributes by their ID -
getMask
- Returns:
- Bitwise mask of the ID's of all the containing attributes
-
get
Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;- Returns:
- The attribute (which can safely be cast) if any, otherwise null
-
get
-
clear
public void clear()Removes all attributes -
size
public int size()- Returns:
- The amount of attributes this material contains.
-
set
Add an attribute to this material. If the material already contains an attribute of the same type it is overwritten. -
set
-
set
-
set
-
set
Add an array of attributes to this material. If the material already contains an attribute of the same type it is overwritten. -
set
-
remove
Removes the attribute from the material, i.e.: material.remove(BlendingAttribute.ID); Can also be used to remove multiple attributes also, i.e. remove(AttributeA.ID | AttributeB.ID); -
remove
public final void remove(int index) -
has
- Returns:
- True if this collection has the specified attribute, i.e. attributes.has(ColorAttribute.Diffuse); Or when multiple attribute types are specified, true if this collection has all specified attributes, i.e. attributes.has(out, ColorAttribute.Diffuse | ColorAttribute.Specular | TextureAttribute.Diffuse);
-
has
public final boolean has(int index) -
indexOf
protected int indexOf(int index) - Returns:
- the index of the attribute with the specified type or negative if not available.
-
same
Check if this collection has the same attributes as the other collection. If compareValues is true, it also compares the values of each attribute.- Parameters:
compareValues
- True to compare attribute values, false to only compare attribute types- Returns:
- True if this collection contains the same attributes (and optionally attribute values) as the other.
-
same
- Returns:
- True if this collection contains the same attributes (but not values) as the other.
-
compare
Used for sorting attributes by type (not by value)- Specified by:
compare
in interfaceComparator<Attribute>
-
iterator
-
attributesHash
public int attributesHash()- Returns:
- A hash code based on only the attribute values, which might be different compared to
hashCode()
because the latter might include other properties as well, i.e. the material id.
-
hashCode
-
equals
-
compareTo
- Specified by:
compareTo
in interfaceComparable<Attributes>
-