001: package com.salmonllc.html;
002:
003: /////////////////////////
004: //$Archive: /SOFIA/SourceCode/com/salmonllc/html/HtmlImage.java $
005: //$Author: Dan $
006: //$Revision: 31 $
007: //$Modtime: 10/30/04 11:24a $
008: /////////////////////////
009:
010: import java.awt.*;
011: import java.io.*;
012: import java.util.Hashtable;
013: import java.util.Vector;
014:
015: import com.salmonllc.localizer.LanguagePreferences;
016: import com.salmonllc.localizer.LanguageResourceFinder;
017: import com.salmonllc.properties.Props;
018: import com.salmonllc.sql.*;
019: import com.salmonllc.util.*;
020:
021: /**
022: * This type can be used to add an image to your page.
023: */
024: public class HtmlImage extends HtmlComponent implements ImageGenerator {
025: public static final String ALIGN_LEFT = "LEFT";
026: public static final String ALIGN_RIGHT = "RIGHT";
027: public static final String ALIGN_TOP = "CENTER";
028: public static final String ALIGN_ABSMIDDLE = "ABSMIDDLE";
029: public static final String ALIGN_ABSBOTTOM = "ABSBOTTOM";
030: public static final String VALIGN_TEXTTOP = "TEXTTOP";
031: public static final String VALIGN_MIDDLE = "MIDDLE";
032: public static final String VALIGN_BASELINE = "BASELINE";
033: public static final String ALIGN_BOTTOM = "BOTTOM";
034: public static final String ALIGN_NONE = "";
035: //
036: public static final int SIZE_PIXELS = 0;
037: public static final int SIZE_PERCENT = 1;
038: //
039: public static final String STYLE_RECTANGLE = "RECTANGLE";
040: public static final String STYLE_OVAL = "OVAL";
041: public static final String STYLE_PIXEL = "PIXEL";
042: //
043: private String _source = "";
044: private String _alt = "";
045: private String _align = ALIGN_NONE;
046: //
047: private int _width = -1;
048: private int _height = -1;
049: private int _border = 0;
050: private int _hSpace = -1;
051: private int _vSpace = -1;
052: //
053: private int _widthSizeOption = SIZE_PIXELS;
054: private int _heightSizeOption = SIZE_PIXELS;
055: //
056: private Vector _areaMaps;
057: private HtmlImageMapArea _submit = null;
058: //
059: private String _title;
060:
061: // Stuff for image generation
062: private Font _font;
063: private Color _textColor = Color.black;
064: private Color _backgroundColor = Color.lightGray;
065: private Color _topLeftBorder = Color.white;
066: private Color _bottomRightBorder = Color.gray;
067: private Color _transparentColor = Color.magenta;
068: private String _style = STYLE_RECTANGLE;
069: private String _imageURL;
070: //
071: private boolean _generateImage = false;
072: private String _theme = null;
073: private boolean _useCache = true;
074: private long _cacheKey = 0;
075: private int _count = 0;
076: private boolean _enabled = true;
077: private String _onLoad;
078:
079: private DataStoreEvaluator _dsEval = null;
080: private DataStoreEvaluator _altEval = null;
081:
082: private String _sourceLocaleKey = null;
083: private String _altLocaleKey = null;
084: private String _textLocaleKey = null;
085: private boolean _updateLocale = false;
086: private String _useMap;
087:
088: /**
089: * Constructs an new Image
090: * @param source - image that is being used.
091: * @param p The page the image will be placed in
092: */
093: public HtmlImage(String source, HtmlPage p) {
094: this ("", source, p);
095: }
096:
097: /**
098: * Constructs a new Image.
099: * @param name Each component on a page must have a unique name.
100: * @param text The Text to put on the button.
101: * @param width The width of the button in pixels
102: * @param height The height of the button in pixels
103: * @param p The page the image will be placed in
104: */
105: public HtmlImage(String name, String text, int width, int height,
106: HtmlPage p) {
107: this (name, text, width, height, null, p);
108: }
109:
110: /**
111: * Constructs a new Image.
112: * @param name Each component on a page must have a unique name.
113: * @param text The Text to put on the button.
114: * @param width The width of the button in pixels
115: * @param height The height of the button in pixels
116: * @param theme The theme to use for the button image
117: * @param p The page the image will be placed in
118: */
119: public HtmlImage(String name, String text, int width, int height,
120: String theme, HtmlPage p) {
121: super (name, p);
122: _source = text;
123: _width = width;
124: _height = height > 0 ? height : getPage().getPageProperties()
125: .getIntProperty(Props.SUBMIT_IMAGE_DEFAULT_HEIGHT);
126: _generateImage = true;
127: p.registerImageGenerator(getFullName(), this );
128: setTheme(theme);
129: }
130:
131: /**
132: * Constructs a new Image. The width of the Image is determined by the size of the text.
133: * @param name Each component on a page must have a unique name.
134: * @param text The Text to put on the button.
135: * @param height The height of the button in pixels
136: * @param p The page the button will be placed in
137: */
138: public HtmlImage(String name, String text, int height, HtmlPage p) {
139: this (name, text, -1, height, null, p);
140: }
141:
142: /**
143: * Constructs a new Image. The width of the Image is determined by the size of the text.
144: * @param name Each component on a page must have a unique name.
145: * @param text The Text to put on the button.
146: * @param height The height of the button in pixels
147: * @param theme The theme to use for the button image
148: * @param p The page the button will be placed in
149: */
150: public HtmlImage(String name, String text, int height,
151: String theme, HtmlPage p) {
152: this (name, text, -1, height, theme, p);
153: }
154:
155: /**
156: * Constructs an image object for the page
157: */
158: public HtmlImage(String name, String source, HtmlPage p) {
159: super (name, p);
160: _source = source;
161: _generateImage = false;
162: }
163:
164: /**
165: * Use this method to add an image area map to the image. When the user clicks on a region of the image a link will be followed or a submit will be performed.
166: */
167: public void addAreaMap(HtmlImageMapArea map) {
168: if (_areaMaps == null)
169: _areaMaps = new Vector();
170:
171: _areaMaps.addElement(map);
172: map.setImage(this );
173: }
174:
175: public void clearSubmit() {
176: _submit = null;
177: }
178:
179: public boolean executeEvent(int eventType) throws Exception {
180: if (_areaMaps != null) {
181: if (_submit != null
182: && eventType == HtmlComponent.EVENT_SUBMIT) {
183: boolean retVal = _submit.executeEvent(eventType);
184: _submit = null;
185: return retVal;
186: }
187: }
188:
189: return true;
190: }
191:
192: public void generateHTML(java.io.PrintWriter p, int rowNo)
193: throws Exception {
194: if (!getVisible())
195: return;
196:
197: processLocaleInfo();
198:
199: if (_dsEval != null) {
200: if (rowNo > -1)
201: _source = _dsEval.evaluateRowFormat(rowNo);
202: else
203: _source = _dsEval.evaluateRowFormat();
204:
205: }
206:
207: String source = _source;
208: if (_generateImage) {
209: // sr 11-01-2000 this replaces the call to generateImageURL() in the constructor
210: if (_imageURL == null) {
211: _imageURL = generateImageURL();
212: }
213: source = _imageURL + "default.dgif";
214: }
215: //else if (source != null) {
216: // source = Util.urlEncode(source,false);
217: //}
218:
219: //
220: if (!_enabled) {
221: if (_generateImage) {
222: source = _imageURL + "disabled.dgif";
223: if (!_useCache)
224: source += "?ct=" + _count++;
225: }
226: }
227:
228: //
229: source = translateSiteMapURL(source);
230:
231: StringBuffer out = new StringBuffer("<IMG SRC=\"" + source
232: + "\"");
233:
234: // NAME
235: if (!Util.isNull(_name) && !Util.isEmpty(_name)) {
236: out.append(" NAME=\"" + getFullName() + "\"");
237: }
238:
239: // ALT
240: String alt = _alt;
241: if (_altEval != null) {
242: if (rowNo > -1)
243: alt = _altEval.evaluateRowFormat(rowNo);
244: else
245: alt = _altEval.evaluateRowFormat();
246: }
247: if (!Util.isNull(alt) && !Util.isEmpty(alt)) {
248: out.append(" ALT=\"" + alt + "\"");
249: }
250:
251: // ALIGN
252: if (!Util.isNull(_align) && !Util.isEmpty(_align)) {
253: out.append(" ALIGN=\"" + _align + "\"");
254: }
255:
256: if (!Util.isNull(_onLoad) && !Util.isEmpty(_onLoad)) {
257: out.append(" ONLOAD=\"" + _onLoad + "\"");
258: }
259:
260: // BORDER
261: if (_border > -1) {
262: out.append(" BORDER=\"" + _border + "\"");
263: }
264:
265: // WIDTH
266: if (_width > -1) {
267: out.append(" WIDTH=\"" + _width
268: + (_widthSizeOption == SIZE_PERCENT ? "%" : "")
269: + "\"");
270: }
271:
272: // HEIGHT
273: if (_height > -1) {
274: out.append(" HEIGHT=\"" + _height
275: + (_heightSizeOption == SIZE_PERCENT ? "%" : "")
276: + "\"");
277: }
278:
279: // HSPACE
280: if (_hSpace > -1) {
281: out.append(" HSPACE=\"" + _hSpace + "\"");
282: }
283: // VSPACE
284: if (_vSpace > -1) {
285: out.append(" VSPACE=\"" + _vSpace + "\"");
286: }
287:
288: // USEMAP
289: if (_useMap != null)
290: out.append(" USEMAP=\"" + _useMap + "\"");
291: else if (_areaMaps != null) {
292: out.append(" USEMAP=\"#" + getFullName()
293: + "_IMAGE_AREA_MAP\"");
294: }
295:
296: // TITLE
297: if (_title != null)
298: out.append(" TITLE=\"" + _title + "\"");
299:
300: //
301: out.append(">");
302: p.print(out);
303: if (_areaMaps != null && _useMap == null) {
304: p.print("<MAP NAME = \"" + getFullName()
305: + "_IMAGE_AREA_MAP\">");
306: for (int i = 0; i < _areaMaps.size(); i++)
307: ((HtmlImageMapArea) _areaMaps.elementAt(i))
308: .generateHTML(p, rowNo);
309: p.print("</MAP>");
310: }
311: }
312:
313: public void generateImage(String img, OutputStream out)
314: throws IOException {
315: //create an image to draw
316: ImageFactory fact = new ImageFactory();
317: Image i = null;
318:
319: if (_style.equals(STYLE_OVAL)) {
320: if (_width > 0) {
321: i = fact.createOvalButton(_width, _height, _font,
322: _source, _textColor, _backgroundColor,
323: _topLeftBorder, _bottomRightBorder,
324: _transparentColor, false, _enabled);
325: } else {
326: i = fact.createOvalButton(_height, _font, _source,
327: _textColor, _backgroundColor, _topLeftBorder,
328: _bottomRightBorder, _transparentColor, false,
329: _enabled);
330: }
331: }
332: if (_style.equals(STYLE_PIXEL)) {
333: i = fact.createOnePixelImage(_backgroundColor);
334: } else if (_width > 0) {
335: i = fact
336: .createRectangleButton(_width, _height, _font,
337: _source, _textColor, _backgroundColor,
338: _topLeftBorder, _bottomRightBorder, false,
339: _enabled);
340: } else {
341: i = fact.createRectangleButton(_height, _font, _source,
342: _textColor, _backgroundColor, _topLeftBorder,
343: _bottomRightBorder, false, _enabled);
344: }
345:
346: GifEncoder g = new GifEncoder(i, out, true, _transparentColor);
347: g.encode();
348:
349: }
350:
351: public void generateInitialHTML(PrintWriter p) throws Exception {
352: if (_areaMaps != null) {
353: for (int i = 0; i < _areaMaps.size(); i++)
354: ((HtmlImageMapArea) _areaMaps.elementAt(i))
355: .generateInitialHTML(p);
356: }
357: }
358:
359: /**
360: * Returns the alignment property for the image.
361: */
362: public String getAlign() {
363: return _align;
364: }
365:
366: /**
367: * Returns the tool tip for the image
368: */
369: public String getAlt() {
370: return _alt;
371: }
372:
373: /**
374: * This method gets the DataStoreEvaluator being used for alt expressions.
375: * @return DataStoreEvaluator
376: * @see DataStoreEvaluator
377: */
378: public DataStoreEvaluator getAltExpression() {
379: return _altEval;
380: }
381:
382: /**
383: * Returns the Locale key used for the alt texy
384: */
385: public String getAltLocaleKey() {
386: return _altLocaleKey;
387: }
388:
389: /**
390: * This method returns the background color if the image is generated
391: */
392: public Color getBackgroundColor() {
393: return _backgroundColor;
394: }
395:
396: /**
397: * This method returns the border width of the image in pixels.
398: */
399: public int getBorder() {
400: return _border;
401: }
402:
403: /**
404: * This method returns the bottom right border color if the image is generated
405: */
406: public Color getBottomRightColor() {
407: return _bottomRightBorder;
408: }
409:
410: public long getCacheKey() {
411: return _cacheKey;
412: }
413:
414: /**
415: * This method gets the Display Style for a generated image button. Valid Values are STYLE_RECTANGLE and STYLE_OVAL
416: */
417: public String getDisplayStyle() {
418: return _style;
419: }
420:
421: /**
422: * This method returns whether or not clicking on the image will do a submit.
423: */
424: public boolean getEnabled() {
425: return _enabled;
426: }
427:
428: /**
429: * This method gets the DataStoreEvaluator being used for expressions.
430: * @return DataStoreEvaluator
431: * @see DataStoreEvaluator
432: */
433: public DataStoreEvaluator getExpression() {
434: return _dsEval;
435: }
436:
437: /**
438: * This method returns the font used for dynamically generated images.
439: */
440: public Font getFont() {
441: return _font;
442: }
443:
444: /**
445: * This method returns the height of the image.
446: */
447: public int getHeight() {
448: return _height;
449: }
450:
451: /**
452: * This method returns SIZE_PIXELS or SIZE_PERCENT.
453: */
454: public int getHeightSizeOption() {
455: return _heightSizeOption;
456: }
457:
458: /**
459: * This method returns the horizontal space around the the image.
460: */
461: public int getHorizontalSpace() {
462: return _hSpace;
463: }
464:
465: /**
466: * This method gets the source url for the image.
467: */
468: public String getSource() {
469: return _source;
470: }
471:
472: /**
473: * Returns the Locale key used for the source url
474: */
475: public String getSourceLocaleKey() {
476: return _sourceLocaleKey;
477: }
478:
479: /**
480: * This method returns the text for the button
481: * @return java.lang.String
482: */
483: public String getText() {
484: if (_generateImage)
485: return _source;
486: else
487: return null;
488: }
489:
490: /**
491: * This method returns the text color if the image is generated
492: */
493: public Color getTextColor() {
494: return _textColor;
495: }
496:
497: /**
498: * Returns the Locale key used for the text of this component
499: */
500: public String getTextLocaleKey() {
501: return _textLocaleKey;
502: }
503:
504: /**
505: * This method returns the property theme for the component.
506: * @return
507: */
508: public String getTheme() {
509: return _theme;
510: }
511:
512: /**
513: * This method returns the top and left border color if the image is generated
514: */
515: public Color getTopLeftColor() {
516: return _topLeftBorder;
517: }
518:
519: /**
520: * This method returns the color that will be represent transparent if the image is generated
521: */
522: public Color getTransparentColor() {
523: return _transparentColor;
524: }
525:
526: /**
527: * If the image is dynamically generated, this method will indicate whether or not the Objectstore should cache it.
528: */
529: public boolean getUseCache() {
530: return _useCache;
531: }
532:
533: /**
534: * This method returns the vertical space around the the image.
535: */
536: public int getVerticalSpace() {
537: return _vSpace;
538: }
539:
540: /**
541: * This method returns the width of the image.
542: */
543: public int getWidth() {
544: return _width;
545: }
546:
547: /**
548: * This method returns SIZE_PIXELS or SIZE_PERCENT.
549: */
550: public int getWidthSizeOption() {
551: return _widthSizeOption;
552: }
553:
554: private void processLocaleInfo() {
555: if (_updateLocale) {
556: _updateLocale = false;
557: LanguagePreferences p = getPage().getLanguagePreferences();
558: if (_sourceLocaleKey != null) {
559: String newSource = LanguageResourceFinder.getResource(
560: getPage().getApplicationName(),
561: _sourceLocaleKey, p);
562: if (newSource != null)
563: setSource(newSource);
564: }
565: if (_textLocaleKey != null) {
566: String newText = LanguageResourceFinder.getResource(
567: getPage().getApplicationName(), _textLocaleKey,
568: p);
569: if (newText != null)
570: setText(newText);
571: }
572: if (_altLocaleKey != null) {
573: String newAlt = LanguageResourceFinder.getResource(
574: getPage().getApplicationName(), _altLocaleKey,
575: p);
576: if (newAlt != null)
577: setAlt(newAlt);
578: }
579: }
580: }
581:
582: public boolean processParms(Hashtable parms, int rowNo)
583: throws Exception {
584:
585: if (_areaMaps != null) {
586: for (int i = 0; i < _areaMaps.size(); i++) {
587: if (((HtmlImageMapArea) _areaMaps.elementAt(i))
588: .processParms(parms, rowNo)) {
589: _submit = (HtmlImageMapArea) _areaMaps.elementAt(i);
590: return true;
591: }
592: }
593: }
594: return false;
595:
596: }
597:
598: /**
599: * Sets the alignment property for the image.
600: */
601:
602: public void setAlign(String align) {
603: _align = align;
604: }
605:
606: /**
607: * This method sets the tool tip for the image
608: */
609: public void setAlt(String alt) {
610: _alt = alt;
611: }
612:
613: /**
614: * Use this method to bind the alt property to an expression in a DataStore
615: * @param ds The DataStore to bind to.
616: * @param expression The expression to bind to.
617: * @see DataStoreEvaluator
618: */
619: public void setAltExpression(DataStoreBuffer ds, String expression)
620: throws Exception {
621: _altEval = new DataStoreEvaluator(ds, expression);
622: }
623:
624: /**
625: * Use this method to bind the alt property to an expression in a DataStore
626: * @param ds The DataStore to bind to.
627: * @param expression The expression to bind to.
628: * @see DataStoreEvaluator
629: */
630: public void setAltExpression(DataStoreBuffer ds,
631: DataStoreExpression expression) throws Exception {
632: _altEval = new DataStoreEvaluator(ds, expression);
633: }
634:
635: /**
636: * Sets the Locale key used for the Alt text
637: */
638: public void setAltLocaleKey(String altLocaleKey) {
639: _altLocaleKey = altLocaleKey;
640: _updateLocale = true;
641:
642: }
643:
644: /**
645: * This method sets the background color for the generated image
646: */
647: public void setBackgroundColor(Color c) {
648: _backgroundColor = c;
649: }
650:
651: /**
652: * This method sets the border border of the image in pixels.
653: */
654: public void setBorder(int border) {
655: _border = border;
656: }
657:
658: /**
659: * This method sets the bottom and right border color for the generated image
660: */
661: public void setBottomRightColor(Color c) {
662: _bottomRightBorder = c;
663: }
664:
665: public void setCacheKey(long key) {
666: _cacheKey = key;
667: }
668:
669: /**
670: * This method will set whether or not clicking on the image will do a submit.
671: */
672: public void setEnabled(boolean enabled) {
673: _enabled = enabled;
674: }
675:
676: /**
677: * Use this method to bind this component to an expression in a DataStore
678: * @param ds The DataStore to bind to.
679: * @param expression The expression to bind to.
680: * @see DataStoreEvaluator
681: */
682: public void setExpression(DataStoreBuffer ds,
683: DataStoreExpression expression) throws Exception {
684:
685: _dsEval = new DataStoreEvaluator(ds, expression);
686: }
687:
688: /**
689: * Use this method to bind this component to an expression in a DataStoreBuffer. The resulting expression wil be formatted according to the pattern specified.
690: * @param ds The DataStore to bind to.
691: * @param expression The expression to bind to.
692: * @param format The patter to use to format the result
693: * @see com.salmonllc.sql.DataStore#setFormat
694: * @see DataStoreEvaluator
695: */
696: public void setExpression(DataStoreBuffer ds,
697: DataStoreExpression expression, String format)
698: throws Exception {
699: _dsEval = new DataStoreEvaluator(ds, expression, format);
700: }
701:
702: /**
703: * Use this method to bind this component to an expression in a DataStore
704: * @param ds The DataStore to bind to.
705: * @param expression The expression to bind to.
706: * @see DataStoreEvaluator
707: */
708: public void setExpression(DataStoreBuffer ds, String expression)
709: throws Exception {
710: _dsEval = new DataStoreEvaluator(ds, expression);
711: }
712:
713: /**
714: * Use this method to bind this component to an expression in a DataStoreBuffer. The resulting expression wil be formatted according to the pattern specified.
715: * @param ds The DataStore to bind to.
716: * @param expression The expression to bind to.
717: * @param format The patter to use to format the result
718: * @see com.salmonllc.sql.DataStore#setFormat
719: * @see DataStoreEvaluator
720: */
721: public void setExpression(DataStoreBuffer ds, String expression,
722: String format) throws Exception {
723: _dsEval = new DataStoreEvaluator(ds, expression, format);
724: }
725:
726: /**
727: * This method sets the font used for dynamically generated images.
728: */
729: public void setFont(Font f) {
730: _font = f;
731: }
732:
733: /**
734: * This method sets the height of the image.
735: */
736: public void setHeight(int height) {
737: _height = height;
738: }
739:
740: /**
741: * Valid values for this method are SIZE_PIXELS or SIZE_PERCENT.
742: */
743: public void setHeightSizeOption(int option) {
744: _heightSizeOption = option;
745: }
746:
747: /**
748: * This method sets the Horizontal space around the image in pixels.
749: */
750: public void setHorizontalSpace(int width) {
751: _hSpace = width;
752: }
753:
754: /**
755: * Sets the alignment property for the image.
756: */
757:
758: public void setOnLoad(String onload) {
759: _onLoad = onload;
760: }
761:
762: /**
763: * This method sets the source url for the image.
764: */
765: public void setSource(String source) {
766: _source = source;
767: }
768:
769: /**
770: * Sets the Locale key used for the image URL
771: */
772: public void setSourceLocaleKey(String sourceLocaleKey) {
773: _sourceLocaleKey = sourceLocaleKey;
774: _updateLocale = true;
775:
776: }
777:
778: /**
779: * This method sets the text for the for the dynamically generated image.
780: */
781: public void setText(String text) {
782: if (_generateImage) {
783: _source = text;
784: _useCache = false;
785: }
786: }
787:
788: /**
789: * This method sets the text color for the generated image
790: */
791: public void setTextColor(Color c) {
792: _textColor = c;
793: }
794:
795: /**
796: * Returns the Locale key used for text
797: */
798: public void setTextLocaleKey(String textLocaleKey) {
799: _textLocaleKey = textLocaleKey;
800: _updateLocale = true;
801: }
802:
803: /**
804: * This method sets the property theme for the component.
805: * @param theme The theme to use.
806: */
807: public void setTheme(String theme) {
808: Props props = getPage().getPageProperties();
809:
810: String font = props.getThemeProperty(theme,
811: Props.SUBMIT_IMAGE_FONT_FACE);
812: if (font == null)
813: font = "Helvetica";
814: int size = props.getThemeIntProperty(theme,
815: Props.SUBMIT_IMAGE_FONT_SIZE);
816: if (size == -1)
817: size = 12;
818: int fontStyle = props.getThemeIntProperty(theme,
819: Props.SUBMIT_IMAGE_FONT_STYLE);
820: if ((fontStyle < 0) || (fontStyle > 3))
821: fontStyle = Font.PLAIN;
822: _font = new Font(font, fontStyle, size);
823:
824: Color c = props.getThemeColorProperty(theme,
825: Props.SUBMIT_IMAGE_TEXT_COLOR);
826: if (c != null)
827: _textColor = c;
828:
829: c = props.getThemeColorProperty(theme,
830: Props.SUBMIT_IMAGE_BACKGROUND_COLOR);
831: if (c != null)
832: _backgroundColor = c;
833:
834: if (_height == -1)
835: _height = props.getThemeIntProperty(theme,
836: Props.SUBMIT_IMAGE_DEFAULT_HEIGHT);
837:
838: c = props.getThemeColorProperty(theme,
839: Props.SUBMIT_IMAGE_TOPLEFT_BORDER_COLOR);
840: if (c != null)
841: _topLeftBorder = c;
842:
843: c = props.getThemeColorProperty(theme,
844: Props.SUBMIT_IMAGE_BOTTOMRIGHT_BORDER_COLOR);
845: if (c != null)
846: _bottomRightBorder = c;
847:
848: c = props.getThemeColorProperty(theme,
849: Props.SUBMIT_IMAGE_TRANSPARENT_COLOR);
850: if (c != null)
851: _transparentColor = c;
852:
853: String style = props.getThemeProperty(theme,
854: Props.SUBMIT_IMAGE_STYLE);
855: if (style != null) {
856: if (style.toUpperCase().equals(STYLE_OVAL))
857: _style = STYLE_OVAL;
858: else
859: _style = STYLE_RECTANGLE;
860: }
861:
862: _theme = theme;
863: }
864:
865: /**
866: * This method sets the top and left border color for the generated image
867: */
868: public void setTopLeftColor(Color c) {
869: _topLeftBorder = c;
870: }
871:
872: /**
873: * This method sets the color that represents tranparent for the generated image
874: */
875: public void setTransparentColor(Color c) {
876: _transparentColor = c;
877: }
878:
879: /**
880: * This method sets the Vertical space around the image in pixels.
881: */
882: public void setVerticalSpace(int width) {
883: _vSpace = width;
884: }
885:
886: /**
887: * This method sets the width of the image.
888: */
889: public void setWidth(int width) {
890: _width = width;
891: }
892:
893: /**
894: * Valid values for this method are SIZE_PIXELS or SIZE_PERCENT.
895: */
896: public void setWidthSizeOption(int option) {
897: _widthSizeOption = option;
898: }
899:
900: /**
901: * Updates the text and format for the current local
902: */
903: public void updateLocale() {
904: _updateLocale = true;
905: }
906:
907: /**
908: * This method gets the Display Style for a generated image button. Valid Values are STYLE_RECTANGLE and STYLE_OVAL
909: */
910: public void setDisplayStyle(String style) {
911: _style = style;
912: }
913:
914: /**
915: * This method returns a specific use map for the image that is defined elsewhere in the JSP
916: */
917: public String getUseMap() {
918: return _useMap;
919: }
920:
921: /**
922: * If you want to specify a specific use map for the image that is defined elsewhere in the JSP, you can use this method
923: */
924:
925: public void setUseMap(String useMap) {
926: _useMap = useMap;
927: }
928:
929: /**
930: * @return Returns the _title.
931: */
932: public String getTitle() {
933: return _title;
934: }
935:
936: /**
937: * @param string The _title to set.
938: */
939: public void setTitle(String string) {
940: this._title = string;
941: }
942: }
|