com.hfg.html.Body 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.HTMLColor;
import com.hfg.graphics.ColorUtil;
import com.hfg.xml.XMLAttribute;
import com.hfg.xml.XMLNode;
//------------------------------------------------------------------------------
/**
Represents a body (<body>) 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 Body extends HTMLTagWithCoreEvents
{
//###########################################################################
// CONSTRUCTORS
//###########################################################################
//---------------------------------------------------------------------------
public Body()
{
super(HTML.BODY);
}
//--------------------------------------------------------------------------
public Body(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 Div addDiv()
{
Div div = new Div();
addSubtag(div);
return div;
}
//---------------------------------------------------------------------------
public Div addDiv(CharSequence inContent)
{
Div div = new Div(inContent);
addSubtag(div);
return div;
}
//---------------------------------------------------------------------------
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 ImageMap addImageMap()
{
ImageMap imageMap = new ImageMap();
addSubtag(imageMap);
return imageMap;
}
//---------------------------------------------------------------------------
public IFrame addIFrame()
{
IFrame iframe = new IFrame();
addSubtag(iframe);
return iframe;
}
//---------------------------------------------------------------------------
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 Nav addNav()
{
Nav tag = new Nav();
addSubtag(tag);
return tag;
}
//---------------------------------------------------------------------------
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 Section addSection()
{
Section tag = new Section();
addSubtag(tag);
return tag;
}
//---------------------------------------------------------------------------
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 Ul addUnorderedList()
{
Ul ul = new Ul();
addSubtag(ul);
return ul;
}
//---------------------------------------------------------------------------
public void br()
{
HTMLUtil.br(this);
}
//---------------------------------------------------------------------------
public void br(int inNumber)
{
HTMLUtil.br(this, inNumber);
}
//---------------------------------------------------------------------------
public void nbsp(int inNumber)
{
HTMLUtil.nbsp(this, inNumber);
}
//---------------------------------------------------------------------------
public void hr()
{
HTMLUtil.hr(this);
}
//---------------------------------------------------------------------------
public void hr(String inWidth)
{
HTMLUtil.hr(this, inWidth);
}
//---------------------------------------------------------------------------
/**
Sets the background image for the page.
@param inValue the URL of the background image to use for the body
@return this Body object to enable method chaining
*/
public Body setBackground(String inValue)
{
setAttribute(HTML.BACKGROUND, inValue);
return this;
}
//---------------------------------------------------------------------------
/**
Sets the background color for the page.
@param inValue the background color to use for the body
@return this Body object to enable method chaining
*/
public Body setBackgroundColor(HTMLColor inValue)
{
setAttribute(HTML.BGCOLOR, inValue);
return this;
}
//--------------------------------------------------------------------------
/**
Sets the background color for the page.
@param inValue the background color to use for the body
@return this Body object to enable method chaining
*/
public Body setBackgroundColor(Color inValue)
{
setAttribute(HTML.BGCOLOR, "#" + ColorUtil.colorToHex(inValue));
return this;
}
//---------------------------------------------------------------------------
/**
Sets the background color for the page.
@param inValue the background color to use for the body
@return this Body object to enable method chaining
*/
public Body setBackgroundColor(String inValue)
{
setAttribute(HTML.BGCOLOR, inValue);
return this;
}
//---------------------------------------------------------------------------
/**
Sets the class attribute to the specified value.
@param inValue the CSS class(es) to apply to the body
@return this Body object to enable method chaining
*/
@Override
public Body setClass(String inValue)
{
setAttribute(HTML.CLASS, inValue);
return this;
}
//---------------------------------------------------------------------------
/**
Sets the onload attribute to the specified value.
@param inValue the 'onload' javascript to apply to the body
@return this Body object to enable method chaining
*/
public Body setOnLoad(String inValue)
{
setAttribute(HTML.ONLOAD, inValue);
return this;
}
//---------------------------------------------------------------------------
/**
Appends the specified javascript to the body's onload attribute.
@param inValue javascript to append to the 'onload' javascript for the body
@return this Body object to enable method chaining
*/
public Body appendToOnLoad(String inValue)
{
XMLAttribute attr = getAttribute(HTML.ONLOAD);
String value = (attr != null ? attr.getValue() + " " : "");
setAttribute(HTML.ONLOAD, value + inValue);
return this;
}
// Overrides for HTMLTag setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Body setId(String inValue)
{
return (Body) super.setId(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setStyle(CharSequence inValue)
{
return (Body) super.setStyle(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body addStyle(String inValue)
{
return (Body) super.addStyle(inValue);
}
// Overrides for HTMLTagWithCoreEvents setters to allow method chaining.
//--------------------------------------------------------------------------
@Override
public Body setOnClick(String inValue)
{
return (Body) super.setOnClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnDblClick(String inValue)
{
return (Body) super.setOnDblClick(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnMouseDown(String inValue)
{
return (Body) super.setOnMouseDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnMouseMove(String inValue)
{
return (Body) super.setOnMouseMove(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnMouseOut(String inValue)
{
return (Body) super.setOnMouseOut(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnMouseOver(String inValue)
{
return (Body) super.setOnMouseOver(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnMouseUp(String inValue)
{
return (Body) super.setOnMouseUp(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnKeyDown(String inValue)
{
return (Body) super.setOnKeyDown(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnKeyPress(String inValue)
{
return (Body) super.setOnKeyPress(inValue);
}
//--------------------------------------------------------------------------
@Override
public Body setOnKeyUp(String inValue)
{
return (Body) super.setOnKeyUp(inValue);
}
}