import java.io.*;

/*-------------------------------------------------- 
* CLASS: THtmlFont
* DESCRIPTION: Is used to produce a formatted Html
   Font Tag with text content. The text can contain
   other Html tags.
* STATUS: 
* HISTORY: 
    25th Jan 2001- written
* DOCUMENTED AT: ? 
* CODE LOCATION: 
    \LibraryCode\Java\Classes\SourceCode1\ 
* TO DO: 
------------------------------------------------------*/ 

public class THtmlFont
{
  private boolean bIsBold;
  private boolean bIsItalic;
  private StringBuffer sbSize;
  private StringBuffer sbColour;
  private StringBuffer sbFontFace;
  private StringBuffer sbContents;        

  //-----------------------------------
  // Constructors
  //-----------------------------------
  public THtmlFont
   (String sContents, String sSize, String sColour,
    String sFontFace, boolean bIsBold, boolean bIsItalic)
  {
    this.bIsBold = bIsBold;
    this.bIsItalic = bIsItalic;
    this.sbSize = new StringBuffer(sSize);
    this.sbColour = new StringBuffer(sColour);
    this.sbFontFace = new StringBuffer(sFontFace);
    sbContents = new StringBuffer(sContents); 
  } /* Constructor: (S, S, S, S, b, b) */

  public THtmlFont
   (String sContents, String sSize, String sColour,
    String sFontFace, boolean bIsBold)
  {
    this(sContents, sSize, sColour, sFontFace, bIsBold, false);
  } /* Constructor: (S, S, S, S, b) */

  public THtmlFont
   (String sContents, String sSize, String sColour,
    String sFontFace)
  {
    this(sContents, sSize, sColour, sFontFace, false, false);
  } /* Constructor: (S, S, S, S) */

  public THtmlFont
   (String sContents, String sSize, String sColour)
  {
    this(sContents, sSize, sColour, "helvetica", false, false);
  } /* Constructor: (S, S, S) */

  public THtmlFont(String sContents, String sSize)
  {
    this(sContents, sSize, "black", "helvetica", false, false);
  } /* Constructor: (S, S) */

  public THtmlFont(String sContents)
  {
    this(sContents, "+0", "black", "helvetica", false, false);
  } /* Constructor: (S) */

  public THtmlFont()
  {
    this("", "+0", "black", "helvetica", false, false);
  } /* Constructor: () */

  //-----------------------------------
  // Accessor methods
  //-----------------------------------
  public void setIsBold(boolean bIsBold)
    { this.bIsBold = bIsBold; } 

  public boolean getIsBold()
    { return this.bIsBold; }

  public void setIsItalic(boolean bIsItalic)
    { this.bIsItalic = bIsItalic; } 

  public boolean getIsItalic()
    { return this.bIsItalic; }

  public void setSize(StringBuffer sbSize)
    { this.sbSize = sbSize; }

  public void setSize(int iSize)
  {
    this.sbSize = new StringBuffer(iSize); 
  }

  public String getSize()
    { return this.sbSize.toString(); }

  public void setColour(StringBuffer sbColour)
    { this.sbColour = sbColour; }

  public void setColour(int iColour)
  {
    this.sbColour = new StringBuffer(iColour); 
  }

  public String getColour()
    { return this.sbColour.toString(); }

  public void setFontFace(StringBuffer sbFontFace)
    { this.sbFontFace = sbFontFace; }

  public String getFontFace()
    { return this.sbFontFace.toString(); }

  public void setContents(StringBuffer sbContents)
    { this.sbContents = sbContents; }

  public String getContents()
    { return this.sbContents.toString(); }

  //-----------------------------------
  // toString method
  //-----------------------------------
  public String toString()
  {
    String sReturn;
    
    sReturn = new String("");
    sReturn = 
      "<font   size = \"" + this.sbSize + "\" \n" +
      "       color = \"" + this.sbColour + "\" \n" +
      "        face = \"" + this.sbFontFace + "\"> \n";
    if (this.bIsBold == true)
      { sReturn += "<b>"; }
    if (this.bIsItalic == true)
      { sReturn += "<i> \n"; }
     
    sReturn += this.sbContents + " \n";

    if (this.bIsBold == true)
      { sReturn += "</b>"; }
    if (this.bIsItalic == true)
      { sReturn += "</i>"; }

    sReturn += "</font> \n";

    return sReturn;
  } /* method: toString */
  
  //-- Test script
  public static void main(String[] args)
  {
    String sDisplay;
   
    sDisplay = 
      "+----------------------------------------------------------+ \n" +
      "|  The THtmlFont class:                                    | \n" +
      "|                                                          | \n" +
      "|  This purpose of this class is to produce an Html        | \n" +
      "|  Font tag with a (small) number of attributes and        | \n" +
      "|  containing some text.                                   | \n" +
      "|  The toString() method produces the formatted Html text. | \n" +
      "|                                                          | \n" +
      "+----------------------------------------------------------+ \n" +
      "|  Testing the toString() method with a zero argument      | \n" +
      "|  constructor...                                          | \n" +
      "+----------------------------------------------------------+ \n\n";       


    THtmlFont hfTest = new THtmlFont();    
    sDisplay += hfTest;
    sDisplay +=
      "+----------------------------------------------------------+ \n" +
      "|  Testing the toString() method with a one argument       | \n" +
      "|  constructor...                                          | \n" +
      "+----------------------------------------------------------+ \n\n";       

    hfTest = new THtmlFont("The contents of the font tag");    
    sDisplay += hfTest;

    sDisplay +=
      "+----------------------------------------------------------+ \n" +
      "|  Testing the toString() method with a 5 argument         | \n" +
      "|  constructor...                                          | \n" +
      "+----------------------------------------------------------+ \n\n";       

    hfTest = new THtmlFont(
      "The contents of the font tag", "+1", "red", "courier",
      true, true);    
    sDisplay += hfTest;

    System.out.println(sDisplay);
  } //-- main
} //--class: THtmlFont