X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjexer%2Fbits%2FCellAttributes.java;h=ec3f6ddb6d9518be3302c8aa49ee07a2a0433310;hb=d36057dfab8def933a64be042b039d76708ac5ba;hp=43e0b222c751f616e7edf99554a6c63707df59ec;hpb=6358f6e567422c8a5e880af36bec9ea798cc2cd4;p=fanfix.git diff --git a/src/jexer/bits/CellAttributes.java b/src/jexer/bits/CellAttributes.java index 43e0b22..ec3f6dd 100644 --- a/src/jexer/bits/CellAttributes.java +++ b/src/jexer/bits/CellAttributes.java @@ -3,7 +3,7 @@ * * The MIT License (MIT) * - * Copyright (C) 2016 Kevin Lamonte + * Copyright (C) 2017 Kevin Lamonte * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -33,11 +33,73 @@ package jexer.bits; */ public class CellAttributes { + // ------------------------------------------------------------------------ + // Variables -------------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Bold attribute. */ private boolean bold; + /** + * Blink attribute. + */ + private boolean blink; + + /** + * Reverse attribute. + */ + private boolean reverse; + + /** + * Underline attribute. + */ + private boolean underline; + + /** + * Protected attribute. + */ + private boolean protect; + + /** + * Foreground color. Color.WHITE, Color.RED, etc. + */ + private Color foreColor; + + /** + * Background color. Color.WHITE, Color.RED, etc. + */ + private Color backColor; + + // ------------------------------------------------------------------------ + // Constructors ----------------------------------------------------------- + // ------------------------------------------------------------------------ + + /** + * Public constructor sets default values of the cell to white-on-black, + * no bold/blink/reverse/underline/protect. + * + * @see #reset() + */ + public CellAttributes() { + reset(); + } + + /** + * Public constructor makes a copy from another instance. + * + * @param that another CellAttributes instance + * @see #reset() + */ + public CellAttributes(final CellAttributes that) { + setTo(that); + } + + // ------------------------------------------------------------------------ + // CellAttributes --------------------------------------------------------- + // ------------------------------------------------------------------------ + /** * Getter for bold. * @@ -56,11 +118,6 @@ public class CellAttributes { this.bold = bold; } - /** - * Blink attribute. - */ - private boolean blink; - /** * Getter for blink. * @@ -79,11 +136,6 @@ public class CellAttributes { this.blink = blink; } - /** - * Reverse attribute. - */ - private boolean reverse; - /** * Getter for reverse. * @@ -102,11 +154,6 @@ public class CellAttributes { this.reverse = reverse; } - /** - * Underline attribute. - */ - private boolean underline; - /** * Getter for underline. * @@ -125,11 +172,6 @@ public class CellAttributes { this.underline = underline; } - /** - * Protected attribute. - */ - private boolean protect; - /** * Getter for protect. * @@ -148,11 +190,6 @@ public class CellAttributes { this.protect = protect; } - /** - * Foreground color. Color.WHITE, Color.RED, etc. - */ - private Color foreColor; - /** * Getter for foreColor. * @@ -171,11 +208,6 @@ public class CellAttributes { this.foreColor = foreColor; } - /** - * Background color. Color.WHITE, Color.RED, etc. - */ - private Color backColor; - /** * Getter for backColor. * @@ -208,16 +240,6 @@ public class CellAttributes { backColor = Color.BLACK; } - /** - * Public constructor sets default values of the cell to white-on-black, - * no bold/blink/reverse/underline/protect. - * - * @see #reset() - */ - public CellAttributes() { - reset(); - } - /** * Comparison check. All fields must match to return true. * @@ -284,12 +306,8 @@ public class CellAttributes { */ @Override public String toString() { - if (bold) { - return String.format("bold %s on %s", - foreColor, backColor); - } else { - return String.format("%s on %s", foreColor, backColor); - } + return String.format("%s%s%s on %s", (bold == true ? "bold " : ""), + (blink == true ? "blink " : ""), foreColor, backColor); } }