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