com.hfg.html.Tr 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.HTMLColor;
import com.hfg.html.attribute.VAlign;
import com.hfg.graphics.ColorUtil;
import com.hfg.xml.XMLNode;
//------------------------------------------------------------------------------
/**
* Represents a table row (<tr>) 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 Tr extends HTMLTagWithCoreEvents
{
//##########################################################################
// PRIVATE FIELDS
//##########################################################################
//##########################################################################
// CONSTRUCTORS
//##########################################################################
//--------------------------------------------------------------------------
public Tr()
{
super(HTML.TR);
}
//--------------------------------------------------------------------------
public Tr(Align inAlign)
{
this();
setAlign(inAlign);
}
//--------------------------------------------------------------------------
public Tr(XMLNode inXMLNode)
{
this();
initFromXMLNode(inXMLNode);
}
//##########################################################################
// PUBLIC METHODS
//##########################################################################
//--------------------------------------------------------------------------
public void addCell(Td inCell)
{
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(inCell);
}
//--------------------------------------------------------------------------
public Td addCell()
{
Td td = new Td();
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(td);
return td;
}
//--------------------------------------------------------------------------
public Td addCell(String inContent)
{
Td td = new Td(inContent);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(td);
return td;
}
//--------------------------------------------------------------------------
public Td addCell(String inContent, Align inAlign)
{
Td td = new Td(inContent, inAlign);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(td);
return td;
}
//--------------------------------------------------------------------------
public Td addCell(HTMLNode inContent)
{
Td td = new Td(inContent);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(td);
return td;
}
//--------------------------------------------------------------------------
public Td addCell(HTMLNode inContent, Align inAlign)
{
Td td = new Td(inContent, inAlign);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(td);
return td;
}
//--------------------------------------------------------------------------
public void addHeaderCell(Th inCell)
{
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(inCell);
}
//--------------------------------------------------------------------------
public Th addHeaderCell()
{
Th th = new Th();
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(th);
return th;
}
//--------------------------------------------------------------------------
public Th addHeaderCell(String inContent)
{
Th th = new Th(inContent);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(th);
return th;
}
//--------------------------------------------------------------------------
public Th addHeaderCell(String inContent, Align inAlign)
{
Th th = new Th(inContent, inAlign);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(th);
return th;
}
//--------------------------------------------------------------------------
public Th addHeaderCell(HTMLTag inContent)
{
Th th = new Th(inContent);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(th);
return th;
}
//--------------------------------------------------------------------------
public Th addHeaderCell(HTMLTag inContent, Align inAlign)
{
Th th = new Th(inContent, inAlign);
// Using addSubtag() instead of addContent() because there should not
// be any content in 'tr' other than 'td' or 'th' tags.
addSubtag(th);
return th;
}
//--------------------------------------------------------------------------
public Tr setAlign(Align inValue)
{
setAttribute(inValue.getHTMLAttributeName(), inValue.toString());
return this;
}
//--------------------------------------------------------------------------
public Tr setVAlign(VAlign inValue)
{
setAttribute(inValue.getHTMLAttributeName(), inValue.toString());
return this;
}
//---------------------------------------------------------------------------
/**
Sets the background color for the table row.
*/
public Tr setBackgroundColor(HTMLColor inValue)
{
setAttribute(HTML.BGCOLOR, inValue);
return this;
}
//--------------------------------------------------------------------------
/**
Sets the background color for the table row.
*/
public Tr setBackgroundColor(Color inValue)
{
setAttribute(HTML.BGCOLOR, "#" + ColorUtil.colorToHex(inValue));
return this;
}
//--------------------------------------------------------------------------
/**
Sets the background color for the table row.
*/
public Tr setBackgroundColor(String inValue)
{
setAttribute(HTML.BGCOLOR, inValue);
return this;
}
//--------------------------------------------------------------------------
public String getBackgroundColor()
{
return getAttributeValue(HTML.BGCOLOR);
}
// Overrides for HTMLTag setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Tr addClass(String inValue)
{
return (Tr) super.addClass(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setClass(String inValue)
{
return (Tr) super.setClass(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setId(String inValue)
{
return (Tr) super.setId(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setStyle(CharSequence inValue)
{
return (Tr) super.setStyle(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr addStyle(String inValue)
{
return (Tr) super.addStyle(inValue);
}
// Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Tr setOnClick(String inValue)
{
return (Tr) super.setOnClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnDblClick(String inValue)
{
return (Tr) super.setOnDblClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnMouseDown(String inValue)
{
return (Tr) super.setOnMouseDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnMouseMove(String inValue)
{
return (Tr) super.setOnMouseMove(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr appendToOnMouseOut(String inValue)
{
return (Tr) super.appendToOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnMouseOut(String inValue)
{
return (Tr) super.setOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr appendToOnMouseOver(String inValue)
{
return (Tr) super.appendToOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnMouseOver(String inValue)
{
return (Tr) super.setOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnMouseUp(String inValue)
{
return (Tr) super.setOnMouseUp(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnKeyDown(String inValue)
{
return (Tr) super.setOnKeyDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnKeyPress(String inValue)
{
return (Tr) super.setOnKeyPress(inValue);
}
//--------------------------------------------------------------------------
@Override
public Tr setOnKeyUp(String inValue)
{
return (Tr) super.setOnKeyUp(inValue);
}
}