Class Attributes

    • Constructor Summary

      Constructors 
      Constructor Description
      Attributes()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int attributesHash()  
      void clear()
      Removes all attributes
      int compare​(Attribute arg0, Attribute arg1)
      Used for sorting attributes by type (not by value)
      int compareTo​(Attributes other)  
      boolean equals​(java.lang.Object other)  
      Attribute get​(long type)
      Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;
      Array<Attribute> get​(Array<Attribute> out, long type)
      Get multiple attributes at once.
      <T extends Attribute>
      T
      get​(java.lang.Class<T> clazz, long type)
      Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;
      long getMask()  
      boolean has​(long type)  
      int hashCode()  
      protected int indexOf​(long type)  
      java.util.Iterator<Attribute> iterator()
      Used for iterating through the attributes
      void remove​(long mask)
      Removes the attribute from the material, i.e.: material.remove(BlendingAttribute.ID); Can also be used to remove multiple attributes also, i.e.
      boolean same​(Attributes other)
      boolean same​(Attributes other, boolean compareValues)
      Check if this collection has the same attributes as the other collection.
      void set​(Attribute attribute)
      Add a attribute to this material.
      void set​(Attribute... attributes)
      Add an array of attributes to this material.
      void set​(Attribute attribute1, Attribute attribute2)
      Add multiple attributes to this material.
      void set​(Attribute attribute1, Attribute attribute2, Attribute attribute3)
      Add multiple attributes to this material.
      void set​(Attribute attribute1, Attribute attribute2, Attribute attribute3, Attribute attribute4)
      Add multiple attributes to this material.
      void set​(java.lang.Iterable<Attribute> attributes)
      Add an array of attributes to this material.
      int size()  
      void sort()
      Sort the attributes by their ID
      • Methods 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 Detail

      • mask

        protected long mask
      • sorted

        protected boolean sorted
    • Constructor Detail

      • Attributes

        public Attributes()
    • Method Detail

      • sort

        public final void sort()
        Sort the attributes by their ID
      • getMask

        public final long getMask()
        Returns:
        Bitwise mask of the ID's of all the containing attributes
      • get

        public final Attribute get​(long type)
        Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;
        Returns:
        The attribute (which can safely be cast) if any, otherwise null
      • get

        public final <T extends Attribute> T get​(java.lang.Class<T> clazz,
                                                 long type)
        Example usage: ((BlendingAttribute)material.get(BlendingAttribute.ID)).sourceFunction;
        Returns:
        The attribute if any, otherwise null
      • get

        public final Array<Attribute> get​(Array<Attribute> out,
                                          long type)
        Get multiple attributes at once. Example: material.get(out, ColorAttribute.Diffuse | ColorAttribute.Specular | TextureAttribute.Diffuse);
      • clear

        public void clear()
        Removes all attributes
      • size

        public int size()
        Returns:
        The amount of attributes this material contains.
      • set

        public final void set​(Attribute attribute)
        Add a attribute to this material. If the material already contains an attribute of the same type it is overwritten.
      • set

        public final void set​(Attribute attribute1,
                              Attribute attribute2)
        Add multiple attributes to this material. If the material already contains an attribute of the same type it is overwritten.
      • set

        public final void set​(Attribute attribute1,
                              Attribute attribute2,
                              Attribute attribute3)
        Add multiple attributes to this material. If the material already contains an attribute of the same type it is overwritten.
      • set

        public final void set​(Attribute attribute1,
                              Attribute attribute2,
                              Attribute attribute3,
                              Attribute attribute4)
        Add multiple attributes to this material. If the material already contains an attribute of the same type it is overwritten.
      • set

        public final void set​(Attribute... attributes)
        Add an array of attributes to this material. If the material already contains an attribute of the same type it is overwritten.
      • set

        public final void set​(java.lang.Iterable<Attribute> attributes)
        Add an array of attributes to this material. If the material already contains an attribute of the same type it is overwritten.
      • remove

        public final void remove​(long mask)
        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);
      • has

        public final boolean has​(long type)
        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);
      • indexOf

        protected int indexOf​(long type)
        Returns:
        the index of the attribute with the specified type or negative if not available.
      • same

        public final boolean same​(Attributes other,
                                  boolean compareValues)
        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

        public final boolean same​(Attributes other)
        Returns:
        True if this collection contains the same attributes (but not values) as the other.
      • compare

        public final int compare​(Attribute arg0,
                                 Attribute arg1)
        Used for sorting attributes by type (not by value)
        Specified by:
        compare in interface java.util.Comparator<Attribute>
      • iterator

        public final java.util.Iterator<Attribute> iterator()
        Used for iterating through the attributes
        Specified by:
        iterator in interface java.lang.Iterable<Attribute>
      • 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

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object other)
        Specified by:
        equals in interface java.util.Comparator<Attribute>
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(Attributes other)
        Specified by:
        compareTo in interface java.lang.Comparable<Attributes>