def createImage(self, symbol, width, height, borderWidth, url):

        result = Image(url)
        # if smaller of width, height is at least twice
        # the border width, border width is used as is, otherwise,
        # it's replaced with half the smaller of width, height:
        if width < height:
            wh = width
        else:
            wh = height
        if (2*borderWidth <= wh):
            cappedBW = borderWidth
        else:
            cappedBW = int(wh/2)

        borderColor = symbol.getBorderColorCSS()
        # If border was too big to fit inside rectangle, since GChart
        # borders are uniform around the rectangle, odd-sized
        # dimensions can leave a single "leftover" 1px inside the
        # border. Set background to the border's color so that the
        # border, in effect, takes up the entire rectangle.
        if (cappedBW == borderWidth):
            backgroundColor = symbol.getBackgroundColorCSS()
        else:
            backgroundColor = borderColor
        # In principle, x,y position should also change with transparency
        # emulation in some cases. But these images are only used in
        # tables on the legend key, where they are always centered, so
        # that doesn't matter.

        if GChartConsts.TRANSPARENT_BORDER_COLOR == borderColor:
            #transparency emulation
            if cappedBW > 0:
                # to emulate an internal transparent border using a 0 width
                # border, we need to shrink the size by twice the amount
                # of the border.
                height -= 2*cappedBW; # shrink size
                width -= 2*cappedBW

            # else, external border is just eliminated, no adjustment needed
            cappedBW = 0
            borderColor = "transparent"
            if GChartConsts.TRANSPARENT_BORDER_COLOR == backgroundColor:
                backgroundColor = "transparent"


        elif cappedBW > 0:
            height -= 2*cappedBW; # shrink size to incorporate
            width -= 2*cappedBW; # impact of internal border.

        GChartUtil.setBackgroundColor(result, backgroundColor)
        GChartUtil.setBorderColor(result, borderColor)
        GChartUtil.setBorderStyle(result, symbol.getBorderStyle())
        GChartUtil.setBorderWidth(result, abs(cappedBW))
        result.setPixelSize(int(round(width)), int(round(height)))
        return result

    # creates small image of symbol (used in the chart legend).
dataset/ETHPy150Open anandology/pyjamas/library/gwt/chart/SymbolType.py/SymbolType.createImage/original