question: public Element drawShape ( int x , int y , int w , int h , Map < String , Object > style ) { String fillColor = mxUtils . getString ( style , mxConstants . STYLE_FILLCOLOR , "none" ) ; String strokeColor = mxUtils . getString ( style , mxConstants . STYLE_STROKECOLOR ) ; float strokeWidth = ( float ) ( mxUtils . getFloat ( style , mxConstants . STYLE_STROKEWIDTH , 1 ) * scale ) ; String shape = mxUtils . getString ( style , mxConstants . STYLE_SHAPE ) ; Element elem = null ; Element background = null ; if ( shape . equals ( mxConstants . SHAPE_IMAGE ) ) { String img = getImageForStyle ( style ) ; if ( img != null ) { elem = document . createElement ( "image" ) ; elem . setAttribute ( "x" , String . valueOf ( x ) ) ; elem . setAttribute ( "y" , String . valueOf ( y ) ) ; elem . setAttribute ( "width" , String . valueOf ( w ) ) ; elem . setAttribute ( "height" , String . valueOf ( h ) ) ; elem . setAttributeNS ( mxConstants . NS_XLINK , "xlink:href" , img ) ; } } else if ( shape . equals ( mxConstants . SHAPE_LINE ) ) { String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , mxConstants . DIRECTION_EAST ) ; String d = null ; if ( direction . equals ( mxConstants . DIRECTION_EAST ) || direction . equals ( mxConstants . DIRECTION_WEST ) ) { int mid = ( int ) ( y + h / 2 ) ; d = "M " + x + " " + mid + " L " + ( x + w ) + " " + mid ; } else { int mid = ( int ) ( x + w / 2 ) ; d = "M " + mid + " " + y + " L " + mid + " " + ( y + h ) ; } elem = document . createElement ( "path" ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_ELLIPSE ) ) { elem = document . createElement ( "ellipse" ) ; elem . setAttribute ( "cx" , String . valueOf ( x + w / 2 ) ) ; elem . setAttribute ( "cy" , String . valueOf ( y + h / 2 ) ) ; elem . setAttribute ( "rx" , String . valueOf ( w / 2 ) ) ; elem . setAttribute ( "ry" , String . valueOf ( h / 2 ) ) ; } else if ( shape . equals ( mxConstants . SHAPE_DOUBLE_ELLIPSE ) ) { elem = document . createElement ( "g" ) ; background = document . createElement ( "ellipse" ) ; background . setAttribute ( "cx" , String . valueOf ( x + w / 2 ) ) ; background . setAttribute ( "cy" , String . valueOf ( y + h / 2 ) ) ; background . setAttribute ( "rx" , String . valueOf ( w / 2 ) ) ; background . setAttribute ( "ry" , String . valueOf ( h / 2 ) ) ; elem . appendChild ( background ) ; int inset = ( int ) ( ( 3 + strokeWidth ) * scale ) ; Element foreground = document . createElement ( "ellipse" ) ; foreground . setAttribute ( "fill" , "none" ) ; foreground . setAttribute ( "stroke" , strokeColor ) ; foreground . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; foreground . setAttribute ( "cx" , String . valueOf ( x + w / 2 ) ) ; foreground . setAttribute ( "cy" , String . valueOf ( y + h / 2 ) ) ; foreground . setAttribute ( "rx" , String . valueOf ( w / 2 - inset ) ) ; foreground . setAttribute ( "ry" , String . valueOf ( h / 2 - inset ) ) ; elem . appendChild ( foreground ) ; } else if ( shape . equals ( mxConstants . SHAPE_RHOMBUS ) ) { elem = document . createElement ( "path" ) ; String d = "M " + ( x + w / 2 ) + " " + y + " L " + ( x + w ) + " " + ( y + h / 2 ) + " L " + ( x + w / 2 ) + " " + ( y + h ) + " L " + x + " " + ( y + h / 2 ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_TRIANGLE ) ) { elem = document . createElement ( "path" ) ; String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , "" ) ; String d = null ; if ( direction . equals ( mxConstants . DIRECTION_NORTH ) ) { d = "M " + x + " " + ( y + h ) + " L " + ( x + w / 2 ) + " " + y + " L " + ( x + w ) + " " + ( y + h ) ; } else if ( direction . equals ( mxConstants . DIRECTION_SOUTH ) ) { d = "M " + x + " " + y + " L " + ( x + w / 2 ) + " " + ( y + h ) + " L " + ( x + w ) + " " + y ; } else if ( direction . equals ( mxConstants . DIRECTION_WEST ) ) { d = "M " + ( x + w ) + " " + y + " L " + x + " " + ( y + h / 2 ) + " L " + ( x + w ) + " " + ( y + h ) ; } else { d = "M " + x + " " + y + " L " + ( x + w ) + " " + ( y + h / 2 ) + " L " + x + " " + ( y + h ) ; } elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_HEXAGON ) ) { elem = document . createElement ( "path" ) ; String direction = mxUtils . getString ( style , mxConstants . STYLE_DIRECTION , "" ) ; String d = null ; if ( direction . equals ( mxConstants . DIRECTION_NORTH ) || direction . equals ( mxConstants . DIRECTION_SOUTH ) ) { d = "M " + ( x + 0.5 * w ) + " " + y + " L " + ( x + w ) + " " + ( y + 0.25 * h ) + " L " + ( x + w ) + " " + ( y + 0.75 * h ) + " L " + ( x + 0.5 * w ) + " " + ( y + h ) + " L " + x + " " + ( y + 0.75 * h ) + " L " + x + " " + ( y + 0.25 * h ) ; } else { d = "M " + ( x + 0.25 * w ) + " " + y + " L " + ( x + 0.75 * w ) + " " + y + " L " + ( x + w ) + " " + ( y + 0.5 * h ) + " L " + ( x + 0.75 * w ) + " " + ( y + h ) + " L " + ( x + 0.25 * w ) + " " + ( y + h ) + " L " + x + " " + ( y + 0.5 * h ) ; } elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_CLOUD ) ) { elem = document . createElement ( "path" ) ; String d = "M " + ( x + 0.25 * w ) + " " + ( y + 0.25 * h ) + " C " + ( x + 0.05 * w ) + " " + ( y + 0.25 * h ) + " " + x + " " + ( y + 0.5 * h ) + " " + ( x + 0.16 * w ) + " " + ( y + 0.55 * h ) + " C " + x + " " + ( y + 0.66 * h ) + " " + ( x + 0.18 * w ) + " " + ( y + 0.9 * h ) + " " + ( x + 0.31 * w ) + " " + ( y + 0.8 * h ) + " C " + ( x + 0.4 * w ) + " " + ( y + h ) + " " + ( x + 0.7 * w ) + " " + ( y + h ) + " " + ( x + 0.8 * w ) + " " + ( y + 0.8 * h ) + " C " + ( x + w ) + " " + ( y + 0.8 * h ) + " " + ( x + w ) + " " + ( y + 0.6 * h ) + " " + ( x + 0.875 * w ) + " " + ( y + 0.5 * h ) + " C " + ( x + w ) + " " + ( y + 0.3 * h ) + " " + ( x + 0.8 * w ) + " " + ( y + 0.1 * h ) + " " + ( x + 0.625 * w ) + " " + ( y + 0.2 * h ) + " C " + ( x + 0.5 * w ) + " " + ( y + 0.05 * h ) + " " + ( x + 0.3 * w ) + " " + ( y + 0.05 * h ) + " " + ( x + 0.25 * w ) + " " + ( y + 0.25 * h ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_ACTOR ) ) { elem = document . createElement ( "path" ) ; double width3 = w / 3 ; String d = " M " + x + " " + ( y + h ) + " C " + x + " " + ( y + 3 * h / 5 ) + " " + x + " " + ( y + 2 * h / 5 ) + " " + ( x + w / 2 ) + " " + ( y + 2 * h / 5 ) + " C " + ( x + w / 2 - width3 ) + " " + ( y + 2 * h / 5 ) + " " + ( x + w / 2 - width3 ) + " " + y + " " + ( x + w / 2 ) + " " + y + " C " + ( x + w / 2 + width3 ) + " " + y + " " + ( x + w / 2 + width3 ) + " " + ( y + 2 * h / 5 ) + " " + ( x + w / 2 ) + " " + ( y + 2 * h / 5 ) + " C " + ( x + w ) + " " + ( y + 2 * h / 5 ) + " " + ( x + w ) + " " + ( y + 3 * h / 5 ) + " " + ( x + w ) + " " + ( y + h ) ; elem . setAttribute ( "d" , d + " Z" ) ; } else if ( shape . equals ( mxConstants . SHAPE_CYLINDER ) ) { elem = document . createElement ( "g" ) ; background = document . createElement ( "path" ) ; double dy = Math . min ( 40 , Math . floor ( h / 5 ) ) ; String d = " M " + x + " " + ( y + dy ) + " C " + x + " " + ( y - dy / 3 ) + " " + ( x + w ) + " " + ( y - dy / 3 ) + " " + ( x + w ) + " " + ( y + dy ) + " L " + ( x + w ) + " " + ( y + h - dy ) + " C " + ( x + w ) + " " + ( y + h + dy / 3 ) + " " + x + " " + ( y + h + dy / 3 ) + " " + x + " " + ( y + h - dy ) ; background . setAttribute ( "d" , d + " Z" ) ; elem . appendChild ( background ) ; Element foreground = document . createElement ( "path" ) ; d = "M " + x + " " + ( y + dy ) + " C " + x + " " + ( y + 2 * dy ) + " " + ( x + w ) + " " + ( y + 2 * dy ) + " " + ( x + w ) + " " + ( y + dy ) ; foreground . setAttribute ( "d" , d ) ; foreground . setAttribute ( "fill" , "none" ) ; foreground . setAttribute ( "stroke" , strokeColor ) ; foreground . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; elem . appendChild ( foreground ) ; } else { elem = document . createElement ( "rect" ) ; elem . setAttribute ( "x" , String . valueOf ( x ) ) ; elem . setAttribute ( "y" , String . valueOf ( y ) ) ; elem . setAttribute ( "width" , String . valueOf ( w ) ) ; elem . setAttribute ( "height" , String . valueOf ( h ) ) ; if ( mxUtils . isTrue ( style , mxConstants . STYLE_ROUNDED , false ) ) { elem . setAttribute ( "rx" , String . valueOf ( w * mxConstants . RECTANGLE_ROUNDING_FACTOR ) ) ; elem . setAttribute ( "ry" , String . valueOf ( h * mxConstants . RECTANGLE_ROUNDING_FACTOR ) ) ; } } Element bg = background ; if ( bg == null ) { bg = elem ; } bg . setAttribute ( "fill" , fillColor ) ; bg . setAttribute ( "stroke" , strokeColor ) ; bg . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; Element shadowElement = null ; if ( mxUtils . isTrue ( style , mxConstants . STYLE_SHADOW , false ) && ! fillColor . equals ( "none" ) ) { shadowElement = ( Element ) bg . cloneNode ( true ) ; shadowElement . setAttribute ( "transform" , mxConstants . SVG_SHADOWTRANSFORM ) ; shadowElement . setAttribute ( "fill" , mxConstants . W3C_SHADOWCOLOR ) ; shadowElement . setAttribute ( "stroke" , mxConstants . W3C_SHADOWCOLOR ) ; shadowElement . setAttribute ( "stroke-width" , String . valueOf ( strokeWidth ) ) ; appendSvgElement ( shadowElement ) ; } double rotation = mxUtils . getDouble ( style , mxConstants . STYLE_ROTATION ) ; if ( rotation != 0 ) { int cx = x + w / 2 ; int cy = y + h / 2 ; elem . setAttribute ( "transform" , "rotate(" + rotation + "," + cx + "," + cy + ")" ) ; if ( shadowElement != null ) { shadowElement . setAttribute ( "transform" , "rotate(" + rotation + "," + cx + "," + cy + ") " + mxConstants . SVG_SHADOWTRANSFORM ) ; } } float opacity = mxUtils . getFloat ( style , mxConstants . STYLE_OPACITY , 100 ) ; if ( opacity != 100 ) { String value = String . valueOf ( opacity / 100 ) ; elem . setAttribute ( "fill-opacity" , value ) ; elem . setAttribute ( "stroke-opacity" , value ) ; if ( shadowElement != null ) { shadowElement . setAttribute ( "fill-opacity" , value ) ; shadowElement . setAttribute ( "stroke-opacity" , value ) ; } } appendSvgElement ( elem ) ; return elem ; }
target:  Draws the shape specified with the STYLE_SHAPE key in the given style.