Package com.day.cq.wcm.foundation
Class Image
- java.lang.Object
-
- org.apache.sling.api.resource.ResourceWrapper
-
- com.day.cq.commons.DownloadResource
-
- com.day.cq.commons.ImageResource
-
- com.day.cq.wcm.foundation.Image
-
public class Image extends ImageResource
Provides convenience methods for displaying images.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
PN_IMAGE_MAP
name of the image map property-
Fields inherited from class com.day.cq.commons.ImageResource
DEFAULT_IMAGE_PATH, PN_ALT, PN_DEFAULT_IMAGE_PATH, PN_HEIGHT, PN_HTML_HEIGHT, PN_HTML_WIDTH, PN_IMAGE_CROP, PN_IMAGE_ROTATE, PN_LINK_URL, PN_MAX_HEIGHT, PN_MAX_WIDTH, PN_MIN_HEIGHT, PN_MIN_WIDTH, PN_WIDTH
-
Fields inherited from class com.day.cq.commons.DownloadResource
NN_FILE, PN_DESCRIPTION, PN_FILE_NAME, PN_REFERENCE, PN_TITLE
-
Fields inherited from interface org.apache.sling.api.resource.Resource
RESOURCE_TYPE_NON_EXISTING
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getIconPath()
Returns a path to an icon representing the file.boolean
hasNoPlaceholder()
Returns the placeholder flag.void
loadStyleData(Style style)
Loads several definitions from style.void
setDropTargetId(java.lang.String id)
Sets the drop target id for this image, using the name of the resources as path.void
setDropTargetId(java.lang.String id, java.lang.String classifier)
Sets the drop target id for this image.void
setNoPlaceholder(boolean noPlaceholder)
Sets the placeholder flag.-
Methods inherited from class com.day.cq.commons.ImageResource
crop, draw, getAlt, getCropRect, getData, getDoctype, getExtension, getImageDoctype, getLayer, getRotation, getSrc, getTitle, resize, rotate, setAlt, setDoctype, setExtension, setImageDoctype, setSrc
-
Methods inherited from class com.day.cq.commons.DownloadResource
addAttribute, addCssClass, addQueryParam, get, get, getAttributes, getDescription, getDescription, getFileName, getFileNodePath, getFileReference, getHref, getIconType, getInnerHtml, getItemName, getLastModified, getMimeType, getQuery, getSelector, getString, getSuffix, getTitle, hasContent, init, isTouchAuthoringUIMode, set, setDescription, setFileName, setFileNodePath, setFileReference, setHref, setInnerHtml, setIsInUITouchMode, setItemName, setQuery, setSelector, setSuffix, setTitle
-
Methods inherited from class org.apache.sling.api.resource.ResourceWrapper
adaptTo, getChild, getChildren, getName, getParent, getPath, getResource, getResourceMetadata, getResourceResolver, getResourceSuperType, getResourceType, getValueMap, hasChildren, isResourceType, listChildren, toString
-
-
-
-
Field Detail
-
PN_IMAGE_MAP
public static final java.lang.String PN_IMAGE_MAP
name of the image map property- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Image
public Image(Resource resource)
Creates a new image based on the given resource. the image properties are considered to 'on' the given resource.- Parameters:
resource
- resource of the image- Throws:
java.lang.IllegalArgumentException
- if the given resource is not adaptable to node.
-
Image
public Image(Resource resource, java.lang.String imageName)
Creates a new image based on the given resource. the image properties are considered to 'on' the given resource unlessimageName
is specified. then the respective child resource holds the image properties.- Parameters:
resource
- current resourceimageName
- name of the image resource- Throws:
java.lang.IllegalArgumentException
- if the given resource is not adaptable to node.
-
-
Method Detail
-
setDropTargetId
public void setDropTargetId(java.lang.String id, java.lang.String classifier)
Sets the drop target id for this image. the id is added as css class to the image attribute. and has the format: ""cq-dd-"{id}-{classifier}"- Parameters:
id
- the drop target id as configured in edit config.classifier
- optional classifier
-
setDropTargetId
public void setDropTargetId(java.lang.String id)
Sets the drop target id for this image, using the name of the resources as path.- Parameters:
id
- the drop target id as configured in edit config.
-
hasNoPlaceholder
public boolean hasNoPlaceholder()
Returns the placeholder flag.- Returns:
true
if no placeholder for empty content should be drawn.
-
setNoPlaceholder
public void setNoPlaceholder(boolean noPlaceholder)
Sets the placeholder flag.- Parameters:
noPlaceholder
- iftrue
no placeholder for empty content is used.
-
loadStyleData
public void loadStyleData(Style style)
Loads several definitions from style.Currently, the minimum/maximum width and height are transferred from the given style.
- Parameters:
style
- style to load definitions from
-
getIconPath
public java.lang.String getIconPath()
Returns a path to an icon representing the file. Checks if the component of the resource provides an icon for the respective type.- Overrides:
getIconPath
in classDownloadResource
- Returns:
- a path to an icon or
null
.
-
-