Class SVGImageManager

java.lang.Object
org.eclnt.util.image.SVGImageManager

public class SVGImageManager extends Object
Utility for flexibly adapting flat SVG icon images and update their fill color and their size.

Purpose: have one icon imagea definition and derive all variations of the icon by this utility instead of copying/pasting the SVG multiple times.

The utitily already covers quite typical definitions of flat SVG icon images but of course can not cover all - because there is some individual variation how SVG is structured. You may add own conversion algorithms by calling addSVGImageUpdate(ISVGImageUpdate).

The utility can be called by URL as well (".ccsvg" access, DynamicImageServlet.
  • Constructor Details

    • SVGImageManager

      public SVGImageManager()
  • Method Details

    • addSVGSourceReader

      public static void addSVGSourceReader(SVGImageManager.ISVGSourceReader svgSourceReader)
    • removeSVGSourceReader

      public static void removeSVGSourceReader(SVGImageManager.ISVGSourceReader svgSourceReader)
    • addSVGImageUpdate

      public static void addSVGImageUpdate(ISVGImageUpdate svgImageUpdate)
      During the SVG image update you can add own algorithms - that are executed before the default SVG update is executed.
    • removeSVGImageUpdate

      public static void removeSVGImageUpdate(ISVGImageUpdate svgImageUpdate)
    • findImage

      public byte[] findImage(String dynImage)
      Structure: "/svg(resourcePath,color,width[,height])" Example: "/svg(images/iconssvg/test.svg,#000000,32)"
    • createImageCCSVG

      public byte[] createImageCCSVG(String path)
      Parameters:
      path - Format: [.].[.][.]
      The color values are either sent with "#" as first character or with "_" as first character.
      Returns:
    • createSVGImageBytes

      public byte[] createSVGImageBytes(String svgResource, String backgroundColor, String color, int width, int height)
    • createSVGImage

      public String createSVGImage(String svgResource, String backgroundColor, String color, int width, int height)
    • updateSVG

      public static String updateSVG(String svg, String backgroundColor, String color, int width, int height)
    • cleanSvgForParsing

      public static String cleanSvgForParsing(String svg)
    • updateBackgroundColor

      public static String updateBackgroundColor(String svg, String backgroundColor)
    • updateWidthHeight

      public static String updateWidthHeight(String svg, int width, int height)
    • readSVG

      protected String readSVG(String svgResource)