// Constants --------------------------------------------------------------
// ------------------------------------------------------------------------
+ /**
+ * How this cell needs to be displayed if it is part of a larger glyph.
+ */
+ public enum Width {
+ /**
+ * This cell is an entire glyph on its own.
+ */
+ SINGLE,
+
+ /**
+ * This cell is the left half of a wide glyph.
+ */
+ LEFT,
+
+ /**
+ * This cell is the right half of a wide glyph.
+ */
+ RIGHT,
+ }
+
/**
* The special "this cell is unset" (null) value. This is the Unicode
* "not a character" value.
/**
* The character at this cell.
*/
- private char ch;
+ private int ch = ' ';
+
+ /**
+ * The display width of this cell.
+ */
+ private Width width = Width.SINGLE;
/**
* The image at this cell.
* The background color used for the area the image portion might not
* cover.
*/
- private Color background = null;
+ private Color background = Color.BLACK;
/**
* hashCode() needs to call image.hashCode(), which can get quite
* @see #reset()
*/
public Cell() {
- reset();
+ // NOP
}
/**
* @param ch character to set to
* @see #reset()
*/
- public Cell(final char ch) {
- reset();
+ public Cell(final int ch) {
this.ch = ch;
}
+ /**
+ * Public constructor sets the attributes.
+ *
+ * @param attr attributes to use
+ */
+ public Cell(final CellAttributes attr) {
+ super(attr);
+ }
+
+ /**
+ * Public constructor sets the character and attributes.
+ *
+ * @param ch character to set to
+ * @param attr attributes to use
+ */
+ public Cell(final int ch, final CellAttributes attr) {
+ super(attr);
+ this.ch = ch;
+ }
+
+ /**
+ * Public constructor creates a duplicate.
+ *
+ * @param cell the instance to copy
+ */
+ public Cell(final Cell cell) {
+ setTo(cell);
+ }
+
// ------------------------------------------------------------------------
// Cell -------------------------------------------------------------------
// ------------------------------------------------------------------------
-
/**
* Set the image data for this cell.
*
public void setImage(final BufferedImage image) {
this.image = image;
imageHashCode = image.hashCode();
+ width = Width.SINGLE;
}
/**
*
* @return cell character
*/
- public char getChar() {
+ public int getChar() {
return ch;
}
*
* @param ch new cell character
*/
- public void setChar(final char ch) {
+ public void setChar(final int ch) {
this.ch = ch;
}
+ /**
+ * Getter for cell width.
+ *
+ * @return Width.SINGLE, Width.LEFT, or Width.RIGHT
+ */
+ public Width getWidth() {
+ return width;
+ }
+
+ /**
+ * Setter for cell width.
+ *
+ * @param width new cell width, one of Width.SINGLE, Width.LEFT, or
+ * Width.RIGHT
+ */
+ public void setWidth(final Width width) {
+ this.width = width;
+ }
+
/**
* Reset this cell to a blank.
*/
public void reset() {
super.reset();
ch = ' ';
+ width = Width.SINGLE;
image = null;
imageHashCode = 0;
invertedImage = null;
public void unset() {
super.reset();
ch = UNSET_VALUE;
+ width = Width.SINGLE;
image = null;
imageHashCode = 0;
invertedImage = null;
&& !isProtect()
&& !isRGB()
&& !isImage()
+ && (width == Width.SINGLE)
&& (ch == ' ')
) {
return true;
}
// Normal case: character and attributes must match.
- if (ch == that.ch) {
+ if ((ch == that.ch) && (width == that.width)) {
return super.equals(rhs);
}
return false;
int B = 23;
int hash = A;
hash = (B * hash) + super.hashCode();
- hash = (B * hash) + (int)ch;
+ hash = (B * hash) + ch;
+ hash = (B * hash) + width.hashCode();
if (image != null) {
/*
hash = (B * hash) + image.hashCode();
this.image = null;
this.imageHashCode = 0;
this.backgroundHashCode = 0;
+ this.width = Width.SINGLE;
super.setTo(thatAttr);
if (rhs instanceof Cell) {
Cell that = (Cell) rhs;
this.ch = that.ch;
+ this.width = that.width;
this.image = that.image;
this.invertedImage = that.invertedImage;
this.background = that.background;