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 Type Field Description
      java.lang.String alt
      The "ALT" property string for IMG.
      int height
      Height of image part to display.
      int imageHeight
      Height of entire image (when different device pixel ratio or multiple).
      int imageType
      Type of client image: 0=bitmap, 1=fontIcon, 2=svg.
      int imageWidth
      Width of entire image (when different device pixel ratio or multiple).
      boolean isMulti
      Flag indicating multiple image type.
      int width
      Width of image part to display.
    • Constructor Summary

      Constructors 
      Constructor Description
      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 Type Method Description
      void addMulti​(java.lang.String resource, int matchMask, int offsetX, int offsetY)
      Adds a multiple image.
      void addSingle​(java.lang.String resource, int matchMask)
      Adds a single image.
      ClientImageData 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.
      ClientImageData createMultiResolution​(double dpr, java.lang.String resource, int imageWidth, int imageHeight, int offsetX, int offsetY)
      Creates a new resolution for a multiple image.
      ClientImageData createSingleResolution​(double dpr, java.lang.String resource, int imageWidth, int imageHeight)
      Creates a new resolution for a single image.
      java.lang.String getDefaultResource()
      Gets the default image resource string.
      java.lang.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 isFontIcon()
      Returns if the image is a font icon image type.
      boolean isSVG()
      Returns if the image is SVG.
      java.lang.String toString()
      To debug String.
      void unCommit()
      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.