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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintvoidclear()Removes all attributesfinal intUsed for sorting attributes by type (not by value)intcompareTo(Attributes other) booleanfinal Attributeget(int index) Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;final <T extends Attribute>
TExample usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;final BitsgetMask()final booleanhas(int index) final booleaninthashCode()protected intindexOf(int index) iterator()Used for iterating through the attributesfinal voidremove(int index) final voidRemoves the attribute from the material, i.e.: material.remove(BlendingAttribute.ID); Can also be used to remove multiple attributes also, i.e.final booleansame(Attributes other) final booleansame(Attributes other, boolean compareValues) Check if this collection has the same attributes as the other collection.final voidAdd an attribute to this material.final voidAdd an array of attributes to this material.final voidAdd multiple attributes to this material.final voidAdd multiple attributes to this material.final voidAdd multiple attributes to this material.final voidAdd an array of attributes to this material.intsize()final voidsort()Sort the attributes by their IDMethods inherited from class Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLongMethods inherited from interface 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:
comparein 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:
compareToin interfaceComparable<Attributes>
-