Package jexer.bits
Class Cell
- java.lang.Object
-
- jexer.bits.CellAttributes
-
- jexer.bits.Cell
-
public class Cell extends CellAttributes
This class represents a single text cell or bit of image on the screen.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Cell.Width
How this cell needs to be displayed if it is part of a larger glyph.
-
Constructor Summary
Constructors Constructor Description Cell()
Public constructor sets default values of the cell to blank.Cell(int ch)
Public constructor sets the character.Cell(int ch, CellAttributes attr)
Public constructor sets the character and attributes.Cell(Cell cell)
Public constructor creates a duplicate.Cell(CellAttributes attr)
Public constructor sets the attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object rhs)
Comparison check.void
flattenImage(boolean overGlyph, Backend backend)
Flatten the image on this cell by rendering it either onto the background color, or generating the glyph and rendering over that.int
getChar()
Getter for cell character.java.awt.image.BufferedImage
getImage()
Get the image data for this cell.java.awt.image.BufferedImage
getImage(boolean copy)
Get the image data for this cell.int
getImageId()
Get the image ID.Cell.Width
getWidth()
Getter for cell width.int
hashCode()
Hashcode uses all fields in equals().void
invertImage()
Invert the image in this cell, if it has one.boolean
isBlank()
Check to see if this cell has default attributes: white foreground, black background, no bold/blink/reverse/underline/protect, and a character value of ' ' (space).boolean
isCacheable()
If true, this cell can be placed in a glyph cache somewhere so that it does not have to be re-rendered many times.boolean
isFullyTransparentImage()
If true, this cell has image data and all of its pixels are fully transparent (alpha of 0).boolean
isImage()
If true, this cell has image data.boolean
isInvertedImage()
If true, this cell has image data, and that data is inverted.boolean
isTransparentImage()
If true, this cell has image data and some of the pixels are transparent.void
mixImageId(int operation)
"Mix" the imageId of another operation into this cell.void
mixImageId(Cell other)
"Mix" the imageId of another Cell into this cell.void
reset()
Reset this cell to a blank.void
restoreImage()
Restore the image in this cell to its normal version, if it has one.void
setAttr(CellAttributes that)
Set my field attr values to that's field.void
setAttr(CellAttributes that, boolean keepImage)
Set my field attr values to that's field.void
setChar(int ch)
Setter for cell character.void
setImage(java.awt.image.BufferedImage image)
Set the image data for this cell.void
setImage(java.awt.image.BufferedImage image, int imageId)
Set the image data for this cell.void
setImageId(int imageId)
Set the image ID.void
setOpaqueImage()
Force calls to isTransparentImage() to always return false.void
setTo(java.lang.Object rhs)
Set my field values to that's field.void
setWidth(Cell.Width width)
Setter for cell width.java.lang.String
toHtml()
Convert this cell into an HTML entity inside a <font> tag.java.lang.String
toString()
Make human-readable description of this Cell.void
unset()
UNset this cell.-
Methods inherited from class jexer.bits.CellAttributes
getAnimations, getBackColor, getBackColorRGB, getForeColor, getForeColorPulseRGB, getForeColorRGB, getPulseColorRGB, isBlink, isBold, isProtect, isPulse, isReverse, isRGB, isUnderline, setAnimations, setBackColor, setBackColorRGB, setBlink, setBold, setForeColor, setForeColorRGB, setProtect, setPulse, setPulseColorRGB, setReverse, setUnderline
-
-
-
-
Constructor Detail
-
Cell
public Cell()
Public constructor sets default values of the cell to blank.
-
Cell
public Cell(int ch)
Public constructor sets the character. Attributes are the same as default.- Parameters:
ch
- character to set to- See Also:
reset()
-
Cell
public Cell(CellAttributes attr)
Public constructor sets the attributes.- Parameters:
attr
- attributes to use
-
Cell
public Cell(int ch, CellAttributes attr)
Public constructor sets the character and attributes.- Parameters:
ch
- character to set toattr
- attributes to use
-
Cell
public Cell(Cell cell)
Public constructor creates a duplicate.- Parameters:
cell
- the instance to copy
-
-
Method Detail
-
setImage
public void setImage(java.awt.image.BufferedImage image)
Set the image data for this cell.- Parameters:
image
- the image for this cell
-
setImage
public void setImage(java.awt.image.BufferedImage image, int imageId)
Set the image data for this cell.- Parameters:
image
- the image for this cellimageId
- the ID for this image
-
getImage
public java.awt.image.BufferedImage getImage()
Get the image data for this cell.- Returns:
- the image for this cell
-
getImage
public java.awt.image.BufferedImage getImage(boolean copy)
Get the image data for this cell.- Parameters:
copy
- if true, return a copy of the image- Returns:
- the image for this cell
-
setImageId
public void setImageId(int imageId)
Set the image ID.- Parameters:
imageId
- the ID, a positive integer
-
getImageId
public int getImageId()
Get the image ID.- Returns:
- the ID, or 0 if not set
-
mixImageId
public void mixImageId(Cell other)
"Mix" the imageId of another Cell into this cell. When two cells both have imageId's set, the mixture of them should be a deterministic combination such that one can compare a sequence of "mixed" cells and know (within a high degree of likelihood) that they produced the same final image.- Parameters:
other
- the other cell
-
mixImageId
public void mixImageId(int operation)
"Mix" the imageId of another operation into this cell. When a cell has its imageId set, the mixture of it and other operations should be a deterministic combination such that one can compare a sequence of cell + operations and know (within a high degree of likelihood) that they produced the same final image.- Parameters:
operation
- the operation to mix in, typically a color translucent RGB that was blitted over or under this image
-
flattenImage
public void flattenImage(boolean overGlyph, Backend backend)
Flatten the image on this cell by rendering it either onto the background color, or generating the glyph and rendering over that.- Parameters:
overGlyph
- if true, render over the glyphbackend
- the backend that can obtain the correct background color
-
isImage
public boolean isImage()
If true, this cell has image data.- Returns:
- true if this cell is an image rather than a character with attributes
-
isTransparentImage
public boolean isTransparentImage()
If true, this cell has image data and some of the pixels are transparent.- Returns:
- true if this cell has image data with transparent pixels
-
isFullyTransparentImage
public boolean isFullyTransparentImage()
If true, this cell has image data and all of its pixels are fully transparent (alpha of 0).- Returns:
- true if this cell has image data with only transparent pixels
-
setOpaqueImage
public void setOpaqueImage()
Force calls to isTransparentImage() to always return false.
-
restoreImage
public void restoreImage()
Restore the image in this cell to its normal version, if it has one.
-
isInvertedImage
public boolean isInvertedImage()
If true, this cell has image data, and that data is inverted.- Returns:
- true if this cell is an image rather than a character with attributes, and the data is inverted
-
invertImage
public void invertImage()
Invert the image in this cell, if it has one.
-
getChar
public int getChar()
Getter for cell character.- Returns:
- cell character
-
setChar
public void setChar(int ch)
Setter for cell character.- Parameters:
ch
- new cell character
-
getWidth
public Cell.Width getWidth()
Getter for cell width.- Returns:
- Width.SINGLE, Width.LEFT, or Width.RIGHT
-
setWidth
public void setWidth(Cell.Width width)
Setter for cell width.- Parameters:
width
- new cell width, one of Width.SINGLE, Width.LEFT, or Width.RIGHT
-
reset
public void reset()
Reset this cell to a blank.- Overrides:
reset
in classCellAttributes
-
unset
public void unset()
UNset this cell. It will not be equal to any other cell until it has been assigned attributes and a character.
-
isBlank
public boolean isBlank()
Check to see if this cell has default attributes: white foreground, black background, no bold/blink/reverse/underline/protect, and a character value of ' ' (space).- Returns:
- true if this cell has default attributes.
-
isCacheable
public boolean isCacheable()
If true, this cell can be placed in a glyph cache somewhere so that it does not have to be re-rendered many times.- Returns:
- true if this cell can be placed in a cache
-
equals
public boolean equals(java.lang.Object rhs)
Comparison check. All fields must match to return true.- Overrides:
equals
in classCellAttributes
- Parameters:
rhs
- another Cell instance- Returns:
- true if all fields are equal
-
hashCode
public int hashCode()
Hashcode uses all fields in equals().- Overrides:
hashCode
in classCellAttributes
- Returns:
- the hash
-
setTo
public void setTo(java.lang.Object rhs)
Set my field values to that's field.- Overrides:
setTo
in classCellAttributes
- Parameters:
rhs
- an instance of either Cell or CellAttributes
-
setAttr
public void setAttr(CellAttributes that)
Set my field attr values to that's field.- Parameters:
that
- a CellAttributes instance
-
setAttr
public void setAttr(CellAttributes that, boolean keepImage)
Set my field attr values to that's field.- Parameters:
that
- a CellAttributes instancekeepImage
- if true, retain the image data
-
toString
public java.lang.String toString()
Make human-readable description of this Cell.- Overrides:
toString
in classCellAttributes
- Returns:
- displayable String
-
toHtml
public java.lang.String toHtml()
Convert this cell into an HTML entity inside a <font> tag.- Overrides:
toHtml
in classCellAttributes
- Returns:
- the HTML string
-
-