Merge commit '77d3a60869e7a780c6ae069e51530e1eacece5e2'
[fanfix.git] / src / jexer / bits / Cell.java
index 5db5f4387bdcfbf00f785834918d16407f488547..ed3c202a005a8c8a2a4187d08478cf8d62a6191c 100644 (file)
@@ -73,7 +73,7 @@ public final class Cell extends CellAttributes {
     /**
      * The character at this cell.
      */
-    private char ch;
+    private int ch = ' ';
 
     /**
      * The display width of this cell.
@@ -94,7 +94,7 @@ public final class Cell extends CellAttributes {
      * 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
@@ -119,7 +119,7 @@ public final class Cell extends CellAttributes {
      * @see #reset()
      */
     public Cell() {
-        reset();
+        // NOP
     }
 
     /**
@@ -129,11 +129,39 @@ public final class Cell extends CellAttributes {
      * @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 -------------------------------------------------------------------
     // ------------------------------------------------------------------------
@@ -235,7 +263,7 @@ public final class Cell extends CellAttributes {
      *
      * @return cell character
      */
-    public char getChar() {
+    public int getChar() {
         return ch;
     }
 
@@ -244,7 +272,7 @@ public final class Cell extends CellAttributes {
      *
      * @param ch new cell character
      */
-    public void setChar(final char ch) {
+    public void setChar(final int ch) {
         this.ch = ch;
     }
 
@@ -260,7 +288,7 @@ public final class Cell extends CellAttributes {
     /**
      * Setter for cell width.
      *
-     * @param ch new cell width, one of Width.SINGLE, Width.LEFT, or
+     * @param width new cell width, one of Width.SINGLE, Width.LEFT, or
      * Width.RIGHT
      */
     public void setWidth(final Width width) {
@@ -391,7 +419,7 @@ public final class Cell extends CellAttributes {
         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) {
             /*