Class ClientImageData


  • public class ClientImageData
    extends java.lang.Object
    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

      Fields 
      Modifier and TypeFieldDescription
      java.lang.Stringalt
      The "ALT" property string for IMG.
      intheight
      Height of image part to display.
      intimageHeight
      Height of entire image (when different device pixel ratio or multiple).
      intimageType
      Type of client image: 0=bitmap, 1=fontIcon, 2=svg.
      intimageWidth
      Width of entire image (when different device pixel ratio or multiple).
      booleanisMulti
      Flag indicating multiple image type.
      intwidth
      Width of image part to display.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      ClientImageData​(FontIconDefinition fontIcon)
      Creates a new instance for font icons.
      ClientImageData​(SVGInfo svgInfo)
      Creates a new instance for SVG.
      ClientImageData​(java.lang.String resource, java.lang.String alt, int width, int height)
      Creates a new instance for single-images.
      ClientImageData​(java.lang.String resource, java.lang.String alt, int width, int height, int imageWidth, int imageHeight, int offsetX, int offsetY)
      Creates a new instance for multiple-images.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidaddMulti​(java.lang.String resource, int matchMask, int offsetX, int offsetY)
      Adds a multiple image.
      voidaddSingle​(java.lang.String resource, int matchMask)
      Adds a single image.
      ClientImageDataadjustTo​(double dpr)
      Find best match, i.e.
      voidappend​(PropMgr propertyManager, SendTransaction trans, double dpr)
      Appends the image data to a transaction for the specified device pixel ratio.
      static voidappendNoData​(SendTransaction trans)
      Method to call when no ClientImageData is present and needs to be sent to client.
      voidcommit()
      Commits this definition for no further changes to be used in transactions.
      ClientImageDatacreateMultiResolution​(double dpr, java.lang.String resource, int imageWidth, int imageHeight, int offsetX, int offsetY)
      Creates a new resolution for a multiple image.
      ClientImageDatacreateSingleResolution​(double dpr, java.lang.String resource, int imageWidth, int imageHeight)
      Creates a new resolution for a single image.
      java.lang.StringgetDefaultResource()
      Gets the default image resource string.
      java.lang.StringgetKStringNonBitmap​(KStringHTMLImageTag source, IKStringInfoProvider provider)
      Appends the font icon or SVG definition to a KString tag.
      booleanisBitmap()
      Returns if the image is a bitmap image type.
      booleanisFontIcon()
      Returns if the image is a font icon image type.
      booleanisSVG()
      Returns if the image is SVG.
      java.lang.StringtoString()
      To debug String.
      voidunCommit()
      Uncommits the ClientImageData to enable it e.g.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • imageType

        public final int imageType
        Type of client image: 0=bitmap, 1=fontIcon, 2=svg.
      • isMulti

        public final boolean isMulti
        Flag indicating multiple image type.
      • alt

        public final java.lang.String alt
        The "ALT" property string for IMG.
      • width

        public final int width
        Width of image part to display.
      • height

        public final int height
        Height of image part to display.
      • imageWidth

        public final int imageWidth
        Width of entire image (when different device pixel ratio or multiple).
      • imageHeight

        public final int imageHeight
        Height of entire image (when different device pixel ratio or multiple).
    • Constructor Detail

      • ClientImageData

        public ClientImageData​(FontIconDefinition fontIcon)
        Creates a new instance for font icons.
      • ClientImageData

        public ClientImageData​(SVGInfo svgInfo)
        Creates a new instance for SVG.
      • ClientImageData

        public ClientImageData​(java.lang.String resource,
                               java.lang.String alt,
                               int width,
                               int height)
        Creates a new instance for single-images.
      • ClientImageData

        public ClientImageData​(java.lang.String resource,
                               java.lang.String alt,
                               int width,
                               int height,
                               int imageWidth,
                               int imageHeight,
                               int offsetX,
                               int offsetY)
        Creates a new instance for multiple-images.
    • Method Detail

      • addSingle

        public void addSingle​(java.lang.String resource,
                              int matchMask)
        Adds a single image.
      • addMulti

        public void addMulti​(java.lang.String resource,
                             int matchMask,
                             int offsetX,
                             int offsetY)
        Adds a multiple image.
      • createSingleResolution

        public ClientImageData createSingleResolution​(double dpr,
                                                      java.lang.String resource,
                                                      int imageWidth,
                                                      int imageHeight)
        Creates a new resolution for a single image.
      • createMultiResolution

        public ClientImageData createMultiResolution​(double dpr,
                                                     java.lang.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 new commit() is performed.
      • append

        public void append​(PropMgr propertyManager,
                           SendTransaction trans,
                           double dpr)
        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

        public static void appendNoData​(SendTransaction trans)
        Method to call when no ClientImageData is present and needs to be sent to client.
        Parameters:
        trans - The transaction.
      • toString

        public java.lang.String toString()
        To debug String.
        Overrides:
        toString in class java.lang.Object
      • getDefaultResource

        public java.lang.String getDefaultResource()
        Gets the default image resource string.
        Returns:
        The resource, or null for none.
      • adjustTo

        public ClientImageData adjustTo​(double dpr)
        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

        public java.lang.String getKStringNonBitmap​(KStringHTMLImageTag source,
                                                    IKStringInfoProvider provider)
        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.