All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.adobe.aemds.guide.common.GuideImage Maven / Gradle / Ivy

/*************************************************************************
 * ADOBE CONFIDENTIAL
 * __________________
 *
 *  Copyright 2014 Adobe Systems Incorporated
 *  All Rights Reserved.
 *
 * NOTICE:  All information contained herein is, and remains
 * the property of Adobe Systems Incorporated and its suppliers,
 * if any.  The intellectual and technical concepts contained
 * herein are proprietary to Adobe Systems Incorporated and its
 * suppliers and may be covered by U.S. and Foreign Patents,
 * patents in process, and are protected by trade secret or copyright law.
 * Dissemination of this information or reproduction of this material
 * is strictly forbidden unless prior written permission is obtained
 * from Adobe Systems Incorporated.
 **************************************************************************/

package com.adobe.aemds.guide.common;

import com.adobe.aemds.guide.utils.GuideConstants;
import com.adobe.aemds.guide.utils.GuideUtils;
import com.day.cq.wcm.api.components.DropTarget;
import com.day.cq.wcm.foundation.Image;

import javax.jcr.RepositoryException;
import java.io.IOException;
import java.io.Serializable;


/**
 * GuideImage class encapsulates basic properties of the adaptive forms Image Component.
 * The properties that it encapsulates are listed below:
 * 
    *
  • Source of the image
  • *
  • Alternate Text of the image
  • *
  • Height of the image
  • *
* * @since AEM 6.0 */ public class GuideImage extends GuideField implements Serializable { private Image image; /** * Returns the source where the image is present. * @return String representing source of the image. */ public String getImageSrc() throws RepositoryException, IOException { image = new Image(getResource()); Boolean containsData = (image.getData() != null); if (containsData) { image.setSelector(".img"); return image.getSrc(); } else { return ""; } } public String getStyles() { String style = ""; String width = getWidth(); String height = getHeight(); // Append all styles here, for now only width is getting updated style += ((width.length()) > 0 ? ("width:" + width + "%;") : ("")); style += ((height.length()) > 0 ? ("height:" + height + "px;") : ("")); // Return the style return style; } /** * Returns the drop target class. * @return String representing drop target class for touch ui. */ public String getDropTargetClass() throws RepositoryException{ if(image.getData() == null) { return "cq-placeholder "+DropTarget.CSS_CLASS_PREFIX + "image"; } else{ return DropTarget.CSS_CLASS_PREFIX + "image"; } } /** * Returns the alternate text of the Image configured in the authoring dialog. * @return String representing alternate text */ public String getAltText() { String altText = this.resourceProps.get("altText", ""); if( "".equals(altText) ) { String title = this.resourceProps.get("jcr:title", ""); altText = "".equals(title) ? this.resourceProps.get("name","") : title; } return externalize(GuideUtils.filterHtml(altText, getXssapi())); } /** * Returns the height of image configured in the authoring dialog * @return String representing height of the image */ public String getHeight() { return resourceProps.get("height", ""); } /** * Returns the field type of the Adaptive Forms Component * @return String representing guide field type */ public String getGuideFieldType() { return GuideConstants.GUIDE_FIELD_IMAGE; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy