Class DOMBuilder


  • public final class DOMBuilder
    extends Object
    Singleton utility to create and manage DOM element.
    Author:
    Andrea "Stock" Stocchero
    • Method Detail

      • get

        public static DOMBuilder get()
        Returns the singleton instance of the builder.
        Returns:
        the singleton instance of the builder
      • createUniqueChartId

        public String createUniqueChartId()
        Creates an unique id for CHARBA charts id.
        Returns:
        an unique id for CHARBA charts id
      • isUniqueChartId

        public boolean isUniqueChartId​(String id)
        Returns true if the passed id is a CHARBA charts id.
        Parameters:
        id - an id instance to check
        Returns:
        true if the passed id is a CHARBA charts id
      • isCanvasSupported

        public boolean isCanvasSupported()
        Returns true if the canvas is supported by browser.
        Returns:
        true if the canvas is supported by browser
      • createCanvasElement

        public Canvas createCanvasElement()
        Creates a <canvas> element.
        Returns:
        the newly created element
      • createDivElement

        public Div createDivElement()
        Creates a <div> element.
        Returns:
        a <div> element
      • createScriptElement

        public Script createScriptElement()
        Creates a <script> element.
        Returns:
        a <script> element
      • createStyleElement

        public Style createStyleElement()
        Creates a <style> element.
        Returns:
        a <style> element
      • createLineBreakElement

        public LineBreak createLineBreakElement()
        Creates a <br> element.
        Returns:
        a <br> element
      • createSpanElement

        public Span createSpanElement()
        Creates a <span> element.
        Returns:
        a <span> element
      • createImageElement

        public Img createImageElement()
        Creates a <img> element.
        Returns:
        a <img> element
      • createImageElement

        public Img createImageElement​(String src)
        Creates a <img> element with the full URL of the image.
        Parameters:
        src - the full URL of the image
        Returns:
        a <img> element
      • createTableElement

        public Table createTableElement()
        Creates a <table> element.
        Returns:
        a <table> element
      • createTableRowElement

        public TableRow createTableRowElement()
        Creates a <tr> element.
        Returns:
        a <tr> element
      • createTableCellElement

        public TableCell createTableCellElement()
        Creates a <td> element.
        Returns:
        a <td> element
      • createHeadingElement

        public Heading createHeadingElement()
        Creates a <h3> element.
        Returns:
        a <h3> element
      • createTextNode

        public TextNode createTextNode​(String data)
        Creates a text node.
        Parameters:
        data - the text node's initial text
        Returns:
        a text node