|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.day.cq.wcm.foundation.Download
com.day.cq.wcm.foundation.Image
public class Image
Provides convenience methods for displaying images.
| Field Summary | |
|---|---|
static String |
PN_ALT
name of the alt name property |
static String |
PN_HEIGHT
name of the height property |
static String |
PN_HTML_HEIGHT
name of the html height property |
static String |
PN_HTML_WIDTH
name of the html width property |
static String |
PN_IMAGE_CROP
name of the image crop property |
static String |
PN_IMAGE_MAP
name of the image map property |
static String |
PN_IMAGE_ROTATE
name of the image rotation property |
static String |
PN_MAX_HEIGHT
name of the maximal height property. |
static String |
PN_MAX_WIDTH
name of the maximal width property. |
static String |
PN_MIN_HEIGHT
name of the minimal height property. |
static String |
PN_MIN_WIDTH
name of the minimal width property. |
static String |
PN_WIDTH
name of the width property |
| Fields inherited from class com.day.cq.wcm.foundation.Download |
|---|
attrs, NN_FILE, node, PN_DESCRIPTION, PN_FILE_NAME, PN_REFERENCE, PN_TITLE, properties, resource |
| Constructor Summary | |
|---|---|
Image(org.apache.sling.api.resource.Resource resource)
Creates a new image based on the given resource. |
|
Image(org.apache.sling.api.resource.Resource resource,
String imageName)
Creates a new image based on the given resource. |
|
| Method Summary | |
|---|---|
com.day.image.Layer |
crop(com.day.image.Layer layer)
Crops the layer using the internal crop rectangle. |
void |
draw(Writer w)
Writes this image as tag to the given writer |
String |
getAlt()
Returns the image alt name as defined by the "alt" or overridden by setAlt(String). |
Rectangle |
getCropRect()
Returns the cropping rectangle as defined by the "imageCrop". |
com.day.image.Layer |
getLayer(boolean cropped,
boolean resized,
boolean rotated)
Returns the layer addressed by this image. |
int |
getRotation()
Returns the rotation angle as defined by the "imageRotate". |
String |
getSrc()
Returns the source attribute of this image. |
boolean |
hasNoPlaceholder()
Returns the placeholder flag. |
void |
loadStyleData(Style style)
Loads several definitions from style. |
com.day.image.Layer |
resize(com.day.image.Layer layer)
Resizes the given layer according to the dimensions defined in this image. |
com.day.image.Layer |
rotate(com.day.image.Layer layer)
Rotates the layer using the internal rotation angle. |
void |
setAlt(String alt)
Sets the alt name. |
void |
setDropTargetId(String id)
Sets the drop target id for this image, using the name of the resources as path. |
void |
setDropTargetId(String id,
String classifier)
Sets the drop target id for this image. |
void |
setNoPlaceholder(boolean noPlaceholder)
Sets the placeholder flag. |
void |
setSrc(String src)
Sets the source attribute |
| Methods inherited from class com.day.cq.wcm.foundation.Download |
|---|
addAttribute, addCssClass, get, get, getAttributes, getData, getDescription, getDescription, getExtension, getFileName, getFileNodePath, getFileReference, getHref, getIconPath, getIconType, getInnerHtml, getItemName, getMimeType, getResource, getSelector, getString, getSuffix, getTitle, getTitle, hasContent, init, set, setDescription, setExtension, setFileName, setFileNodePath, setFileReference, setHref, setInnerHtml, setItemName, setSelector, setSuffix, setTitle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String PN_HTML_WIDTH
public static final String PN_HTML_HEIGHT
public static final String PN_WIDTH
public static final String PN_HEIGHT
public static final String PN_MIN_WIDTH
public static final String PN_MIN_HEIGHT
public static final String PN_MAX_WIDTH
public static final String PN_MAX_HEIGHT
public static final String PN_ALT
public static final String PN_IMAGE_MAP
public static final String PN_IMAGE_CROP
public static final String PN_IMAGE_ROTATE
| Constructor Detail |
|---|
public Image(org.apache.sling.api.resource.Resource resource)
resource - resource of the image
IllegalArgumentException - if the given resource is not adaptable to node.
public Image(org.apache.sling.api.resource.Resource resource,
String imageName)
image
is specified. then the respective child resource hold the image
properties.
resource - current resourceimageName - name of the image resource
IllegalArgumentException - if the given resource is not adaptable to node.| Method Detail |
|---|
public String getAlt()
setAlt(String).
PN_ALT
public void setDropTargetId(String id,
String classifier)
id - the drop target id as configured in edit config.classifier - optional classifierpublic void setDropTargetId(String id)
id - the drop target id as configured in edit config.public void setAlt(String alt)
alt - the alt name.public String getSrc()
public void setSrc(String src)
src - the source attributepublic boolean hasNoPlaceholder()
true if no placeholder for empty content should be
drawn.public void setNoPlaceholder(boolean noPlaceholder)
noPlaceholder - if true no placeholder for empty content
is used.public void loadStyleData(Style style)
Currently, the minimum/maximum width and height are transferred from the given style.
style - style to load definitions from
public void draw(Writer w)
throws IOException
draw in class Downloadw - the writer
IOException - if an I/O error occurspublic Rectangle getCropRect()
nullpublic int getRotation()
public com.day.image.Layer resize(com.day.image.Layer layer)
ImageHelper.resize(Layer, Dimension, Dimension, Dimension)
for more details about the resizing algorithm.
layer - the layer to resize
null if the layer is untouchedpublic com.day.image.Layer crop(com.day.image.Layer layer)
null is returned.
layer - the layer
nullpublic com.day.image.Layer rotate(com.day.image.Layer layer)
null is returned.
layer - the layer
null
public com.day.image.Layer getLayer(boolean cropped,
boolean resized,
boolean rotated)
throws IOException,
RepositoryException
cropped - apply cropping if trueresized - apply resizing if truerotated - apply rotation if true
IOException - if an I/O error occurs.
RepositoryException - if a repository error occurs.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||