⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmsphotoalbumconfiguration.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        } else {
            // use speed render settings for thumbnails
            getThumbNailScaler().setQuality(50);
            getThumbNailScaler().setRenderMode(Simapi.RENDER_SPEED);
        }

        // get the thumbnail size
        stringValue = content.getStringValue(cms, nodePrefix + NODE_SIZE, locale);
        setImageSize(stringValue, true);
        
        // get the thumbnail filter
        stringValue = content.getStringValue(cms, nodePrefix + NODE_FILTER, locale);
        setImageFilter(stringValue, true);

        // get the top and bottom texts for the thumbnail pages
        CmsXmlHtmlValue textValue = (CmsXmlHtmlValue)content.getValue(nodePrefix + NODE_TEXTTOP, locale);
        if (textValue != null) {
            // get the top text
            stringValue = textValue.getStringValue(cms);
            setThumbTextTop(getConfigurationValue(stringValue, ""));
        } else {
            setThumbTextTop("");
        }
        textValue = (CmsXmlHtmlValue)content.getValue(nodePrefix + NODE_TEXTBOTTOM, locale);
        if (textValue != null) {
            // get the top text
            stringValue = textValue.getStringValue(cms);
            setThumbTextBottom(getConfigurationValue(stringValue, ""));
        } else {
            setThumbTextBottom("");
        }

        // get the detail configuration parameters
        nodePrefix = NODE_DETAIL + "/";

        // get the show detail title flag
        stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWTITLE, locale);
        setShowDetailTitle(Boolean.valueOf(stringValue).booleanValue());

        // get the show detail description flag
        stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWDESCRIPTION, locale);
        setShowDetailDescription(Boolean.valueOf(stringValue).booleanValue());

        // get the alignment of detail title
        stringValue = content.getStringValue(cms, nodePrefix + NODE_ALIGN_TITLE, locale);
        setDetailAlignTitle(getConfigurationValue(stringValue, "left"));

        // get the show detail link to original flag
        stringValue = content.getStringValue(cms, nodePrefix + NODE_SHOWLINKORIGINAL, locale);
        setShowDetailOriginalLink(Boolean.valueOf(stringValue).booleanValue());

        // get the detail image size
        stringValue = content.getStringValue(cms, nodePrefix + NODE_SIZE, locale);
        setImageSize(stringValue, false);
        
        // get the detail image filter
        stringValue = content.getStringValue(cms, nodePrefix + NODE_FILTER, locale);
        setImageFilter(stringValue, false);

        // get the detail image background color
        stringValue = content.getStringValue(cms, nodePrefix + NODE_BACKGROUND, locale);
        stringValue = getConfigurationValue(stringValue, "#FFFFFF");
        color = Color.WHITE;
        try {
            color = Color.decode(stringValue);
        } catch (NumberFormatException e) {
            throw new CmsException(Messages.get().container(Messages.LOG_ERR_WRONG_DETAIL_BGCOLOR_1, stringValue));
        }
        getDetailImageScaler().setColor(color);
    }

    /**
     * Returns if the image description is shown on the detail view.<p>
     * 
     * @return true if the image description is shown on the detail view, otherwise false
     */
    public boolean showDetailDescription() {

        return m_showDetailDescription;
    }

    /**
     * Returns if the image original link is shown on the detail view.<p>
     * 
     * @return true if the image original link is shown on the detail view, otherwise false
     */
    public boolean showDetailOriginalLink() {

        return m_showDetailOriginalLink;
    }

    /**
     * Returns if the image title is shown on the detail view.<p>
     * 
     * @return true if the image title is shown on the detail view, otherwise false
     */
    public boolean showDetailTitle() {

        return m_showDetailTitle;
    }

    /**
     * Returns if a page navigation should be shown on the tumbnail overview.<p>
     * 
     * @return true if a page navigation should be shown on the tumbnail overview, otherwise false
     */
    public boolean showPageNavigation() {

        return getThumbRows() > 0;
    }

    /**
     * Returns if the image resource name is shown as title if no title is found.<p>
     * 
     * @return true if the image resource name is shown as title if no title is found, otherwise false
     */
    public boolean showResourceNameAsTitle() {

        return m_showResourceNameAsTitle;
    }

    /**
     * Returns if the optional bottom text on the thumbnail overview is shown.<p>
     * 
     * @return true if the optional bottom text on the thumbnail overview is shown, otherwise false
     */
    public boolean showThumbTextBottom() {

        return CmsStringUtil.isNotEmpty(getThumbTextBottom());
    }

    /**
     * Returns if the optional top text on the thumbnail overview is shown.<p>
     * 
     * @return true if the optional top text on the thumbnail overview is shown, otherwise false
     */
    public boolean showThumbTextTop() {

        return CmsStringUtil.isNotEmpty(getThumbTextTop());
    }

    /**
     * Returns if the image title is shown on the thumbnail overview.<p>
     * 
     * @return true if the image title is shown on the thumbnail overview, otherwise false
     */
    public boolean showThumbTitle() {

        return m_showThumbTitle;
    }

    /**
     * Returns the style attribute value to use for alignment configurations.<p>
     * 
     * @param alignment the alignment (left, center or right)
     * @return the style attribute value to use for alignment configurations
     */
    protected String getStyleAlignAttribute(String alignment) {

        StringBuffer result = new StringBuffer(32);
        result.append(" style=\"text-align: ");
        result.append(alignment);
        result.append(";\"");
        return result.toString();
    }

    /**
     * Initializes the members variables.<p>
     */
    protected void initMembers() {

        // initialize member image scaler objects
        setDetailImageScaler(new CmsImageScaler());
        setThumbNailScaler(new CmsImageScaler());

        // set defaults
        setVfsPathGallery("/");
        setThumbCols(3);
        setThumbRows(3);
        setNavigationPosition(NAVPOS_TOP_BELOW);

    }

    /**
     * Sets the image album title.<p>
     * 
     * @param albumTitle the image album title
     */
    protected void setAlbumTitle(String albumTitle) {

        m_albumTitle = albumTitle;
    }

    /**
     * Sets the alignment of the album navigation elements.<p>
     * 
     * @param alignNavigation the alignment of the album navigation elements
     */
    protected void setAlignNavigation(String alignNavigation) {

        m_alignNavigation = alignNavigation;
    }

    /**
     * Sets the alignment of the image titles on the detail view.<p>
     * 
     * @param detailAlignTitle the alignment of the image titles on the detail view
     */
    protected void setDetailAlignTitle(String detailAlignTitle) {

        m_detailAlignTitle = detailAlignTitle;
    }

    /**
     * Sets the image scaler for the detail image.<p>
     * 
     * @param detailImageScaler the image scaler for the detail image
     */
    protected void setDetailImageScaler(CmsImageScaler detailImageScaler) {

        m_detailImageScaler = detailImageScaler;
    }

    /**
     * Sets the navigation element position on the pages.<p>
     * 
     * @param navigationPosition the navigation element position on the pages
     */
    protected void setNavigationPosition(String navigationPosition) {

        m_navigationPosition = navigationPosition;
    }

    /**
     * Sets if the image description is shown on the detail view.<p>
     * 
     * @param showDetailDescription true if the image description is shown on the detail view, otherwise false
     */
    protected void setShowDetailDescription(boolean showDetailDescription) {

        m_showDetailDescription = showDetailDescription;
    }

    /**
     * Sets if the image original link is shown on the detail view.<p>
     * 
     * @param showDetailOriginalLink true if the image original link is shown on the detail view, otherwise false
     */
    protected void setShowDetailOriginalLink(boolean showDetailOriginalLink) {

        m_showDetailOriginalLink = showDetailOriginalLink;
    }

    /**
     * Sets if the image title is shown on the detail view.<p>
     * 
     * @param showDetailTitle true if the image title is shown on the detail view, otherwise false
     */
    protected void setShowDetailTitle(boolean showDetailTitle) {

        m_showDetailTitle = showDetailTitle;
    }

    /**
     * Sets if the image resource name is shown as title if no title is found.<p>
     * 
     * @param showResourceNameAsTitle true if the image resource name is shown as title if no title is found, otherwise false
     */
    protected void setShowResourceNameAsTitle(boolean showResourceNameAsTitle) {

        m_showResourceNameAsTitle = showResourceNameAsTitle;
    }

    /**
     * Sets if the image title is shown on the thumbnail overview.<p>
     * 
     * @param showThumbTitle true if the image title is shown on the thumbnail overview, otherwise false
     */
    protected void setShowThumbTitle(boolean showThumbTitle) {

        m_showThumbTitle = showThumbTitle;
    }

    /**
     * Sets the alignment of the image titles on the thumbnail overview.<p>
     * 
     * @param thumbAlignTitle the alignment of the image titles on the thumbnail overview
     */
    protected void setThumbAlignTitle(String thumbAlignTitle) {

        m_thumbAlignTitle = thumbAlignTitle;
    }

    /**
     * Sets the number of image columns on the thumbnail overview.<p>
     * 
     * @param thumbCols the number of image columns on the thumbnail overview
     */
    protected void setThumbCols(int thumbCols) {

        m_thumbCols = thumbCols;
    }

    /**
     * Sets the image scaler for the thumbnails.<p>
     * 
     * @param thumbNailScaler the image scaler for the thumbnails
     */
    protected void setThumbNailScaler(CmsImageScaler thumbNailScaler) {

        m_thumbNailScaler = thumbNailScaler;
    }

    /**
     * Sets the number of image rows on the thumbnail overview.<p>
     * 
     * @param thumbRows the number of image rows on the thumbnail overview
     */
    protected void setThumbRows(int thumbRows) {

        if (thumbRows < 1) {
            m_thumbRows = -1;
        } else {
            m_thumbRows = thumbRows;
        }
    }

    /**
     * Sets the optional bottom text on the thumbnail overview.<p>
     * 
     * @param thumbTextBottom the optional bottom text on the thumbnail overview
     */
    protected void setThumbTextBottom(String thumbTextBottom) {

        m_thumbTextBottom = thumbTextBottom;
    }

    /**
     * Sets the optional top text on the thumbnail overview.<p>
     * 
     * @param thumbTextTop the optional top text on the thumbnail overview
     */
    protected void setThumbTextTop(String thumbTextTop) {

        m_thumbTextTop = thumbTextTop;
    }

    /**
     * Sets the OpenCms VFS path of the image gallery to use.<p>
     * 
     * @param vfsPathGallery the OpenCms VFS path of the image gallery to use
     */
    protected void setVfsPathGallery(String vfsPathGallery) {

        m_vfsPathGallery = vfsPathGallery;
    }

    /**
     * Checks if the given value is empty and returns in that case the default value.<p>
     * 
     * @param value the configuration value to check
     * @param defaultValue the default value to return in case the value is empty
     * @return the checked value
     */
    private String getConfigurationValue(String value, String defaultValue) {

        if (CmsStringUtil.isNotEmpty(value)) {
            return value;
        }
        return defaultValue;
    }
    
    /**
     * Sets the image filter for thumbnails and the detail view.<p>
     * 
     * @param configValue the String value of the configuration file
     * @param isThumbNail flag indicating if the thumbnail or the detail view configuration is set
     * @throws Exception if parsing the configuration fails
     */
    private void setImageFilter(String configValue, boolean isThumbNail) throws Exception {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(configValue) && !FILTER_NONE.equals(configValue)) {
            // filter value set, determine it
            List filter = CmsStringUtil.splitAsList(configValue, FILTER_DELIMITER);
            for (int i=0; i<filter.size(); i++) {
                String currentFilter = (String)filter.get(i);
                if (isThumbNail) {
                    // set thumbnail filter
                    getThumbNailScaler().addFilter(currentFilter);
                } else {
                    // set detail image filter
                    getDetailImageScaler().addFilter(currentFilter);
                }
            }
            
        }
    }

    /**
     * Sets the image size for thumbnails and the detail view.<p>
     * 
     * @param configValue the String value of the configuration file
     * @param isThumbNail flag indicating if the thumbnail or the detail view configuration is set
     * @throws Exception if parsing the configuration fails
     */
    private void setImageSize(String configValue, boolean isThumbNail) throws Exception {

        List sizes = CmsStringUtil.splitAsList(getConfigurationValue(configValue, "200x150"), 'x', true);
        int width = Integer.parseInt((String)sizes.get(0));
        int height = Integer.parseInt((String)sizes.get(1));
        if (isThumbNail) {
            getThumbNailScaler().setWidth(width);
            getThumbNailScaler().setHeight(height);
        } else {
            getDetailImageScaler().setWidth(width);
            getDetailImageScaler().setHeight(height);
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -