@OpenApiAll public class ImageTool extends Tool
Modifier and Type | Class and Description |
---|---|
class |
ImageTool.ImageProperty
Class that store image and its properties e.g., format, path ect.
|
ITool.HTMLString, ITool.RetainedString, ITool.Void
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONTEXT_NAME
Contains a context name.
|
static int |
DEFAULT_DPI
The default DPI which is 96.
|
static int |
HIGH
The scaling quality high.
|
static int |
HIGHEST
The scaling quality highest.
|
static int |
LOW
The scaling quality low.
|
static int |
LOWEST
The scaling quality lowest.
|
static int |
MEDIUM
The scaling quality medium.
|
static int |
PAPER_SIZE
Constant value for paper size.
|
static int |
REDUCE_TO_PAPER_SIZE
Constant value for paper size.
|
context, properties
Constructor and Description |
---|
ImageTool()
Prevent empty initiate.
|
ImageTool(ITemplateEngine engine)
Create an image tool with engine.
|
Modifier and Type | Method and Description |
---|---|
protected float[] |
calculatePaperWidthHeight()
Deprecated.
see
getPaperBounds() |
Image |
copy(java.lang.String location)
Copy an external image from local file or URL into report.
|
protected IFormatterWrapper |
createFormatterWrapper(java.lang.Class<?> engineClass)
Create the formatter wrapper from given engine class.
|
ITool.RetainedString |
createImageWithAbsolutePath(Image image)
Export image and return absolute path of the file.
This method is suitable for TXT, HTML and XML template only. Use the method with above template types, the image would be exported on a file system and return absolute path. Use the method with other template types, the image would be exported in a report output and return INVALID path. |
ITool.RetainedString |
createImageWithAbsolutePath(Image image,
boolean includeURI)
Export image and return absolute path of the file.
This method is suitable for TXT, HTML and XML template only. Use the method with above template types, the image would be exported on a file system and return absolute path. Use the method with other template types, the image would be exported in a report output and return INVALID path. |
ITool.RetainedString |
createImageWithRelativePath(Image image)
Export image and return relative path of image file.
This method is suitable for TXT, HTML and XML template only. Use the method with above template types, the image would be exported on a file system and return relative path. Use the method with other template types, the image would be exported in a report output and return INVALID path. |
ITool.Void |
createSilentImage(Image image)
Create image and do not return any path.
|
ITool.RetainedString |
getAbsolutePath(Image image)
Return an absolute path of image file.
|
ITool.RetainedString |
getAbsolutePath(Image image,
boolean includeURI)
Return an absolute path of image file.
|
ImageTool.ImageProperty |
getImageProperty(Image image)
Get ImageProperty object
|
protected java.awt.Rectangle |
getPaperBounds()
Calculate the paper bounds.
|
ITool.RetainedString |
getRelativePath(Image image)
Return a possible relative path of image file.
|
Image |
include(java.lang.String location)
Include an external image from local file or URL into report.
|
Image |
limitImageSize(Image image)
Limit image size to paper page size.
|
Image |
limitImageSize(Image image,
int maximumWidthPixel,
int maximumHeightPixel)
Limit image size to paper page size and maximum size.
|
Image |
limitImageSize(Image image,
java.lang.String maximumWidth,
java.lang.String maximumHeight)
Limit image size to paper page size and maximum size.
|
int |
measureToPixel(java.lang.String measure)
Transforms measurements into pixel count.
|
Image |
rotateLeft(Image image)
Return the image transform with clockwise rotation transformation.
|
Image |
rotateRight(Image image)
Return the image transformed with clockwise rotation transformation.
|
Image |
scale(Image image,
double sxy)
Convenience method to scale equally in height and width.
|
Image |
scale(Image image,
double sx,
double sy)
Return the image after scaling transformation.
|
ITool.Void |
setDPI(int newDpi)
Sets the DPI value for this document.
|
Image |
setHeight(Image image,
int height)
Return the image from specified height.
|
Image |
setHeight(Image image,
int height,
boolean keepratio)
Return the image from specified height.
|
Image |
setHeight(Image image,
java.lang.String height)
Scale the image by the given height measurement, keeping the ratio.
|
Image |
setHeight(Image image,
java.lang.String height,
boolean keepRatio)
Scale the image by the given height measurement, and keep ratio if set.
|
ITool.Void |
setScalingQuality(int quality)
Sets the image scaling quality.
|
void |
setSeparateChar(java.lang.String separateChar)
Set separate character for printing image path.
For example. "/" or "\" |
Image |
setSize(Image image,
int width,
int height)
Return the image from specified width and height.
|
Image |
setSize(Image image,
java.lang.String width,
java.lang.String height)
Scale the image by the given width/height measurements.
|
Image |
setSize(Image image,
java.lang.String width,
java.lang.String height,
boolean overrideAutoSizing)
Scale the image by the given width/height measurements.
|
Image |
setWidth(Image image,
int width)
Return the image from specified width.
|
Image |
setWidth(Image image,
int width,
boolean keepratio)
Return the image from specified width.
|
Image |
setWidth(Image image,
java.lang.String width)
Scale the image by the given width measurements, keeping the ratio.
|
Image |
setWidth(Image image,
java.lang.String width,
boolean keepRatio)
Scale the image by the given width measurement, and keep ratio if set.
|
java.util.List<Image> |
split(Image image)
Split the image into rows and columns with automatic number of rows and columns, and draw each chunked image
from left-to-right and top-to-bottom.
|
java.util.List<Image> |
split(Image image,
int cols,
int rows)
Split the image into rows and columns, and draw each chunked image from left-to-right and top-to-bottom.
|
clone, getContext, getProperties, getProperty, getProperty, notifyObservers, setContext, setProperties
public static final java.lang.String CONTEXT_NAME
public static final int LOWEST
public static final int LOW
public static final int MEDIUM
public static final int HIGH
public static final int HIGHEST
public static final int PAPER_SIZE
$image.setWidth($diagram.image, -1)
public static final int DEFAULT_DPI
public static final int REDUCE_TO_PAPER_SIZE
$image.setWidth($diagram.image, -2)
public ImageTool()
public ImageTool(ITemplateEngine engine)
engine
- default global enginepublic void setSeparateChar(java.lang.String separateChar)
separateChar
- character for printing image path.public Image scale(Image image, double sxy)
image
- the image to be scaled.sxy
- the scaling factor for both height and widthImage
public Image scale(Image image, double sx, double sy)
Note: new image id is ${old.id}-${sx},${sy}
image
- report imagesx
- the amount by which X coordinates in subsequent rendering operations are multiplied relative to
previous rendering operations.sy
- the amount by which Y coordinates in subsequent rendering operations are multiplied relative to
previous rendering operations.Image
public Image setSize(Image image, int width, int height)
image
- report imagewidth
- the new width for this image objectheight
- the new height for this image objectImage
public Image setSize(Image image, java.lang.String width, java.lang.String height)
image
- the image to be scaled.width
- the width as in, cm, mm, pt or pxheight
- the height as in, cm, mm, pt or pxImage
public Image setSize(Image image, java.lang.String width, java.lang.String height, boolean overrideAutoSizing)
image
- the image to be scaled.width
- the width as in, cm, mm, pt or pxheight
- the height as in, cm, mm, pt or pxoverrideAutoSizing
- setSize function will override AutoImageResizing function when true; otherwise, AutoImageResizing option will override set size.Image
public Image setWidth(Image image, int width)
image
- report imagewidth
- the new width for this image objectpublic Image setWidth(Image image, int width, boolean keepratio)
image
- report imagewidth
- the new width for this image objectkeepratio
- keep image ratio when true; otherwise falseImage
public Image setWidth(Image image, java.lang.String width)
image
- the image to be scaled.width
- the width as in, cm, mm, pt or pxImage
public Image setWidth(Image image, java.lang.String width, boolean keepRatio)
image
- the image to be scaled.width
- the width as in, cm, mm, pt or pxkeepRatio
- keeps image ratio if set to trueImage
public Image setHeight(Image image, int height)
image
- report imageheight
- the new height for this image objectImage
public Image setHeight(Image image, int height, boolean keepratio)
image
- report imageheight
- the new height for this image objectkeepratio
- keep image ratio when true; otherwise falseImage
public Image setHeight(Image image, java.lang.String height)
image
- the image to be scaled.height
- the height as in, cm, mm, pt or pxImage
public Image setHeight(Image image, java.lang.String height, boolean keepRatio)
image
- the image to be scaled.height
- the height as in, cm, mm, pt or pxkeepRatio
- keeps image ratio if set to trueImage
public Image rotateRight(Image image)
image
- report imageImage
public Image rotateLeft(Image image)
image
- report imageImage
public ITool.Void setDPI(int newDpi)
newDpi
- the new dpi value, default is 96.public ITool.Void setScalingQuality(int quality)
public int measureToPixel(java.lang.String measure)
measure
- the measurement in inches, cm, mm or pixelspublic Image include(java.lang.String location) throws java.net.MalformedURLException
$image.include('c:/my document/logo.gif')
$image.include('http://www.magicdraw.com/images/product_boxes/MD.gif')
location
- an image location. Location format can be either URI or system file.java.net.MalformedURLException
- invalid location formatpublic Image copy(java.lang.String location) throws java.net.MalformedURLException
$image.copy('c:/my document/logo.gif')
$image.copy('http://www.magicdraw.com/images/product_boxes/MD.gif')
location
- an image location. Location format can be either URI or system file.java.net.MalformedURLException
- invalid location formatprotected float[] calculatePaperWidthHeight()
getPaperBounds()
protected java.awt.Rectangle getPaperBounds()
protected IFormatterWrapper createFormatterWrapper(java.lang.Class<?> engineClass)
engineClass
- the engine classIFormatterWrapper
public java.util.List<Image> split(Image image)
image
- the original image.split(Image, int, int)
public java.util.List<Image> split(Image image, int cols, int rows)
Note:
PAPER_SIZE
will be determined from property TemplateConstants.TEMPLATE_INPUT_FORMAT
.PAPER_SIZE
is specified but cannot be determined that specific cols or rows won't be
split.
image
- the original image.cols
- number of columns. Specifies PAPER_SIZE
to automatic calculate number of columns from
paper width.rows
- number of rows. Specifies PAPER_SIZE
to automatic calculate number of rows from paper
height.public ITool.Void createSilentImage(Image image)
image
- an image to be createdpublic ITool.RetainedString createImageWithRelativePath(Image image)
image
- an image to be createdpublic ITool.RetainedString createImageWithAbsolutePath(Image image)
image
- an image to be createdpublic ITool.RetainedString createImageWithAbsolutePath(Image image, boolean includeURI)
image
- an image to be createdincludeURI
- true to include uri in pathpublic ITool.RetainedString getRelativePath(Image image)
image
- an imagepublic ITool.RetainedString getAbsolutePath(Image image)
image
- an imagepublic ITool.RetainedString getAbsolutePath(Image image, boolean includeURI)
image
- an imageincludeURI
- true to include uri in pathpublic ImageTool.ImageProperty getImageProperty(Image image)
image
- current imagepublic Image limitImageSize(Image image)
image
- imagepublic Image limitImageSize(Image image, java.lang.String maximumWidth, java.lang.String maximumHeight)
image
- imagemaximumWidth
- maximum width of image as in, cm, mm, pt or pxmaximumHeight
- maximum height of image as in, cm, mm, pt or pxpublic Image limitImageSize(Image image, int maximumWidthPixel, int maximumHeightPixel)
image
- imagemaximumWidthPixel
- maximum width of image as pixel numbermaximumHeightPixel
- maximum height of image as pixel numberCopyright © 2010 - No Magic Asia