public class ImageHelper
extends java.lang.Object
ImageHelper
...Constructor and Description |
---|
ImageHelper() |
Modifier and Type | Method and Description |
---|---|
static Layer |
createLayer(Item item)
Creates a layer of the given item.
|
static Layer |
createLayer(Node node,
java.lang.String imageName,
java.lang.String refName)
Creates a layer either by the node addressed by
imageName or
the referenced image addressed by the refName property. |
static Layer |
createLayer(Resource resource)
Creates a layer from the given resource.
|
static Layer |
createLayer(Session session,
java.lang.String path)
Creates a layer of the given item addressed by the path.
|
static java.awt.Rectangle |
getCropRect(java.lang.String rectCSV,
java.lang.String path)
d
Parses a CSV string of the form "x1,y1,x2,y2" and returns the respective
rectangle.
|
static java.lang.String |
getExtensionFromType(java.lang.String type)
Returns the extension from the given image type.
|
static java.lang.String |
getTypeFromExtension(java.lang.String ext)
Returns the image type for the given extension.
|
static java.awt.Color |
parseColor(java.lang.String s)
Converts a
String to an integer and returns the
specified Color . |
static java.awt.Color |
parseColor(java.lang.String s,
int alpha)
Converts a
String to an integer and returns the
specified Color . |
static int |
parseFontStyle(java.lang.String... styles)
Parses the font style from the given string(s).
|
static Layer |
resize(Layer layer,
java.awt.Dimension d,
java.awt.Dimension min,
java.awt.Dimension max)
Resizes the given layer according to the given dimensions.
|
static Node |
saveLayer(Layer layer,
java.lang.String type,
double quality,
Node parent,
java.lang.String filename,
boolean replace)
Saves the layer as nt:file below the given node.
|
public static java.awt.Rectangle getCropRect(java.lang.String rectCSV, java.lang.String path)
null
is
returned. The method can deal with an aspect ratio that is appended by "/" (e.g.
"x1,y1,x2,y2/ratioX,ratioY".rectCSV
- the rectangle coordinatespath
- optional path for debuggingnull
public static Layer createLayer(Node node, java.lang.String imageName, java.lang.String refName) throws RepositoryException, java.io.IOException
imageName
or
the referenced image addressed by the refName
property.node
- the current nodeimageName
- the name of the image noderefName
- the name of the reference propertynull
RepositoryException
- if a repository error occursjava.io.IOException
- if a I/O error occurspublic static Layer createLayer(Session session, java.lang.String path) throws RepositoryException, java.io.IOException
session
- to use for retrieving the itempath
- to the itemnull
RepositoryException
- if a repository error occursjava.io.IOException
- if a I/O error occurspublic static Layer createLayer(Resource resource)
InputStream
null
is returned.resource
- resourcenull
public static Layer createLayer(Item item) throws RepositoryException, java.io.IOException
item
- the itemnull
RepositoryException
- if a repository error occursjava.io.IOException
- if a I/O error occurspublic static int parseFontStyle(java.lang.String... styles)
style string | return |
---|---|
bold | AbstractFont.BOLD |
italic | AbstractFont.ITALIC |
underline | AbstractFont.UNDERLINE |
strikeout | AbstractFont.STRIKEOUT |
all other | AbstractFont.PLAIN |
styles
- the stylespublic static Layer resize(Layer layer, java.awt.Dimension d, java.awt.Dimension min, java.awt.Dimension max)
null
is returned.
Examples:
| lW | lH | dW | dH | minW | maxW | minH | maxH | w | h | comment | | | | 400 | 200 | 0 | 0 | 0 | 0 | 400 | 200 | no resizing | | | | 400 | 200 | 0 | 200 | 0 | 0 | 200 | 100 | 200 max width applies | | 120 | 80 | 0 | 0 | 100 | 400 | 50 | 100 | 120 | 80 | within bounds | | 120 | 80 | 0 | 0 | 0 | 100 | 50 | 100 | 100 | 60 | 100 max width applies | | 400 | 100 | 300 | 0 | 0 | 0 | 0 | 0 | 300 | 75 | resize proportional | | 400 | 100 | 300 | 0 | 0 | 0 | 0 | 50 | 200 | 50 | max height applies |
layer
- layer to resize.d
- dimensionmin
- minimal dimension constraintsmax
- maximal dimension constraintsnull
if untouched.public static java.awt.Color parseColor(java.lang.String s)
String
to an integer and returns the
specified Color
. This method handles string
formats that are used to represent octal and hexadecimal numbers.
If the string cannot be converted an transparent black is returned.s
- a String
that represents an RGBA color as a 32-bit integerColor
object.Integer.decode(java.lang.String)
public static java.awt.Color parseColor(java.lang.String s, int alpha)
String
to an integer and returns the
specified Color
. This method handles string
formats that are used to represent octal and hexadecimal numbers.
If the string cannot be converted an transparent black is returned.s
- a String
that represents an RGB color as a 24-bit integeralpha
- override the alpha settingColor
object.Integer.decode(java.lang.String)
public static Node saveLayer(Layer layer, java.lang.String type, double quality, Node parent, java.lang.String filename, boolean replace) throws RepositoryException, java.io.IOException
layer
- the layer to savetype
- image type. eg "image/png"quality
- image quality. eg 1.0parent
- parent nodefilename
- file namereplace
- if true
existing node are replaced rather than updated.RepositoryException
- if a repository error occurrsjava.io.IOException
- if an I/O error occurrspublic static java.lang.String getTypeFromExtension(java.lang.String ext)
ext
- the extensionnull
.public static java.lang.String getExtensionFromType(java.lang.String type)
type
- the mime typenull
.Copyright © 2010 - 2020 Adobe. All Rights Reserved