Package jexer.tackboard
Class TackboardItem
- java.lang.Object
-
- jexer.tackboard.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 booleandirtyDirty 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 intcompareTo(TackboardItem that)Comparison operator.booleanequals(java.lang.Object rhs)Comparison check.java.awt.image.BufferedImagegetImage(int textWidth, int textHeight)Get this item rendered to a bitmap, offset to align on a grid of cells with pixel dimensions (textWidth, textHeight).intgetX()Get X position.intgetY()Get Y position.intgetZ()Get Z position.inthashCode()Hashcode uses all fields in equals().booleanisDirty()Get dirty flag.voidremove()Remove this item from its board.voidsetDirty()Set dirty flag.voidsetTackboard(Tackboard tackboard)Set the tackboard this item is on.voidsetX(int x)Set X position.voidsetY(int y)Set Y position.voidsetZ(int z)Set Z position.java.lang.StringtoString()Make human-readable description of this item.
-
-
-
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- the tackboard
-
equals
public boolean equals(java.lang.Object rhs)
Comparison check. All fields must match to return true.- Overrides:
equalsin classjava.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:
hashCodein classjava.lang.Object- Returns:
- the hash
-
compareTo
public int compareTo(TackboardItem that)
Comparison operator.- Specified by:
compareToin interfacejava.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:
toStringin classjava.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 celltextHeight- 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.
-
-