All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.html.Td Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.html;

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;
import com.hfg.xml.XMLTag;

import java.awt.*;


//------------------------------------------------------------------------------
/**
 * Represents a table cell (<td>) 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 Td extends HTMLTagWithCoreEvents
{

   //##########################################################################
   // PRIVATE FIELDS
   //##########################################################################


   //##########################################################################
   // CONSTRUCTORS
   //##########################################################################

   //--------------------------------------------------------------------------
   public Td()
   {
      super(HTML.TD);
   }

   //--------------------------------------------------------------------------
   public Td(String inContent)
   {
      this();
      addContent(inContent);
   }

   //--------------------------------------------------------------------------
   public Td(HTMLNode inContent)
   {
      this();
      addSubtag(inContent);
   }

   //--------------------------------------------------------------------------
   public Td(String inContent, Align inAlign)
   {
      this(inContent);
      setAlign(inAlign);
   }

   //--------------------------------------------------------------------------
   public Td(HTMLNode inContent, Align inAlign)
   {
      this(inContent);
      setAlign(inAlign);
   }

   //--------------------------------------------------------------------------
   public Td(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(String inContent)
   {
      Div div = new Div(inContent);
      addSubtag(div);

      return div;
   }

   //--------------------------------------------------------------------------
   public Div addDiv(HTMLTag 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 void addImageMap(ImageMap inValue)
   {
      addSubtag(inValue);
   }

   //--------------------------------------------------------------------------
   public Link addLink()
   {
      Link link = new Link();
      addSubtag(link);

      return link;
   }

   //--------------------------------------------------------------------------
   public Link addLink(Link inLink)
   {
      addSubtag(inLink);

      return inLink;
   }

   //--------------------------------------------------------------------------
   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 Link addLink(CharSequence inURL, HTMLTag 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 Script addScript()
   {
      Script script = new Script();
      addSubtag(script);

      return script;
   }

   //--------------------------------------------------------------------------
   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 InputButton addButton()
   {
      InputButton button = new InputButton();
      addSubtag(button);

      return button;
   }

   //--------------------------------------------------------------------------
   public InputButton addButton(String inName, String inValue)
   {
      InputButton button = new InputButton(inName, inValue);
      addSubtag(button);

      return button;
   }

   //--------------------------------------------------------------------------
   public InputSubmit addSubmit()
   {
      InputSubmit submit = new InputSubmit();
      addSubtag(submit);

      return submit;
   }

   //--------------------------------------------------------------------------
   public InputSubmit addSubmit(String inName, String inValue)
   {
      InputSubmit submit = new InputSubmit(inName, inValue);
      addSubtag(submit);

      return submit;
   }

   //--------------------------------------------------------------------------
   public Textarea addTextarea()
   {
      Textarea textarea = new Textarea();
      addSubtag(textarea);

      return textarea;
   }

   //--------------------------------------------------------------------------
   public Textarea addTextarea(String inName, String inValue)
   {
      Textarea textarea = new Textarea(inName, inValue);
      addSubtag(textarea);

      return textarea;
   }

   //--------------------------------------------------------------------------
   public InputText addTextInput()
   {
      InputText text = new InputText();
      addSubtag(text);

      return text;
   }

   //--------------------------------------------------------------------------
   public InputText addTextInput(String inName, String inValue)
   {
      InputText text = new InputText(inName, inValue);
      addSubtag(text);

      return text;
   }

   //--------------------------------------------------------------------------
   public InputPassword addPasswordInput()
   {
      InputPassword input = new InputPassword();
      addSubtag(input);

      return input;
   }

   //--------------------------------------------------------------------------
   public InputPassword addPasswordInput(String inName, String inValue)
   {
      InputPassword input = new InputPassword(inName, inValue);
      addSubtag(input);

      return input;
   }

   //--------------------------------------------------------------------------
   public InputCheckbox addCheckbox(String inName, String inValue)
   {
      InputCheckbox checkbox = new InputCheckbox(inName, inValue);
      addSubtag(checkbox);

      return checkbox;
   }

   //--------------------------------------------------------------------------
   public InputCheckbox addCheckbox(String inName, String inValue, boolean checked)
   {
      InputCheckbox checkbox = new InputCheckbox(inName, inValue, checked);
      addSubtag(checkbox);

      return checkbox;
   }

   //--------------------------------------------------------------------------
   public InputRadio addRadio(String inName, String inValue)
   {
      InputRadio radio = new InputRadio(inName, inValue);
      addSubtag(radio);

      return radio;
   }

   //--------------------------------------------------------------------------
   public InputRadio addRadio(String inName, String inValue, boolean checked)
   {
      InputRadio radio = new InputRadio(inName, inValue, checked);
      addSubtag(radio);

      return radio;
   }


   //--------------------------------------------------------------------------
   public Select addSelect(String inName)
   {
      Select select = new Select(inName);
      addSubtag(select);

      return select;
   }


   //--------------------------------------------------------------------------
   public InputReset addReset()
   {
      InputReset reset = new InputReset();
      addSubtag(reset);

      return reset;
   }


   //--------------------------------------------------------------------------
   public InputFile addFileInput()
   {
      InputFile subtag = new InputFile();
      addSubtag(subtag);

      return subtag;
   }

   //--------------------------------------------------------------------------
   public InputFile addFileInput(String inName)
   {
      InputFile subtag = new InputFile(inName);
      addSubtag(subtag);

      return subtag;
   }

   //--------------------------------------------------------------------------
   public InputFile addFileInput(String inName, String inValue)
   {
      InputFile subtag = new InputFile(inName, inValue);
      addSubtag(subtag);

      return subtag;
   }


   //--------------------------------------------------------------------------
   public Td setAlign(Align inValue)
   {
      setAttribute(inValue.getHTMLAttributeName(), inValue.toString());

      return this;
   }

   //--------------------------------------------------------------------------
   public Td setVAlign(VAlign inValue)
   {
      setAttribute(inValue.getHTMLAttributeName(), inValue.toString());

      return this;
   }

   //--------------------------------------------------------------------------
   public Td setColSpan(int inValue)
   {
      setAttribute(HTML.COLSPAN, Integer.toString(inValue));

      return this;
   }

   //--------------------------------------------------------------------------
   public String getColSpan()
   {
      return getAttributeValue(HTML.COLSPAN);
   }

   //--------------------------------------------------------------------------
   public Td setRowSpan(int inValue)
   {
      setAttribute(HTML.ROWSPAN, Integer.toString(inValue));

      return this;
   }

   //--------------------------------------------------------------------------
   public String getRowSpan()
   {
      return getAttributeValue(HTML.ROWSPAN);
   }

   //---------------------------------------------------------------------------
   /**
    Sets the background color for the table cell.
    */
   public Td setBackgroundColor(HTMLColor inValue)
   {
      setAttribute(HTML.BGCOLOR, inValue);
      return this;
   }

   //--------------------------------------------------------------------------
   /**
    Sets the background color for the table cell.
    */
   public Td setBackgroundColor(Color inValue)
   {
      setAttribute(HTML.BGCOLOR, "#" + ColorUtil.colorToHex(inValue));

      return this;
   }

   //--------------------------------------------------------------------------
   /**
    Sets the background color for the table cell.
    */
   public Td setBackgroundColor(String inValue)
   {
      setAttribute(HTML.BGCOLOR, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public String getBackgroundColor()
   {
      return getAttributeValue(HTML.BGCOLOR);
   }


   //--------------------------------------------------------------------------
   public Td setWidth(String inValue)
   {
      setAttribute(HTML.WIDTH, inValue);

      return this;
   }

   //--------------------------------------------------------------------------
   public Td setWidth(int inValue)
   {
      setAttribute(HTML.WIDTH, Integer.toString(inValue));

      return this;
   }


   //--------------------------------------------------------------------------
   public Td setTitle(String inValue)
   {
      setAttribute(HTML.TITLE, inValue);
      return this;
   }

   //--------------------------------------------------------------------------
   public String getTitle()
   {
      return getAttributeValue(HTML.TITLE);
   }

   //--------------------------------------------------------------------------
   public Td br()
   {
      HTMLUtil.br(this);
      return this;
   }

   //--------------------------------------------------------------------------
   public Td br(int inNumber)
   {
      HTMLUtil.br(this, inNumber);
      return this;
   }

   //--------------------------------------------------------------------------
   public Td 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 Td addClass(String inValue)
   {
      return (Td) super.addClass(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setClass(String inValue)
   {
      return (Td) super.setClass(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setId(String inValue)
   {
      return (Td) super.setId(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setStyle(CharSequence inValue)
   {
      return (Td) super.setStyle(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td addStyle(String inValue)
   {
      return (Td) super.addStyle(inValue);
   }

   // Overrides for HTMLTagWithCoreEvents setters to allow method chaining.

   //--------------------------------------------------------------------------
   @Override
   public Td setOnClick(String inValue)
   {
      return (Td) super.setOnClick(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnDblClick(String inValue)
   {
      return (Td) super.setOnDblClick(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnMouseDown(String inValue)
   {
      return (Td) super.setOnMouseDown(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnMouseMove(String inValue)
   {
      return (Td) super.setOnMouseMove(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td appendToOnMouseOut(String inValue)
   {
      return (Td) super.appendToOnMouseOut(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnMouseOut(String inValue)
   {
      return (Td) super.setOnMouseOut(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td appendToOnMouseOver(String inValue)
   {
      return (Td) super.appendToOnMouseOver(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnMouseOver(String inValue)
   {
      return (Td) super.setOnMouseOver(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnMouseUp(String inValue)
   {
      return (Td) super.setOnMouseUp(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnKeyDown(String inValue)
   {
      return (Td) super.setOnKeyDown(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnKeyPress(String inValue)
   {
      return (Td) super.setOnKeyPress(inValue);
   }

   //--------------------------------------------------------------------------
   @Override
   public Td setOnKeyUp(String inValue)
   {
      return (Td) super.setOnKeyUp(inValue);
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy