public class ImageResource extends DownloadResource
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEFAULT_IMAGE_PATH
the default image path
|
static java.lang.String |
PN_ALT
name of the alt name property
|
static java.lang.String |
PN_DEFAULT_IMAGE_PATH
name of the default image path property
|
static java.lang.String |
PN_HEIGHT
name of the height property
|
static java.lang.String |
PN_HTML_HEIGHT
name of the html height property
|
static java.lang.String |
PN_HTML_WIDTH
name of the html width property
|
static java.lang.String |
PN_IMAGE_CROP
name of the image crop property
|
static java.lang.String |
PN_IMAGE_ROTATE
name of the image rotation property
|
static java.lang.String |
PN_LINK_URL
name of the link URL property
|
static java.lang.String |
PN_MAX_HEIGHT
name of the maximal height property.
|
static java.lang.String |
PN_MAX_WIDTH
name of the maximal width property.
|
static java.lang.String |
PN_MIN_HEIGHT
name of the minimal height property.
|
static java.lang.String |
PN_MIN_WIDTH
name of the minimal width property.
|
static java.lang.String |
PN_WIDTH
name of the width property
|
NN_FILE, PN_DESCRIPTION, PN_FILE_NAME, PN_REFERENCE, PN_TITLE
RESOURCE_TYPE_NON_EXISTING
Constructor and Description |
---|
ImageResource(Resource resource)
Creates a new image based on the given resource.
|
ImageResource(Resource resource,
java.lang.String imageName)
Creates a new image based on the given resource.
|
Modifier and Type | Method and Description |
---|---|
Layer |
crop(Layer layer)
Crops the layer using the internal crop rectangle.
|
void |
draw(java.io.Writer w)
Writes this image as tag to the given writer by invoking
doDraw(PrintWriter) if canDraw() returns true . |
java.lang.String |
getAlt()
Returns the image alt name as defined by the "alt"
or overridden by
setAlt(String) . |
java.awt.Rectangle |
getCropRect()
Returns the cropping rectangle as defined by the "imageCrop".
|
Property |
getData()
Returns the property that contains the binary data of this download.
|
Doctype |
getDoctype()
Deprecated.
|
java.lang.String |
getExtension()
Tries to calculate the extension from the mime-type of the underlying
image.
|
Doctype |
getImageDoctype()
Returns the doctype that is used when generating the HTML.
|
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".
|
java.lang.String |
getSrc()
Returns the source attribute of this image.
|
java.lang.String |
getTitle(boolean escape)
Returns the image title as defined by 'getItemName(PN_TITLE)'
or overridden by
DownloadResource.setTitle(String) . |
Layer |
resize(Layer layer)
Resizes the given layer according to the dimensions defined in this image.
|
Layer |
rotate(Layer layer)
Rotates the layer using the internal rotation angle.
|
void |
setAlt(java.lang.String alt)
Sets the alt name.
|
void |
setDoctype(Doctype doctype)
Deprecated.
|
void |
setExtension(java.lang.String extension)
Sets the extension.
|
void |
setImageDoctype(Doctype doctype)
Sets the doctype that is used when generating the HTML.
|
void |
setSrc(java.lang.String src)
Sets the source attribute
|
addAttribute, addCssClass, addQueryParam, get, get, getAttributes, getDescription, getDescription, getFileName, getFileNodePath, getFileReference, getHref, getIconPath, 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
adaptTo, getChild, getChildren, getName, getParent, getPath, getResource, getResourceMetadata, getResourceResolver, getResourceSuperType, getResourceType, getValueMap, hasChildren, isResourceType, listChildren, toString
public static final java.lang.String PN_HTML_WIDTH
public static final java.lang.String PN_HTML_HEIGHT
public static final java.lang.String PN_WIDTH
public static final java.lang.String PN_HEIGHT
public static final java.lang.String PN_MIN_WIDTH
public static final java.lang.String PN_MIN_HEIGHT
public static final java.lang.String PN_MAX_WIDTH
public static final java.lang.String PN_MAX_HEIGHT
public static final java.lang.String PN_ALT
public static final java.lang.String PN_IMAGE_CROP
public static final java.lang.String PN_IMAGE_ROTATE
public static final java.lang.String PN_LINK_URL
public static final java.lang.String PN_DEFAULT_IMAGE_PATH
public static final java.lang.String DEFAULT_IMAGE_PATH
public ImageResource(Resource resource)
resource
- resource of the imagejava.lang.IllegalArgumentException
- if the given resource is not adaptable to node.public ImageResource(Resource resource, java.lang.String imageName)
imageName
is specified. then the respective child resource holds the image
properties.resource
- current resourceimageName
- name of the image resourcejava.lang.IllegalArgumentException
- if the given resource is not adaptable to node.public java.lang.String getTitle(boolean escape)
DownloadResource.setTitle(String)
.getTitle
in class DownloadResource
escape
- if true
the string is HTML escapedpublic java.lang.String getAlt()
setAlt(String)
.PN_ALT
public void setAlt(java.lang.String alt)
alt
- the alt name.public java.lang.String getSrc()
public java.lang.String getExtension()
getExtension
in class DownloadResource
public void setExtension(java.lang.String extension)
DownloadResource
setExtension
in class DownloadResource
extension
- the extension.public void setSrc(java.lang.String src)
src
- the source attribute@Deprecated public Doctype getDoctype()
getImageDoctype()
Doctype.HTML_401_STRICT
.public Doctype getImageDoctype()
Doctype.HTML_401_STRICT
.@Deprecated public void setDoctype(Doctype doctype)
setImageDoctype(Doctype)
null
the current doctype is not overridden.doctype
- the doctypepublic void setImageDoctype(Doctype doctype)
null
the current doctype is not overridden.doctype
- the doctypepublic void draw(java.io.Writer w) throws java.io.IOException
doDraw(PrintWriter)
if canDraw()
returns true
.draw
in class DownloadResource
w
- the writerjava.io.IOException
- if an I/O error occurspublic java.awt.Rectangle getCropRect()
null
public int getRotation()
public Layer resize(Layer layer)
ImageHelper.resize(Layer, Dimension, Dimension, Dimension)
for more details about the resizing algorithm.layer
- the layer to resizenull
if the layer is untouchedpublic Layer crop(Layer layer)
null
is returned.layer
- the layernull
public Layer rotate(Layer layer)
null
is returned.layer
- the layernull
public Layer getLayer(boolean cropped, boolean resized, boolean rotated) throws java.io.IOException, RepositoryException
cropped
- apply cropping if true
resized
- apply resizing if true
rotated
- apply rotation if true
java.io.IOException
- if an I/O error occurs.RepositoryException
- if a repository error occurs.public Property getData() throws RepositoryException
DownloadResource
getData
in class DownloadResource
null
RepositoryException
- if an error accessing the repository occurs.Copyright © 2010 - 2020 Adobe. All Rights Reserved