Class TackboardItem

  • All Implemented Interfaces:
    java.lang.Comparable<TackboardItem>
    Direct Known Subclasses:
    Bitmap

    public class TackboardItem
    extends java.lang.Object
    implements java.lang.Comparable<TackboardItem>
    TackboardItem class represents a single item that can generate pixels on the tackboard.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected boolean dirty
      Dirty flag, if true then getImage() needs to generate a rendering aligned to the text cells.
    • Constructor Summary

      Constructors 
      Constructor Description
      TackboardItem()
      Public constructor.
      TackboardItem​(int x, int y, int z)
      Public constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(TackboardItem that)
      Comparison operator.
      boolean equals​(java.lang.Object rhs)
      Comparison check.
      java.awt.image.BufferedImage getImage​(int textWidth, int textHeight)
      Get this item rendered to a bitmap, offset to align on a grid of cells with pixel dimensions (textWidth, textHeight).
      int getX()
      Get X position.
      int getY()
      Get Y position.
      int getZ()
      Get Z position.
      int hashCode()
      Hashcode uses all fields in equals().
      boolean isDirty()
      Get dirty flag.
      void remove()
      Remove this item from its board.
      void setDirty()
      Set dirty flag.
      void setTackboard​(Tackboard tackboard)
      Set the tackboard this item is on.
      void setX​(int x)
      Set X position.
      void setY​(int y)
      Set Y position.
      void setZ​(int z)
      Set Z position.
      java.lang.String toString()
      Make human-readable description of this item.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • dirty

        protected boolean dirty
        Dirty flag, if true then getImage() needs to generate a rendering aligned to the text cells.
    • Constructor Detail

      • TackboardItem

        public TackboardItem​(int x,
                             int y,
                             int z)
        Public constructor.
        Parameters:
        x - X pixel coordinate
        y - Y pixel coordinate
        z - Z coordinate
      • TackboardItem

        public TackboardItem()
        Public constructor.
    • Method Detail

      • getX

        public final int getX()
        Get X position.
        Returns:
        absolute X position of the top-left corner in pixels
      • setX

        public final void setX​(int x)
        Set X position.
        Parameters:
        x - absolute X position of the top-left corner in pixels
      • getY

        public final int getY()
        Get Y position.
        Returns:
        absolute Y position of the top-left corner in pixels
      • setY

        public final void setY​(int y)
        Set Y position.
        Parameters:
        y - absolute Y position of the top-left corner in pixels
      • getZ

        public final int getZ()
        Get Z position.
        Returns:
        absolute Z position
      • setZ

        public final void setZ​(int z)
        Set Z position.
        Parameters:
        z - absolute Z position
      • isDirty

        public final boolean isDirty()
        Get dirty flag.
        Returns:
        if true, the image data is not aligned with the physical screen cells
      • setDirty

        public final void setDirty()
        Set dirty flag.
      • setTackboard

        public final void setTackboard​(Tackboard tackboard)
        Set the tackboard this item is on.
        Parameters:
        tackboard -
      • equals

        public boolean equals​(java.lang.Object rhs)
        Comparison check. All fields must match to return true.
        Overrides:
        equals in class java.lang.Object
        Parameters:
        rhs - another TackboardItem instance
        Returns:
        true if all fields are equal
      • hashCode

        public int hashCode()
        Hashcode uses all fields in equals().
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        the hash
      • compareTo

        public int compareTo​(TackboardItem that)
        Comparison operator.
        Specified by:
        compareTo in interface java.lang.Comparable<TackboardItem>
        Parameters:
        that - another TackboardItem instance
        Returns:
        differences between this.x/y/z and that.x/y/z
      • toString

        public java.lang.String toString()
        Make human-readable description of this item.
        Overrides:
        toString in class java.lang.Object
        Returns:
        displayable String
      • getImage

        public java.awt.image.BufferedImage getImage​(int textWidth,
                                                     int textHeight)
        Get this item rendered to a bitmap, offset to align on a grid of cells with pixel dimensions (textWidth, textHeight).
        Parameters:
        textWidth - the width of a text cell
        textHeight - the height of a text cell
        Returns:
        the image, or null if this item does not have any pixels to show
      • remove

        public void remove()
        Remove this item from its board. Subclasses can use this for cleanup also.