001: /*
002: * @author <a href="mailto:oliver.wehrens@aei.mpg.de">Oliver Wehrens</a>
003: * @version $Id: ImageBean.java 6385 2007-10-25 14:02:26Z wehrens $
004: */
005: package org.gridsphere.provider.portletui.beans;
006:
007: /**
008: * A <code>ImageBean</code> represents an image element
009: */
010: public class ImageBean extends BaseComponentBean implements TagBean {
011:
012: public static final String NAME = "im";
013: public String src = "";
014: public String alt = null;
015: public String title = null;
016: public String border = "0";
017: protected String width = null;
018: protected String height = null;
019: protected String align = null;
020:
021: /**
022: * Constructs a default image bean
023: */
024: public ImageBean() {
025: super (NAME);
026: }
027:
028: /**
029: * Constructs an image bean using a supplied bean identifier
030: *
031: * @param beanId the bean identifier
032: */
033: public ImageBean(String beanId) {
034: super (NAME);
035: this .beanId = beanId;
036: }
037:
038: /**
039: * Returns the image source
040: *
041: * @return the image source
042: */
043: public String getSrc() {
044: return src;
045: }
046:
047: /**
048: * Sets the image source
049: *
050: * @param src the image source
051: */
052: public void setSrc(String src) {
053: this .src = src;
054: }
055:
056: /**
057: * Returns the image alt tag
058: *
059: * @return the image alt tag
060: */
061: public String getAlt() {
062: return alt;
063: }
064:
065: /**
066: * Sets the image alt tag
067: *
068: * @param alt the image alt tag
069: */
070: public void setAlt(String alt) {
071: this .alt = alt;
072: }
073:
074: /**
075: * Returns the image title
076: *
077: * @return the image title
078: */
079: public String getTitle() {
080: return title;
081: }
082:
083: /**
084: * Sets the image title
085: *
086: * @param title the image title
087: */
088: public void setTitle(String title) {
089: this .title = title;
090: }
091:
092: /**
093: * Sets the table alignment e.g. "left", "top", "bottom" or "right"
094: *
095: * @param align the table alignment
096: */
097: public void setAlign(String align) {
098: this .align = align;
099: }
100:
101: /**
102: * Returns the table alignment e.g. "left", "top", "bottom" or "right"
103: *
104: * @return the table alignment
105: */
106: public String getAlign() {
107: return align;
108: }
109:
110: /**
111: * Sets the table cell width
112: *
113: * @param width the table cell width
114: */
115: public void setWidth(String width) {
116: this .width = width;
117: }
118:
119: /**
120: * Returns the table cell width
121: *
122: * @return the table cell width
123: */
124: public String getWidth() {
125: return width;
126: }
127:
128: /**
129: * Sets the table cell height
130: *
131: * @param height the table cell height
132: */
133: public void setHeight(String height) {
134: this .height = height;
135: }
136:
137: /**
138: * Returns the table cell height
139: *
140: * @return the table cell height
141: */
142: public String getHeight() {
143: return height;
144: }
145:
146: /**
147: * Return the image title border
148: *
149: * @return the image title border
150: */
151: public String getBorder() {
152: return border;
153: }
154:
155: /**
156: * Sets the image title border
157: *
158: * @param border the image title border
159: */
160: public void setBorder(String border) {
161: this .border = border;
162: }
163:
164: public String toStartString() {
165: if (src.equals(""))
166: return "";
167: StringBuffer sb = new StringBuffer();
168: // the 'border' attribute has been removed for XHTML 1.0 Strict compliance
169: sb.append("<img src=\"" + this .src + "\"");
170: if (width != null)
171: sb.append(" width=\"" + width + "\"");
172: if (height != null)
173: sb.append(" height=\"" + height + "\"");
174: if (align != null)
175: sb.append(" align=\"" + align + "\"");
176: // the else case should NEVER be reached, the 'alt' attribute should ALWAYS be specified!
177: if (alt != null)
178: sb.append(" alt=\"" + alt + "\"");
179: else
180: sb.append(" alt=\"image\"");
181: if (title != null)
182: sb.append(" title=\"" + title + "\"");
183: sb.append(" />");
184: return sb.toString();
185: }
186:
187: public String toEndString() {
188: return "";
189: }
190: }
|