Class AnnotationBuilder


  • public final class AnnotationBuilder
    extends Object
    Utility to have an image to apply to canvas of chart in order to add HTML custom information on chart.
    The utility is leveraging on svg+mxl and foreignObject elements.
    The HTML content MUST be XML well-formed, following the xHTML specification, when passed as string.
    This is the SVG XML tree, used:

     <svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}">
        <foreignObject width="100%" height="100%">
           <div xmlns="http://www.w3.org/1999/xhtml">
           ... HTML XML well-formed content ....
           </div>
        </foreignObject>
     </svg>
     
    Drawing the image on canvas, you could get the java script error NS_ERROR_NOT_AVAILABLE which means that if even the content is well-formed, it contains some invalid characters, not allowed in the xHTML.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • build

        public static Img build​(BaseHtmlElement htmlXmlContent,
                                double width,
                                double height)
        Creates an image to apply to canvas with the HTML content (passed as DOM element) and width and height of the resulted image. Drawing the image on canvas, you could get the java script error NS_ERROR_NOT_AVAILABLE which means that if even the content is well-formed, it contains some invalid characters, not allowed in the xHTML.
        Parameters:
        htmlXmlContent - DOM element which represents the XML content to show
        width - width of image to be created
        height - height of image to be created
        Returns:
        an image to apply to canvas
      • build

        public static Img build​(String htmlXmlContent,
                                double width,
                                double height)
        Creates an image to apply to canvas with the HTML content (MUST BE XML well-formed) and width and height of the resulted image. Drawing the image on canvas, you could get the java script error NS_ERROR_NOT_AVAILABLE which means that if even the content is well-formed, it contains some invalid characters, not allowed in the xHTML.
        Parameters:
        htmlXmlContent - HTML content to apply on canvas, must be XML well-formed
        width - width of image to be created
        height - height of image to be created
        Returns:
        an image to apply to canvas