KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > frontend > photoalbum > CmsPhotoAlbumConfiguration


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src-modules/org/opencms/frontend/photoalbum/CmsPhotoAlbumConfiguration.java,v $
3  * Date : $Date: 2006/03/27 14:52:22 $
4  * Version: $Revision: 1.2 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (C) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.frontend.photoalbum;
33
34 import com.alkacon.simapi.Simapi;
35
36 import org.opencms.file.CmsFile;
37 import org.opencms.file.CmsObject;
38 import org.opencms.jsp.CmsJspActionElement;
39 import org.opencms.loader.CmsImageScaler;
40 import org.opencms.main.CmsException;
41 import org.opencms.util.CmsStringUtil;
42 import org.opencms.xml.content.CmsXmlContent;
43 import org.opencms.xml.content.CmsXmlContentFactory;
44 import org.opencms.xml.types.CmsXmlHtmlValue;
45
46 import java.awt.Color JavaDoc;
47 import java.util.List JavaDoc;
48 import java.util.Locale JavaDoc;
49
50 /**
51  * Represents the frontend configuration of a photo album.<p>
52  *
53  * @author Andreas Zahner
54  *
55  * @version $Revision: 1.2 $
56  *
57  * @since 6.1.3
58  */

59 public class CmsPhotoAlbumConfiguration {
60
61     /** Image filter: delimiter character. */
62     public static final String JavaDoc FILTER_DELIMITER = ".";
63     
64     /** Image filter: no filter selected. */
65     public static final String JavaDoc FILTER_NONE = "none";
66     
67     /** Navigation element position: on the bottom, above the editable text element. */
68     public static final String JavaDoc NAVPOS_BOTTOM_ABOVE = "b_a";
69
70     /** Navigation element position: on the bottom, below the editable text element. */
71     public static final String JavaDoc NAVPOS_BOTTOM_BELOW = "b_b";
72
73     /** Navigation element position: on top, above the editable text element. */
74     public static final String JavaDoc NAVPOS_TOP_ABOVE = "t_a";
75
76     /** Navigation element position: on top, below the editable text element. */
77     public static final String JavaDoc NAVPOS_TOP_BELOW = "t_b";
78
79     /** Configuration node name for the align navigation node. */
80     public static final String JavaDoc NODE_ALIGN_NAVIGATION = "AlignNavigation";
81
82     /** Configuration node name for the align navigation node. */
83     public static final String JavaDoc NODE_ALIGN_TITLE = "AlignTitle";
84
85     /** Configuration node name for the background node. */
86     public static final String JavaDoc NODE_BACKGROUND = "Background";
87
88     /** Configuration node name for the columns node. */
89     public static final String JavaDoc NODE_COLS = "Cols";
90
91     /** Configuration node name for the detail node. */
92     public static final String JavaDoc NODE_DETAIL = "Details";
93     
94     /** Configuration node name for the filter node. */
95     public static final String JavaDoc NODE_FILTER = "Filter";
96
97     /** Configuration node name for the high quality node. */
98     public static final String JavaDoc NODE_HIGHQUALITY = "HighQuality";
99
100     /** Configuration node name for the navigation position node. */
101     public static final String JavaDoc NODE_NAVIGATION_POSITION = "NavigationPosition";
102
103     /** Configuration node name for the rows node. */
104     public static final String JavaDoc NODE_ROWS = "Rows";
105
106     /** Configuration node name for the show description node. */
107     public static final String JavaDoc NODE_SHOWDESCRIPTION = "ShowDescription";
108
109     /** Configuration node name for the show original link node. */
110     public static final String JavaDoc NODE_SHOWLINKORIGINAL = "ShowLinkOriginal";
111
112     /** Configuration node name for the show resource name as title node. */
113     public static final String JavaDoc NODE_SHOWRESOURCENAMEASTITLE = "ShowResourceNameAsTitle";
114
115     /** Configuration node name for the show title node. */
116     public static final String JavaDoc NODE_SHOWTITLE = "ShowTitle";
117
118     /** Configuration node name for the size node. */
119     public static final String JavaDoc NODE_SIZE = "Size";
120
121     /** Configuration node name for the bottom text node. */
122     public static final String JavaDoc NODE_TEXTBOTTOM = "TextBottom";
123
124     /** Configuration node name for the top text node. */
125     public static final String JavaDoc NODE_TEXTTOP = "TextTop";
126
127     /** Configuration node name for the thumbs node. */
128     public static final String JavaDoc NODE_THUMBS = "Thumbs";
129
130     /** Configuration node name for the title node. */
131     public static final String JavaDoc NODE_TITLE = "Title";
132
133     /** Configuration node name for the vfs folder node. */
134     public static final String JavaDoc NODE_VFSFOLDER = "VfsFolder";
135
136     /** The image album title. */
137     private String JavaDoc m_albumTitle;
138
139     /** The alignment of the album navigation elements. */
140     private String JavaDoc m_alignNavigation;
141
142     /** The alignment of the image titles on the detail view. */
143     private String JavaDoc m_detailAlignTitle;
144
145     /** The image scaler for the detail image. */
146     private CmsImageScaler m_detailImageScaler;
147
148     /** The navigation element position on the pages. */
149     private String JavaDoc m_navigationPosition;
150
151     /** The flag if the image description is shown on the detail view. */
152     private boolean m_showDetailDescription;
153
154     /** The flag if the image original link is shown on the detail view. */
155     private boolean m_showDetailOriginalLink;
156
157     /** The flag if the image title is shown on the detail view. */
158     private boolean m_showDetailTitle;
159
160     /** The flag if the image resource name is shown as title if no title is found. */
161     private boolean m_showResourceNameAsTitle;
162
163     /** The flag if the image title is shown on the thumbnail overview. */
164     private boolean m_showThumbTitle;
165
166     /** The alignment of the image titles on the thumbnail overview. */
167     private String JavaDoc m_thumbAlignTitle;
168
169     /** The number of image columns on the thumbnail overview. */
170     private int m_thumbCols;
171
172     /** The image scaler for the thumbnails. */
173     private CmsImageScaler m_thumbNailScaler;
174
175     /** The number of image rows on the thumbnail overview. */
176     private int m_thumbRows;
177
178     /** The optional bottom text on the thumbnail overview. */
179     private String JavaDoc m_thumbTextBottom;
180
181     /** The optional top text on the thumbnail overview. */
182     private String JavaDoc m_thumbTextTop;
183
184     /** The OpenCms VFS path of the image gallery to use. */
185     private String JavaDoc m_vfsPathGallery;
186
187     /**
188      * Empty constructor that does no initialization.<p>
189      */

190     public CmsPhotoAlbumConfiguration() {
191
192         // initialize member objects
193
initMembers();
194     }
195
196     /**
197      * Constructor that initializes the configuration using the currently requested URI.<p>
198      *
199      * @param jsp the initialized CmsJspActionElement to access the OpenCms API
200      * @throws Exception if parsing the configuration fails
201      */

202     public CmsPhotoAlbumConfiguration(CmsJspActionElement jsp)
203     throws Exception JavaDoc {
204
205         init(jsp, null);
206     }
207
208     /**
209      * Constructor that initializes the configuration from the given configuration URI.<p>
210      *
211      * @param jsp the initialized CmsJspActionElement to access the OpenCms API
212      * @param configUri URI of the configuration file, if not provided, current URI is used for configuration
213      * @throws Exception if parsing the configuration fails
214      */

215     public CmsPhotoAlbumConfiguration(CmsJspActionElement jsp, String JavaDoc configUri)
216     throws Exception JavaDoc {
217
218         init(jsp, configUri);
219     }
220
221     /**
222      * Returns the image album title.<p>
223      *
224      * @return the image album title
225      */

226     public String JavaDoc getAlbumTitle() {
227
228         return m_albumTitle;
229     }
230
231     /**
232      * Returns the alignment of the album navigation elements.<p>
233      *
234      * @return the alignment of the album navigation elements
235      */

236     public String JavaDoc getAlignNavigation() {
237
238         return m_alignNavigation;
239     }
240
241     /**
242      * Returns the alignment of the image titles on the detail view.<p>
243      *
244      * @return the alignment of the image titles on the detail view
245      */

246     public String JavaDoc getDetailAlignTitle() {
247
248         return m_detailAlignTitle;
249     }
250
251     /**
252      * Returns the image scaler for the detail image.<p>
253      *
254      * @return the image scaler for the detail image
255      */

256     public CmsImageScaler getDetailImageScaler() {
257
258         return m_detailImageScaler;
259     }
260
261     /**
262      * Returns the navigation element position on the pages.<p>
263      *
264      * @return the navigation element position on the pages
265      */

266     public String JavaDoc getNavigationPosition() {
267
268         return m_navigationPosition;
269     }
270
271     /**
272      * Returns the alignment of the image titles on the thumbnail overview.<p>
273      *
274      * @return the alignment of the image titles on the thumbnail overview
275      */

276     public String JavaDoc getThumbAlignTitle() {
277
278         return m_thumbAlignTitle;
279     }
280
281     /**
282      * Returns the number of image columns on the thumbnail overview.<p>
283      *
284      * @return the number of image columns on the thumbnail overview
285      */

286     public int getThumbCols() {
287
288         return m_thumbCols;
289     }
290
291     /**
292      * Returns the image scaler for the thumbnails.<p>
293      *
294      * @return the image scaler for the thumbnails
295      */

296     public CmsImageScaler getThumbNailScaler() {
297
298         return m_thumbNailScaler;
299     }
300
301     /**
302      * Returns the number of image rows on the thumbnail overview.<p>
303      *
304      * @return the number of image rows on the thumbnail overview
305      */

306     public int getThumbRows() {
307
308         return m_thumbRows;
309     }
310
311     /**
312      * Returns the optional bottom text on the thumbnail overview.<p>
313      *
314      * @return the optional bottom text on the thumbnail overview
315      */

316     public String JavaDoc getThumbTextBottom() {
317
318         return m_thumbTextBottom;
319     }
320
321     /**
322      * Returns the optional top text on the thumbnail overview.<p>
323      *
324      * @return the optional top text on the thumbnail overview
325      */

326     public String JavaDoc getThumbTextTop() {
327
328         return m_thumbTextTop;
329     }
330
331     /**
332      * Returns the OpenCms VFS path of the image gallery to use.<p>
333      *
334      * @return the OpenCms VFS path of the image gallery to use
335      */

336     public String JavaDoc getVfsPathGallery() {
337
338         return m_vfsPathGallery;
339     }
340
341     /**
342      * Initializes the album configuration.<p>
343      *
344      * @param jsp the initialized CmsJspActionElement to access the OpenCms API
345      * @param configUri URI of the form configuration file, if not provided, current URI is used for configuration
346      *
347      * @throws Exception if parsing the configuration fails
348      */

349     public void init(CmsJspActionElement jsp, String JavaDoc configUri) throws Exception JavaDoc {
350
351         // initialize member objects
352
initMembers();
353
354         // read the album configuration file from VFS
355
if (CmsStringUtil.isEmpty(configUri)) {
356             configUri = jsp.getRequestContext().getUri();
357         }
358         CmsFile file = jsp.getCmsObject().readFile(configUri);
359         CmsXmlContent content = CmsXmlContentFactory.unmarshal(jsp.getCmsObject(), file);
360
361         // get locale from request context
362
Locale JavaDoc locale = jsp.getRequestContext().getLocale();
363         // get the cms object
364
CmsObject cms = jsp.getCmsObject();
365
366         // get the album title
367
String JavaDoc stringValue = content.getStringValue(cms, NODE_TITLE, locale);
368         setAlbumTitle(getConfigurationValue(stringValue, ""));
369
370         // get the gallery vfs folder
371
stringValue = content.getStringValue(cms, NODE_VFSFOLDER, locale);
372         setVfsPathGallery(getConfigurationValue(stringValue, ""));
373
374         // get the alignment of navigation elements
375
stringValue = content.getStringValue(cms, NODE_ALIGN_NAVIGATION, locale);
376         setAlignNavigation(getConfigurationValue(stringValue, "left"));
377
378         // get the position of navigation elements
379
stringValue = content.getStringValue(cms, NODE_NAVIGATION_POSITION, locale);
380         setNavigationPosition(getConfigurationValue(stringValue, NAVPOS_BOTTOM_BELOW));
381
382         // get the show resource name as title flag
383
stringValue = content.getStringValue(cms, NODE_SHOWRESOURCENAMEASTITLE, locale);
384         setShowResourceNameAsTitle(Boolean.valueOf(stringValue).booleanValue());
385
386         // get the thumbnail configuration parameters
387
String JavaDoc nodePrefix = NODE_THUMBS + "/";
388
389         // get the show thumbs title flag
390
stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWTITLE, locale);
391         setShowThumbTitle(Boolean.valueOf(stringValue).booleanValue());
392
393         // get the alignment of thumbs title
394
stringValue = content.getStringValue(cms, nodePrefix + NODE_ALIGN_TITLE, locale);
395         setThumbAlignTitle(getConfigurationValue(stringValue, "left"));
396
397         // get the number of displayed columns
398
stringValue = content.getStringValue(cms, nodePrefix + NODE_COLS, locale);
399         setThumbCols(Integer.parseInt(getConfigurationValue(stringValue, "1")));
400
401         // get the number of rows per page
402
stringValue = content.getStringValue(cms, nodePrefix + NODE_ROWS, locale);
403         setThumbRows(Integer.parseInt(getConfigurationValue(stringValue, "-1")));
404
405         // get the thumbnail background color
406
stringValue = content.getStringValue(cms, nodePrefix + NODE_BACKGROUND, locale);
407         stringValue = getConfigurationValue(stringValue, "#FFFFFF");
408         Color JavaDoc color = Color.WHITE;
409         try {
410             color = Color.decode(stringValue);
411         } catch (NumberFormatException JavaDoc e) {
412             throw new CmsException(Messages.get().container(Messages.LOG_ERR_WRONG_THUMB_BGCOLOR_1, stringValue));
413         }
414         getThumbNailScaler().setColor(color);
415
416         // get the thumbs high quality flag
417
stringValue = content.getStringValue(cms, nodePrefix + NODE_HIGHQUALITY, locale);
418         if (Boolean.valueOf(stringValue).booleanValue()) {
419             // use high quality for thumbnails
420
getThumbNailScaler().setQuality(85);
421         } else {
422             // use speed render settings for thumbnails
423
getThumbNailScaler().setQuality(50);
424             getThumbNailScaler().setRenderMode(Simapi.RENDER_SPEED);
425         }
426
427         // get the thumbnail size
428
stringValue = content.getStringValue(cms, nodePrefix + NODE_SIZE, locale);
429         setImageSize(stringValue, true);
430         
431         // get the thumbnail filter
432
stringValue = content.getStringValue(cms, nodePrefix + NODE_FILTER, locale);
433         setImageFilter(stringValue, true);
434
435         // get the top and bottom texts for the thumbnail pages
436
CmsXmlHtmlValue textValue = (CmsXmlHtmlValue)content.getValue(nodePrefix + NODE_TEXTTOP, locale);
437         if (textValue != null) {
438             // get the top text
439
stringValue = textValue.getStringValue(cms);
440             setThumbTextTop(getConfigurationValue(stringValue, ""));
441         } else {
442             setThumbTextTop("");
443         }
444         textValue = (CmsXmlHtmlValue)content.getValue(nodePrefix + NODE_TEXTBOTTOM, locale);
445         if (textValue != null) {
446             // get the top text
447
stringValue = textValue.getStringValue(cms);
448             setThumbTextBottom(getConfigurationValue(stringValue, ""));
449         } else {
450             setThumbTextBottom("");
451         }
452
453         // get the detail configuration parameters
454
nodePrefix = NODE_DETAIL + "/";
455
456         // get the show detail title flag
457
stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWTITLE, locale);
458         setShowDetailTitle(Boolean.valueOf(stringValue).booleanValue());
459
460         // get the show detail description flag
461
stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWDESCRIPTION, locale);
462         setShowDetailDescription(Boolean.valueOf(stringValue).booleanValue());
463
464         // get the alignment of detail title
465
stringValue = content.getStringValue(cms, nodePrefix + NODE_ALIGN_TITLE, locale);
466         setDetailAlignTitle(getConfigurationValue(stringValue, "left"));
467
468         // get the show detail link to original flag
469
stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWLINKORIGINAL, locale);
470         setShowDetailOriginalLink(Boolean.valueOf(stringValue).booleanValue());
471
472         // get the detail image size
473
stringValue = content.getStringValue(cms, nodePrefix + NODE_SIZE, locale);
474         setImageSize(stringValue, false);
475         
476         // get the detail image filter
477
stringValue = content.getStringValue(cms, nodePrefix + NODE_FILTER, locale);
478         setImageFilter(stringValue, false);
479
480         // get the detail image background color
481
stringValue = content.getStringValue(cms, nodePrefix + NODE_BACKGROUND, locale);
482         stringValue = getConfigurationValue(stringValue, "#FFFFFF");
483         color = Color.WHITE;
484         try {
485             color = Color.decode(stringValue);
486         } catch (NumberFormatException JavaDoc e) {
487             throw new CmsException(Messages.get().container(Messages.LOG_ERR_WRONG_DETAIL_BGCOLOR_1, stringValue));
488         }
489         getDetailImageScaler().setColor(color);
490     }
491
492     /**
493      * Returns if the image description is shown on the detail view.<p>
494      *
495      * @return true if the image description is shown on the detail view, otherwise false
496      */

497     public boolean showDetailDescription() {
498
499         return m_showDetailDescription;
500     }
501
502     /**
503      * Returns if the image original link is shown on the detail view.<p>
504      *
505      * @return true if the image original link is shown on the detail view, otherwise false
506      */

507     public boolean showDetailOriginalLink() {
508
509         return m_showDetailOriginalLink;
510     }
511
512     /**
513      * Returns if the image title is shown on the detail view.<p>
514      *
515      * @return true if the image title is shown on the detail view, otherwise false
516      */

517     public boolean showDetailTitle() {
518
519         return m_showDetailTitle;
520     }
521
522     /**
523      * Returns if a page navigation should be shown on the tumbnail overview.<p>
524      *
525      * @return true if a page navigation should be shown on the tumbnail overview, otherwise false
526      */

527     public boolean showPageNavigation() {
528
529         return getThumbRows() > 0;
530     }
531
532     /**
533      * Returns if the image resource name is shown as title if no title is found.<p>
534      *
535      * @return true if the image resource name is shown as title if no title is found, otherwise false
536      */

537     public boolean showResourceNameAsTitle() {
538
539         return m_showResourceNameAsTitle;
540     }
541
542     /**
543      * Returns if the optional bottom text on the thumbnail overview is shown.<p>
544      *
545      * @return true if the optional bottom text on the thumbnail overview is shown, otherwise false
546      */

547     public boolean showThumbTextBottom() {
548
549         return CmsStringUtil.isNotEmpty(getThumbTextBottom());
550     }
551
552     /**
553      * Returns if the optional top text on the thumbnail overview is shown.<p>
554      *
555      * @return true if the optional top text on the thumbnail overview is shown, otherwise false
556      */

557     public boolean showThumbTextTop() {
558
559         return CmsStringUtil.isNotEmpty(getThumbTextTop());
560     }
561
562     /**
563      * Returns if the image title is shown on the thumbnail overview.<p>
564      *
565      * @return true if the image title is shown on the thumbnail overview, otherwise false
566      */

567     public boolean showThumbTitle() {
568
569         return m_showThumbTitle;
570     }
571
572     /**
573      * Returns the style attribute value to use for alignment configurations.<p>
574      *
575      * @param alignment the alignment (left, center or right)
576      * @return the style attribute value to use for alignment configurations
577      */

578     protected String JavaDoc getStyleAlignAttribute(String JavaDoc alignment) {
579
580         StringBuffer JavaDoc result = new StringBuffer JavaDoc(32);
581         result.append(" style=\"text-align: ");
582         result.append(alignment);
583         result.append(";\"");
584         return result.toString();
585     }
586
587     /**
588      * Initializes the members variables.<p>
589      */

590     protected void initMembers() {
591
592         // initialize member image scaler objects
593
setDetailImageScaler(new CmsImageScaler());
594         setThumbNailScaler(new CmsImageScaler());
595
596         // set defaults
597
setVfsPathGallery("/");
598         setThumbCols(3);
599         setThumbRows(3);
600         setNavigationPosition(NAVPOS_TOP_BELOW);
601
602     }
603
604     /**
605      * Sets the image album title.<p>
606      *
607      * @param albumTitle the image album title
608      */

609     protected void setAlbumTitle(String JavaDoc albumTitle) {
610
611         m_albumTitle = albumTitle;
612     }
613
614     /**
615      * Sets the alignment of the album navigation elements.<p>
616      *
617      * @param alignNavigation the alignment of the album navigation elements
618      */

619     protected void setAlignNavigation(String JavaDoc alignNavigation) {
620
621         m_alignNavigation = alignNavigation;
622     }
623
624     /**
625      * Sets the alignment of the image titles on the detail view.<p>
626      *
627      * @param detailAlignTitle the alignment of the image titles on the detail view
628      */

629     protected void setDetailAlignTitle(String JavaDoc detailAlignTitle) {
630
631         m_detailAlignTitle = detailAlignTitle;
632     }
633
634     /**
635      * Sets the image scaler for the detail image.<p>
636      *
637      * @param detailImageScaler the image scaler for the detail image
638      */

639     protected void setDetailImageScaler(CmsImageScaler detailImageScaler) {
640
641         m_detailImageScaler = detailImageScaler;
642     }
643
644     /**
645      * Sets the navigation element position on the pages.<p>
646      *
647      * @param navigationPosition the navigation element position on the pages
648      */

649     protected void setNavigationPosition(String JavaDoc navigationPosition) {
650
651         m_navigationPosition = navigationPosition;
652     }
653
654     /**
655      * Sets if the image description is shown on the detail view.<p>
656      *
657      * @param showDetailDescription true if the image description is shown on the detail view, otherwise false
658      */

659     protected void setShowDetailDescription(boolean showDetailDescription) {
660
661         m_showDetailDescription = showDetailDescription;
662     }
663
664     /**
665      * Sets if the image original link is shown on the detail view.<p>
666      *
667      * @param showDetailOriginalLink true if the image original link is shown on the detail view, otherwise false
668      */

669     protected void setShowDetailOriginalLink(boolean showDetailOriginalLink) {
670
671         m_showDetailOriginalLink = showDetailOriginalLink;
672     }
673
674     /**
675      * Sets if the image title is shown on the detail view.<p>
676      *
677      * @param showDetailTitle true if the image title is shown on the detail view, otherwise false
678      */

679     protected void setShowDetailTitle(boolean showDetailTitle) {
680
681         m_showDetailTitle = showDetailTitle;
682     }
683
684     /**
685      * Sets if the image resource name is shown as title if no title is found.<p>
686      *
687      * @param showResourceNameAsTitle true if the image resource name is shown as title if no title is found, otherwise false
688      */

689     protected void setShowResourceNameAsTitle(boolean showResourceNameAsTitle) {
690
691         m_showResourceNameAsTitle = showResourceNameAsTitle;
692     }
693
694     /**
695      * Sets if the image title is shown on the thumbnail overview.<p>
696      *
697      * @param showThumbTitle true if the image title is shown on the thumbnail overview, otherwise false
698      */

699     protected void setShowThumbTitle(boolean showThumbTitle) {
700
701         m_showThumbTitle = showThumbTitle;
702     }
703
704     /**
705      * Sets the alignment of the image titles on the thumbnail overview.<p>
706      *
707      * @param thumbAlignTitle the alignment of the image titles on the thumbnail overview
708      */

709     protected void setThumbAlignTitle(String JavaDoc thumbAlignTitle) {
710
711         m_thumbAlignTitle = thumbAlignTitle;
712     }
713
714     /**
715      * Sets the number of image columns on the thumbnail overview.<p>
716      *
717      * @param thumbCols the number of image columns on the thumbnail overview
718      */

719     protected void setThumbCols(int thumbCols) {
720
721         m_thumbCols = thumbCols;
722     }
723
724     /**
725      * Sets the image scaler for the thumbnails.<p>
726      *
727      * @param thumbNailScaler the image scaler for the thumbnails
728      */

729     protected void setThumbNailScaler(CmsImageScaler thumbNailScaler) {
730
731         m_thumbNailScaler = thumbNailScaler;
732     }
733
734     /**
735      * Sets the number of image rows on the thumbnail overview.<p>
736      *
737      * @param thumbRows the number of image rows on the thumbnail overview
738      */

739     protected void setThumbRows(int thumbRows) {
740
741         if (thumbRows < 1) {
742             m_thumbRows = -1;
743         } else {
744             m_thumbRows = thumbRows;
745         }
746     }
747
748     /**
749      * Sets the optional bottom text on the thumbnail overview.<p>
750      *
751      * @param thumbTextBottom the optional bottom text on the thumbnail overview
752      */

753     protected void setThumbTextBottom(String JavaDoc thumbTextBottom) {
754
755         m_thumbTextBottom = thumbTextBottom;
756     }
757
758     /**
759      * Sets the optional top text on the thumbnail overview.<p>
760      *
761      * @param thumbTextTop the optional top text on the thumbnail overview
762      */

763     protected void setThumbTextTop(String JavaDoc thumbTextTop) {
764
765         m_thumbTextTop = thumbTextTop;
766     }
767
768     /**
769      * Sets the OpenCms VFS path of the image gallery to use.<p>
770      *
771      * @param vfsPathGallery the OpenCms VFS path of the image gallery to use
772      */

773     protected void setVfsPathGallery(String JavaDoc vfsPathGallery) {
774
775         m_vfsPathGallery = vfsPathGallery;
776     }
777
778     /**
779      * Checks if the given value is empty and returns in that case the default value.<p>
780      *
781      * @param value the configuration value to check
782      * @param defaultValue the default value to return in case the value is empty
783      * @return the checked value
784      */

785     private String JavaDoc getConfigurationValue(String JavaDoc value, String JavaDoc defaultValue) {
786
787         if (CmsStringUtil.isNotEmpty(value)) {
788             return value;
789         }
790         return defaultValue;
791     }
792     
793     /**
794      * Sets the image filter for thumbnails and the detail view.<p>
795      *
796      * @param configValue the String value of the configuration file
797      * @param isThumbNail flag indicating if the thumbnail or the detail view configuration is set
798      * @throws Exception if parsing the configuration fails
799      */

800     private void setImageFilter(String JavaDoc configValue, boolean isThumbNail) throws Exception JavaDoc {
801
802         if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configValue) && !FILTER_NONE.equals(configValue)) {
803             // filter value set, determine it
804
List JavaDoc filter = CmsStringUtil.splitAsList(configValue, FILTER_DELIMITER);
805             for (int i=0; i<filter.size(); i++) {
806                 String JavaDoc currentFilter = (String JavaDoc)filter.get(i);
807                 if (isThumbNail) {
808                     // set thumbnail filter
809
getThumbNailScaler().addFilter(currentFilter);
810                 } else {
811                     // set detail image filter
812
getDetailImageScaler().addFilter(currentFilter);
813                 }
814             }
815             
816         }
817     }
818
819     /**
820      * Sets the image size for thumbnails and the detail view.<p>
821      *
822      * @param configValue the String value of the configuration file
823      * @param isThumbNail flag indicating if the thumbnail or the detail view configuration is set
824      * @throws Exception if parsing the configuration fails
825      */

826     private void setImageSize(String JavaDoc configValue, boolean isThumbNail) throws Exception JavaDoc {
827
828         List JavaDoc sizes = CmsStringUtil.splitAsList(getConfigurationValue(configValue, "200x150"), 'x', true);
829         int width = Integer.parseInt((String JavaDoc)sizes.get(0));
830         int height = Integer.parseInt((String JavaDoc)sizes.get(1));
831         if (isThumbNail) {
832             getThumbNailScaler().setWidth(width);
833             getThumbNailScaler().setHeight(height);
834         } else {
835             getDetailImageScaler().setWidth(width);
836             getDetailImageScaler().setHeight(height);
837         }
838     }
839
840 }
Popular Tags