Class ImageEffect

All Implemented Interfaces:
ITimeToLive, Comparable<ImageEffect>
Direct Known Subclasses:
CreatureShadowImageEffect, OverlayPixelsImageEffect, RotationImageEffect, TransparencyImageEffect

public abstract class ImageEffect extends Object implements ITimeToLive, Comparable<ImageEffect>
Represents an abstract image effect that can be applied to a BufferedImage. Implements ITimeToLive and Comparable interfaces.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    ImageEffect(int ttl, String name)
    Constructs a new ImageEffect with the specified time-to-live and name.
    protected
    Constructs a new ImageEffect with the specified name and a time-to-live of 0.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract BufferedImage
    Applies this image effect to the specified BufferedImage.
    int
    Compares this image effect with another image effect based on their priority.
    boolean
    Checks if this image effect is equal to another object.
    long
    Gets the time in milliseconds that this effect has been alive.
    Gets the name of this image effect.
    int
    Gets the priority of this image effect.
    int
    Gets the time-to-live of this image effect in milliseconds.
    int
    Returns the hash code of this image effect.
    void
    Sets the name of this image effect.
    void
    setPriority(int priority)
    Sets the priority of this image effect.
    boolean
    Checks if the time-to-live of this image effect has been reached.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ImageEffect

      protected ImageEffect(String name)
      Constructs a new ImageEffect with the specified name and a time-to-live of 0.
      Parameters:
      name - the name of the image effect
    • ImageEffect

      protected ImageEffect(int ttl, String name)
      Constructs a new ImageEffect with the specified time-to-live and name.
      Parameters:
      ttl - the time-to-live of the image effect in milliseconds
      name - the name of the image effect
  • Method Details

    • getAliveTime

      public long getAliveTime()
      Gets the time in milliseconds that this effect has been alive.
      Specified by:
      getAliveTime in interface ITimeToLive
      Returns:
      the alive time in milliseconds
    • getName

      public String getName()
      Gets the name of this image effect.
      Returns:
      the name of the image effect
    • setName

      public void setName(String name)
      Sets the name of this image effect.
      Parameters:
      name - the new name of the image effect
    • getTimeToLive

      public int getTimeToLive()
      Gets the time-to-live of this image effect in milliseconds.
      Specified by:
      getTimeToLive in interface ITimeToLive
      Returns:
      the time-to-live in milliseconds
    • timeToLiveReached

      public boolean timeToLiveReached()
      Checks if the time-to-live of this image effect has been reached.
      Specified by:
      timeToLiveReached in interface ITimeToLive
      Returns:
      true if the time-to-live has been reached, false otherwise
    • getPriority

      public int getPriority()
      Gets the priority of this image effect.
      Returns:
      the priority of the image effect
    • setPriority

      public void setPriority(int priority)
      Sets the priority of this image effect.
      Parameters:
      priority - the new priority of the image effect
    • compareTo

      public int compareTo(ImageEffect other)
      Compares this image effect with another image effect based on their priority.
      Specified by:
      compareTo in interface Comparable<ImageEffect>
      Parameters:
      other - the other image effect to compare to
      Returns:
      a negative integer, zero, or a positive integer as this image effect's priority is less than, equal to, or greater than the other image effect's priority
    • equals

      public boolean equals(Object obj)
      Checks if this image effect is equal to another object. Two image effects are considered equal if they have the same name and priority.
      Overrides:
      equals in class Object
      Parameters:
      obj - the object to compare to
      Returns:
      true if the objects are equal, false otherwise
    • hashCode

      public int hashCode()
      Returns the hash code of this image effect.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code of the image effect
    • apply

      public abstract BufferedImage apply(BufferedImage image)
      Applies this image effect to the specified BufferedImage.
      Parameters:
      image - the BufferedImage to apply the effect to
      Returns:
      the BufferedImage with the effect applied