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

com.hfg.html.Img 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.VAlign;

//------------------------------------------------------------------------------
/**
 Represents a image (<img>) 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 Img extends HTMLTagWithCoreEvents { //########################################################################## // CONSTRUCTORS //########################################################################## //-------------------------------------------------------------------------- public Img() { super(HTML.IMG); setAlt(""); } //-------------------------------------------------------------------------- public Img(CharSequence inSrc) { this(); setSrc(inSrc); } //########################################################################## // PUBLIC METHODS //########################################################################## //-------------------------------------------------------------------------- public Img setSrc(CharSequence inValue) { if (inValue != null) { setAttribute(HTML.SRC, inValue.toString()); } return this; } //-------------------------------------------------------------------------- public String getSrc() { return getAttributeValue(HTML.SRC); } //-------------------------------------------------------------------------- /** Sets the string to be displayed before the image is loaded or in case the image cannot be loaded. @param inValue the value to use for the 'alt' attribute @return this Img object to enable method chaining */ public Img setAlt(String inValue) { setAttribute(HTML.ALT, inValue); return this; } //-------------------------------------------------------------------------- public String getAlt() { return getAttributeValue(HTML.ALT); } //-------------------------------------------------------------------------- public Img setAlign(Align inValue) { setAttribute(inValue.getHTMLAttributeName(), inValue.toString()); return this; } //-------------------------------------------------------------------------- /** * Since an img align attribute allows the normally valign values of 'top' * and 'bottom', this alternate setAlign method takes a VAlign object. @param inValue the value to use for the 'align' attribute @return this Img object to enable method chaining */ public Img setAlign(VAlign inValue) { setAttribute(HTML.ALIGN, inValue.toString()); return this; } //--------------------------------------------------------------------------- public Img setName(String inValue) { setAttribute(HTML.NAME, inValue); return this; } //--------------------------------------------------------------------------- public String getName() { return getAttributeValue(HTML.NAME); } //-------------------------------------------------------------------------- public Img setWidth(String inValue) { setAttribute(HTML.WIDTH, inValue); return this; } //-------------------------------------------------------------------------- public Img setWidth(int inValue) { setAttribute(HTML.WIDTH, new Integer(inValue).toString()); return this; } //-------------------------------------------------------------------------- public String getWidth() { return getAttributeValue(HTML.WIDTH); } //-------------------------------------------------------------------------- public Img setHeight(String inValue) { setAttribute(HTML.HEIGHT, inValue); return this; } //-------------------------------------------------------------------------- public Img setHeight(int inValue) { setAttribute(HTML.HEIGHT, new Integer(inValue).toString()); return this; } //-------------------------------------------------------------------------- public String getHeight() { return getAttributeValue(HTML.HEIGHT); } //-------------------------------------------------------------------------- public Img setBorder(int inValue) { setAttribute(HTML.BORDER, new Integer(inValue).toString()); return this; } //-------------------------------------------------------------------------- public String getBorder() { return getAttributeValue(HTML.BORDER); } //-------------------------------------------------------------------------- public Img setTitle(String inValue) { setAttribute(HTML.TITLE, inValue); return this; } //-------------------------------------------------------------------------- public Img setUseMap(String inValue) { setAttribute(HTML.USEMAP, inValue); return this; } //-------------------------------------------------------------------------- public Img setStyle(String inValue) { setAttribute(HTML.STYLE, inValue); return this; } // Overrides for HTMLTag setters to allow method chaining. //-------------------------------------------------------------------------- @Override public Img setId(String inValue) { return (Img) super.setId(inValue); } // Overrides for HTMLTagWithCoreEvents setters to allow method chaining. //-------------------------------------------------------------------------- @Override public Img setOnClick(String inValue) { return (Img) super.setOnClick(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnDblClick(String inValue) { return (Img) super.setOnDblClick(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnMouseDown(String inValue) { return (Img) super.setOnMouseDown(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnMouseMove(String inValue) { return (Img) super.setOnMouseMove(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnMouseOut(String inValue) { return (Img) super.setOnMouseOut(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnMouseOver(String inValue) { return (Img) super.setOnMouseOver(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnMouseUp(String inValue) { return (Img) super.setOnMouseUp(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnKeyDown(String inValue) { return (Img) super.setOnKeyDown(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnKeyPress(String inValue) { return (Img) super.setOnKeyPress(inValue); } //-------------------------------------------------------------------------- @Override public Img setOnKeyUp(String inValue) { return (Img) super.setOnKeyUp(inValue); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy