java/cewolf-1.0/src/main/java/de/laures/cewolf/taglib/html/HTMLImgTag.java
author František Kučera <franta-hg@frantovo.cz>
Sat, 28 Feb 2009 21:31:02 +0100
changeset 1 639991d0808a
permissions -rw-r--r--
Rozbalená knihovna verze 1.0
     1 /* ================================================================
     2  * Cewolf : Chart enabling Web Objects Framework
     3  * ================================================================
     4  *
     5  * Project Info:  http://cewolf.sourceforge.net
     6  * Project Lead:  Guido Laures (guido@laures.de);
     7  *
     8  * (C) Copyright 2002, by Guido Laures
     9  *
    10  * This library is free software; you can redistribute it and/or modify it under the terms
    11  * of the GNU Lesser General Public License as published by the Free Software Foundation;
    12  * either version 2.1 of
    13  * the License, or (at your option) any later version.
    14  *
    15  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
    16  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    17  * See the GNU Lesser General Public License for more details.
    18  *
    19  * You should have received a copy of the GNU Lesser General Public License along with this
    20  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
    21  * Boston, MA 02111-1307, USA.
    22  */
    23 
    24 package de.laures.cewolf.taglib.html;
    25 
    26 import java.io.IOException;
    27 import java.io.Serializable;
    28 import java.io.Writer;
    29 
    30 /**
    31  * HTML img tag.
    32  * @author  Guido Laures
    33  */
    34 public class HTMLImgTag extends AbstractHTMLBaseTag implements Serializable{
    35 	
    36 	private final static String TAG_NAME = "IMG";
    37     
    38     /** Holds value of property width. */
    39     protected int width = UNDEFINED_INT;
    40     
    41     /** Holds value of property height. */
    42     protected int height = UNDEFINED_INT;
    43     
    44     /** Holds value of property src. */
    45     protected String src = UNDEFINED_STR;
    46     
    47     /** Holds value of property alt. */
    48     protected String alt = "";
    49     
    50     /** Holds value of property longDesc. */
    51     protected String longDesc = UNDEFINED_STR;
    52     
    53     /** Holds value of property useMap. */
    54     protected String useMap = UNDEFINED_STR;
    55     
    56     /** Holds value of property ismap. */
    57     protected String ismap = UNDEFINED_STR;
    58     
    59     /** Holds value of property align. */
    60     protected String align = UNDEFINED_STR;
    61     
    62     /** Holds value of property border. */
    63     protected int border = 0;
    64     
    65     /** Holds value of property hSpace. */
    66     protected int hSpace = UNDEFINED_INT;
    67     
    68     /** Holds value of property vSpace. */
    69     protected int vSpace = UNDEFINED_INT;
    70     
    71     /**
    72      * Add or not JSESSIONID
    73      */
    74     protected boolean forceSessionId = true;
    75 
    76     /**
    77      * Remove image from Storage after rendering
    78      */
    79     protected boolean removeAfterRender = false;
    80 
    81     /*
    82      public void writeTag(Writer writer) throws IOException {
    83         writer.write("<img ");
    84         writeAttributes(writer);
    85         writer.write("/>");
    86     }
    87      **/
    88     
    89     public void writeAttributes(Writer wr){
    90         try {
    91             super.writeAttributes(wr);
    92             appendAttributeDeclaration(wr, this.border, "BORDER");
    93             appendAttributeDeclaration(wr, this.hSpace, "HSPACE");
    94             appendAttributeDeclaration(wr, this.height, "HEIGHT");
    95             appendAttributeDeclaration(wr, this.vSpace, "VSPACE");
    96             appendAttributeDeclaration(wr, this.width, "WIDTH");
    97             appendAttributeDeclaration(wr, this.align, "ALIGN");
    98             appendAttributeDeclaration(wr, this.alt, "ALT");
    99             appendAttributeDeclaration(wr, this.ismap, "ISMAP");
   100             appendAttributeDeclaration(wr, this.longDesc, "LONGDESC");
   101             appendAttributeDeclaration(wr, this.src, "SRC");
   102             appendAttributeDeclaration(wr, this.useMap, "USEMAP");
   103         } catch(IOException ioex){
   104             ioex.printStackTrace();
   105         }
   106     }
   107     
   108     protected void reset(){
   109         // width = UNDEFINED_INT;
   110         // height = UNDEFINED_INT;
   111         src = UNDEFINED_STR;
   112         alt = "";
   113         longDesc = UNDEFINED_STR;
   114         useMap = UNDEFINED_STR;
   115         ismap = UNDEFINED_STR;
   116         align = UNDEFINED_STR;
   117         border = 0;
   118         hSpace = UNDEFINED_INT;
   119         vSpace = UNDEFINED_INT;
   120         forceSessionId = true;
   121         removeAfterRender = false;
   122         super.reset();
   123     }
   124     
   125     /** Setter for property width.
   126      * @param width New value of property width.
   127      */
   128     public void setWidth(int width) {
   129         this.width = width;
   130     }
   131     
   132     /** Setter for property height.
   133      * @param height New value of property height.
   134      */
   135     public void setHeight(int height) {
   136         this.height = height;
   137     }
   138     
   139     /** Setter for property src.
   140      * @param src New value of property src.
   141      */
   142     public void setSrc(String src) {
   143         this.src = src;
   144     }
   145     
   146     /** Setter for property alt.
   147      * @param alt New value of property alt.
   148      */
   149     public void setAlt(String alt) {
   150         this.alt = alt;
   151     }
   152     
   153     /** Setter for property longDesc.
   154      * @param longDesc New value of property longDesc.
   155      */
   156     public void setLongdesc(String longDesc) {
   157         this.longDesc = longDesc;
   158     }
   159 
   160     /** Setter for property useMap.
   161      * @param useMap New value of property useMap.
   162      */
   163     public void setUsemap(String useMap) {
   164         this.useMap = useMap;
   165     }
   166     
   167     /** Setter for property ismap.
   168      * @param ismap New value of property ismap.
   169      */
   170     public void setIsmap(String ismap) {
   171         this.ismap = ismap;
   172     }
   173     
   174     /** Setter for property align.
   175      * @param align New value of property align.
   176      */
   177     public void setAlign(String align) {
   178         this.align = align;
   179     }
   180     
   181     /** Setter for property border.
   182      * @param border New value of property border.
   183      */
   184     public void setBorder(int border) {
   185         this.border = border;
   186     }
   187     
   188     /** Setter for property hSpace.
   189      * @param hSpace New value of property hSpace.
   190      */
   191     public void setHspace(int hSpace) {
   192         this.hSpace = hSpace;
   193     }
   194     
   195     /** Setter for property vSpace.
   196      * @param vSpace New value of property vSpace.
   197      */
   198     public void setVspace(int vSpace) {
   199         this.vSpace = vSpace;
   200     }
   201     
   202     protected String getTagName() {
   203         return TAG_NAME;
   204     }
   205     
   206     protected boolean hasBody() {
   207         return false;
   208     }
   209     
   210     protected boolean wellFormed() {
   211         return false;
   212     }
   213     
   214 
   215     /**
   216      * @return Returns the forceSessionId.
   217      */
   218     public boolean isForceSessionId() {
   219     	return forceSessionId;
   220     }
   221 
   222     /**
   223      * @param forceSessionId The forceSessionId to set.
   224      */
   225     public void setForceSessionId(boolean forceSessionId) {
   226     	this.forceSessionId = forceSessionId;
   227     }
   228 
   229 	/**
   230 	 * @return Returns the removeAfterRender.
   231 	 */
   232 	public boolean isRemoveAfterRender() {
   233 		return removeAfterRender;
   234 	}
   235 
   236 	/**
   237 	 * @param removeAfterRender The removeAfterRender to set.
   238 	 */
   239 	public void setRemoveAfterRender(boolean removeAfterRender) {
   240 		this.removeAfterRender = removeAfterRender;
   241 	}
   242 }