Package com.iizix.prop.image
Class ClientImageData
java.lang.Object
com.iizix.prop.image.ClientImageData
The Client image data. This data is transmitted between Server and JavaScript Client for an image. When building this class (adding image styles), this must be done in a thread-safe manner.
- Author:
- Christopher Mindus
Field Summary
Modifier and TypeFieldDescriptionfinal String
The "ALT" property string for IMG.final int
Height of image part to display.final int
Height of entire image (when different device pixel ratio or multiple).final int
Type of client image: 0=bitmap, 1=fontIcon, 2=svg.final int
Width of entire image (when different device pixel ratio or multiple).final boolean
Flag indicating multiple image type.final int
Width of image part to display.Constructor Summary
ConstructorDescriptionClientImageData
(FontIconDefinition fontIcon) Creates a new instance for font icons.ClientImageData
(SVGInfo svgInfo) Creates a new instance for SVG.ClientImageData
(String resource, String alt, int width, int height) Creates a new instance for single-images.ClientImageData
(String resource, String alt, int width, int height, int imageWidth, int imageHeight, int offsetX, int offsetY) Creates a new instance for multiple-images.Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a multiple image.void
Adds a single image.adjustTo
(double dpr) Find best match, i.e.void
append
(PropMgr propertyManager, SendTransaction trans, double dpr) Appends the image data to a transaction for the specified device pixel ratio.static void
appendNoData
(SendTransaction trans) Method to call when no ClientImageData is present and needs to be sent to client.void
commit()
Commits this definition for no further changes to be used in transactions.createMultiResolution
(double dpr, String resource, int imageWidth, int imageHeight, int offsetX, int offsetY) Creates a new resolution for a multiple image.createSingleResolution
(double dpr, String resource, int imageWidth, int imageHeight) Creates a new resolution for a single image.Gets the default image resource string.getKStringNonBitmap
(KStringHTMLImageTag source, IKStringInfoProvider provider) Appends the font icon or SVG definition to a KString tag.boolean
isBitmap()
Returns if the image is a bitmap image type.boolean
Returns if the image is a font icon image type.boolean
isSVG()
Returns if the image is SVG.toString()
To debug String.void
unCommit()
Uncommits the ClientImageData to enable it e.g.
Field Details
imageType
public final int imageTypeType of client image: 0=bitmap, 1=fontIcon, 2=svg.isMulti
public final boolean isMultiFlag indicating multiple image type.alt
The "ALT" property string for IMG.width
public final int widthWidth of image part to display.height
public final int heightHeight of image part to display.imageWidth
public final int imageWidthWidth of entire image (when different device pixel ratio or multiple).imageHeight
public final int imageHeightHeight of entire image (when different device pixel ratio or multiple).
Constructor Details
ClientImageData
Creates a new instance for font icons.ClientImageData
Creates a new instance for SVG.ClientImageData
Creates a new instance for single-images.ClientImageData
public ClientImageData(String resource, String alt, int width, int height, int imageWidth, int imageHeight, int offsetX, int offsetY) Creates a new instance for multiple-images.
Method Details
addSingle
Adds a single image.addMulti
Adds a multiple image.createSingleResolution
public ClientImageData createSingleResolution(double dpr, String resource, int imageWidth, int imageHeight) Creates a new resolution for a single image.createMultiResolution
public ClientImageData createMultiResolution(double dpr, String resource, int imageWidth, int imageHeight, int offsetX, int offsetY) Creates a new resolution for a multiple image.commit
public void commit()Commits this definition for no further changes to be used in transactions.unCommit
public void unCommit()Uncommits the ClientImageData to enable it e.g. to have a new DPR resolution added. The previously committed data remains until a newcommit()
is performed.append
Appends the image data to a transaction for the specified device pixel ratio.- Parameters:
propertyManager
- The property manager.trans
- The transaction.dpr
- The display pixel ratio on the client device.
appendNoData
Method to call when no ClientImageData is present and needs to be sent to client.- Parameters:
trans
- The transaction.
toString
To debug String.getDefaultResource
Gets the default image resource string.- Returns:
- The resource, or null for none.
adjustTo
Find best match, i.e. the exact match first, otherwise the one that is just larger in DPR.- Parameters:
dpr
- The device pixel ratio.- Returns:
- The ClientImageData to use for the DPR, or "this" if no match was found.
isBitmap
public boolean isBitmap()Returns if the image is a bitmap image type.isFontIcon
public boolean isFontIcon()Returns if the image is a font icon image type.isSVG
public boolean isSVG()Returns if the image is SVG.getKStringNonBitmap
Appends the font icon or SVG definition to a KString tag.- Parameters:
source
- The source KString tag.provider
- The information provider.- Returns:
- The string to use.