com.hfg.html.Th Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com_hfg Show documentation
Show all versions of com_hfg Show documentation
com.hfg xml, html, svg, and bioinformatics utility library
package com.hfg.html;
import java.awt.Color;
import com.hfg.html.attribute.Align;
import com.hfg.html.attribute.VAlign;
import com.hfg.html.attribute.HTMLColor;
import com.hfg.graphics.ColorUtil;
import com.hfg.xml.XMLNode;
//------------------------------------------------------------------------------
/**
* Represents a table header cell (<th>) tag.
*
* @author J. Alex Taylor, hairyfatguy.com
*/
//------------------------------------------------------------------------------
// com.hfg XML/HTML Coding Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------
public class Th extends HTMLTagWithCoreEvents
{
//##########################################################################
// CONSTRUCTORS
//##########################################################################
//--------------------------------------------------------------------------
public Th()
{
super(HTML.TH);
}
//--------------------------------------------------------------------------
public Th(String inContent)
{
this();
addContent(inContent);
}
//--------------------------------------------------------------------------
public Th(HTMLTag inContent)
{
this();
addSubtag(inContent);
}
//--------------------------------------------------------------------------
public Th(String inContent, Align inAlign)
{
this(inContent);
setAlign(inAlign);
}
//--------------------------------------------------------------------------
public Th(HTMLTag inContent, Align inAlign)
{
this(inContent);
setAlign(inAlign);
}
//--------------------------------------------------------------------------
public Th(XMLNode inXMLNode)
{
this();
initFromXMLNode(inXMLNode);
}
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//--------------------------------------------------------------------------
public Center addCenter()
{
Center center = new Center();
addSubtag(center);
return center;
}
//--------------------------------------------------------------------------
public Center addCenter(String inContent)
{
Center center = new Center(inContent);
addSubtag(center);
return center;
}
//--------------------------------------------------------------------------
public Center addCenter(HTMLTag inContent)
{
Center center = new Center(inContent);
addSubtag(center);
return center;
}
//--------------------------------------------------------------------------
public Form addForm()
{
Form form = new Form();
addSubtag(form);
return form;
}
//--------------------------------------------------------------------------
public Form addForm(String inFormName)
{
Form form = new Form(inFormName);
addSubtag(form);
return form;
}
//--------------------------------------------------------------------------
public Img addImage(String inSrc)
{
Img image = new Img(inSrc);
addSubtag(image);
return image;
}
//--------------------------------------------------------------------------
public Link addLink()
{
Link link = new Link();
addSubtag(link);
return link;
}
//--------------------------------------------------------------------------
public Link addLink(CharSequence inURL)
{
Link link = new Link(inURL);
addSubtag(link);
return link;
}
//--------------------------------------------------------------------------
public Link addLink(CharSequence inURL, String inContent)
{
Link link = new Link(inURL, inContent);
addSubtag(link);
return link;
}
//--------------------------------------------------------------------------
public Nobr addNobr()
{
Nobr nobr = new Nobr();
addSubtag(nobr);
return nobr;
}
//--------------------------------------------------------------------------
public Nobr addNobr(String inContent)
{
Nobr nobr = new Nobr(inContent);
addSubtag(nobr);
return nobr;
}
//--------------------------------------------------------------------------
public Nobr addNobr(HTMLTag inContent)
{
Nobr nobr = new Nobr(inContent);
addSubtag(nobr);
return nobr;
}
//--------------------------------------------------------------------------
public Pre addPre()
{
Pre pre = new Pre();
addSubtag(pre);
return pre;
}
//--------------------------------------------------------------------------
public Pre addPre(String inContent)
{
Pre pre = new Pre(inContent);
addSubtag(pre);
return pre;
}
//--------------------------------------------------------------------------
public Pre addPre(HTMLTag inContent)
{
Pre pre = new Pre(inContent);
addSubtag(pre);
return pre;
}
//--------------------------------------------------------------------------
public Span addSpan()
{
Span span = new Span();
addSubtag(span);
return span;
}
//--------------------------------------------------------------------------
public Span addSpan(String inContent)
{
Span span = new Span(inContent);
addSubtag(span);
return span;
}
//--------------------------------------------------------------------------
public Span addSpan(HTMLTag inContent)
{
Span span = new Span(inContent);
addSubtag(span);
return span;
}
//--------------------------------------------------------------------------
public Table addTable()
{
Table table = new Table();
addSubtag(table);
return table;
}
//--------------------------------------------------------------------------
public Th setTitle(String inValue)
{
setAttribute(HTML.TITLE, inValue);
return this;
}
//--------------------------------------------------------------------------
public String getTitle()
{
return getAttributeValue(HTML.TITLE);
}
//--------------------------------------------------------------------------
public Ul addUnorderedList()
{
Ul ul = new Ul();
addSubtag(ul);
return ul;
}
//--------------------------------------------------------------------------
public Th setAlign(Align inValue)
{
setAttribute(inValue.getHTMLAttributeName(), inValue.toString());
return this;
}
//--------------------------------------------------------------------------
public Th setVAlign(VAlign inValue)
{
setAttribute(inValue.getHTMLAttributeName(), inValue.toString());
return this;
}
//--------------------------------------------------------------------------
public Th setColSpan(int inValue)
{
setAttribute(HTML.COLSPAN, Integer.toString(inValue));
return this;
}
//--------------------------------------------------------------------------
public String getColSpan()
{
return getAttributeValue(HTML.COLSPAN);
}
//--------------------------------------------------------------------------
public Th setRowSpan(int inValue)
{
setAttribute(HTML.ROWSPAN, Integer.toString(inValue));
return this;
}
//--------------------------------------------------------------------------
public String getRowSpan()
{
return getAttributeValue(HTML.ROWSPAN);
}
//---------------------------------------------------------------------------
/**
Sets the background color for the header cell.
*/
public Th setBackgroundColor(HTMLColor inValue)
{
setAttribute(HTML.BGCOLOR, inValue);
return this;
}
//--------------------------------------------------------------------------
/**
Sets the background color for the header cell.
*/
public Th setBackgroundColor(String inValue)
{
setAttribute(HTML.BGCOLOR, inValue);
return this;
}
//--------------------------------------------------------------------------
/**
Sets the background color for the header cell.
*/
public Th setBackgroundColor(Color inValue)
{
setAttribute(HTML.BGCOLOR, "#" + ColorUtil.colorToHex(inValue));
return this;
}
//--------------------------------------------------------------------------
public String getBackgroundColor()
{
return getAttributeValue(HTML.BGCOLOR);
}
//--------------------------------------------------------------------------
public Th setWidth(String inValue)
{
setAttribute(HTML.WIDTH, inValue);
return this;
}
//--------------------------------------------------------------------------
public Th setWidth(int inValue)
{
setAttribute(HTML.WIDTH, Integer.toString(inValue));
return this;
}
//--------------------------------------------------------------------------
public Th br()
{
HTMLUtil.br(this);
return this;
}
//--------------------------------------------------------------------------
public Th br(int inNumber)
{
HTMLUtil.br(this, inNumber);
return this;
}
//--------------------------------------------------------------------------
public Th nbsp(int inNumber)
{
HTMLUtil.nbsp(this, inNumber);
return this;
}
//--------------------------------------------------------------------------
public void hr()
{
HTMLUtil.hr(this);
}
//--------------------------------------------------------------------------
public void hr(String inWidth)
{
HTMLUtil.hr(this, inWidth);
}
// Overrides for HTMLTag setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Th addClass(String inValue)
{
return (Th) super.addClass(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setClass(String inValue)
{
return (Th) super.setClass(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setId(String inValue)
{
return (Th) super.setId(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setStyle(CharSequence inValue)
{
return (Th) super.setStyle(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th addStyle(String inValue)
{
return (Th) super.addStyle(inValue);
}
// Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Th setOnClick(String inValue)
{
return (Th) super.setOnClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th appendToOnClick(String inValue)
{
return (Th) super.appendToOnClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnDblClick(String inValue)
{
return (Th) super.setOnDblClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th appendToOnDblClick(String inValue)
{
return (Th) super.appendToOnDblClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnMouseDown(String inValue)
{
return (Th) super.setOnMouseDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnMouseMove(String inValue)
{
return (Th) super.setOnMouseMove(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th appendToOnMouseOut(String inValue)
{
return (Th) super.appendToOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnMouseOut(String inValue)
{
return (Th) super.setOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th appendToOnMouseOver(String inValue)
{
return (Th) super.appendToOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnMouseOver(String inValue)
{
return (Th) super.setOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnMouseUp(String inValue)
{
return (Th) super.setOnMouseUp(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnKeyDown(String inValue)
{
return (Th) super.setOnKeyDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnKeyPress(String inValue)
{
return (Th) super.setOnKeyPress(inValue);
}
//--------------------------------------------------------------------------
@Override
public Th setOnKeyUp(String inValue)
{
return (Th) super.setOnKeyUp(inValue);
}
}