-
- All Implemented Interfaces:
-
it.unibo.alchemist.boundary.gui.effects.EffectFX,it.unibo.alchemist.boundary.gui.effects.EffectGroup,java.io.Serializable,java.lang.Iterable,java.util.Collection,java.util.Queue
public final class EffectStack<P extends Position2D<out P>> implements EffectGroup<P>
The class models a group of effects, stored as a stack. It can manage priority of visualization and visibility of each effect inside it.
-
-
Field Summary
Fields Modifier and Type Field Description private Stringnameprivate booleanvisibility
-
Constructor Summary
Constructors Constructor Description EffectStack()Constructor that creates an empty stack of effects with default name. EffectStack(String name)Default constructor.
-
Method Summary
Modifier and Type Method Description StringgetName()Gets the name of the effect. voidsetName(String name)Sets the name of the effect. voidsetVisibility(boolean visibility)Sets the visibility of the effect. <T> Queue<DrawCommand<P>>computeDrawCommands(Environment<T, P> environment)Computes a queue of commands to Draw something. EffectFX<P>push(EffectFX<P> effect)Puts the effects in the group, giving it the maximum priority. EffectFX<P>pop()Removes the effect with maximum priority and returns it. intsearch(EffectFX<P> effect)Checks if an effect is present in the group. booleangetVisibilityOf(EffectFX<P> effect)Returns the visibility of the specified effect. voidsetVisibilityOf(EffectFX<P> effect, boolean visibility)Sets the visibility of the specified effect. voidchangePriority(EffectFX<P> effect, int offset)Changes the specified offset priority of the specified offset. booleanisVisible()Gets the visibility of the effect. Iterator<EffectFX<P>>iterator()intsize()booleancontains(Object o)Array<Object>toArray()<T> Array<T>toArray(Array<T> a)booleanadd(EffectFX<P> e)booleanremove(Object o)EffectFX<P>remove()booleancontainsAll(Collection<out Object> c)booleanaddAll(Collection<out EffectFX<P>> c)booleanremoveAll(Collection<out Object> c)booleanretainAll(Collection<out Object> c)voidclear()booleanoffer(EffectFX<P> e)EffectFX<P>poll()EffectFX<P>peek()Returns the effect with maximum priority, without removing it. EffectFX<P>element()booleanisEmpty()inthashCode()booleanequals(Object obj)static EffectGroupAdaptergetTypeAdapter()Returns a com.google.gson.JsonSerializer and com.google.gson.JsonDeserializer combo class to be used as a TypeAdapterfor thisEffectStack.-
Methods inherited from class java.util.Collection
parallelStream, removeIf, spliterator, stream -
Methods inherited from class java.lang.Iterable
forEach, iterator, spliterator -
Methods inherited from class it.unibo.alchemist.boundary.gui.effects.EffectFX
setName, setVisibility -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
EffectStack
EffectStack()
Constructor that creates an empty stack of effects with default name.
-
EffectStack
EffectStack(String name)
Default constructor.- Parameters:
name- the name of the group
-
-
Method Detail
-
setName
void setName(String name)
Sets the name of the effect.
- Parameters:
name- the name of the effect to set
-
setVisibility
void setVisibility(boolean visibility)
Sets the visibility of the effect.
- Parameters:
visibility- the visibility of the effect to set
-
computeDrawCommands
<T> Queue<DrawCommand<P>> computeDrawCommands(Environment<T, P> environment)
Computes a queue of commands to Draw something.
- Parameters:
environment- the environment to gather data from
-
push
EffectFX<P> push(EffectFX<P> effect)
Puts the effects in the group, giving it the maximum priority.
- Parameters:
effect- the effect
-
search
int search(EffectFX<P> effect)
Checks if an effect is present in the group.
- Parameters:
effect- the effect to search
-
getVisibilityOf
boolean getVisibilityOf(EffectFX<P> effect)
Returns the visibility of the specified effect.
- Parameters:
effect- the effect
-
setVisibilityOf
void setVisibilityOf(EffectFX<P> effect, boolean visibility)
Sets the visibility of the specified effect.
- Parameters:
effect- the effectvisibility- the visibility to set
-
changePriority
void changePriority(EffectFX<P> effect, int offset)
Changes the specified offset priority of the specified offset.
- Parameters:
effect- the effectoffset- the offset; it can be positive or negative
-
isVisible
boolean isVisible()
Gets the visibility of the effect.
-
size
int size()
-
containsAll
boolean containsAll(Collection<out Object> c)
-
addAll
boolean addAll(Collection<out EffectFX<P>> c)
-
removeAll
boolean removeAll(Collection<out Object> c)
-
retainAll
boolean retainAll(Collection<out Object> c)
-
clear
void clear()
-
isEmpty
boolean isEmpty()
-
hashCode
int hashCode()
-
getTypeAdapter
@Nonnull() static EffectGroupAdapter getTypeAdapter()
Returns a com.google.gson.JsonSerializer and com.google.gson.JsonDeserializer combo class to be used as a
TypeAdapterfor thisEffectStack.
-
-
-
-