protected Element createElement ( Object parent , String name , String type , Style style , boolean generateId ) { if ( null == name ) { return null ; } Element parentElement ; if ( parent == null ) { parentElement = getRootElement ( ) ; } else { parentElement = getGroup ( parent ) ; } if ( parentElement == null ) { return null ; } else { Element element ; String id = generateId ? Dom . assembleId ( parentElement . getId ( ) , name ) : name ; elementToName . put ( id , name ) ; switch ( namespace ) { case SVG : element = Dom . createElementNS ( Dom . NS_SVG , type , id ) ; if ( style != null ) { applyStyle ( element , style ) ; } break ; case VML : element = Dom . createElementNS ( Dom . NS_VML , type , id ) ; Element stroke = Dom . createElementNS ( Dom . NS_VML , "stroke" ) ; element . appendChild ( stroke ) ; Element fill = Dom . createElementNS ( Dom . NS_VML , "fill" ) ; element . appendChild ( fill ) ; if ( "shape" . equals ( name ) ) { // Set the size .....if the parent has a coordsize defined, take it over: String coordsize = parentElement . getAttribute ( "coordsize" ) ; if ( coordsize != null && coordsize . length ( ) > 0 ) { element . setAttribute ( "coordsize" , coordsize ) ; } } Dom . setStyleAttribute ( element , "position" , "absolute" ) ; VmlStyleUtil . applyStyle ( element , style ) ; break ; case HTML : default : element = Dom . createElementNS ( Dom . NS_HTML , type , id ) ; if ( style != null ) { applyStyle ( element , style ) ; } } parentElement . appendChild ( element ) ; Dom . setElementAttribute ( element , "id" , id ) ; return element ; } }
Generic creation method for non - group elements .