protected BufferedImage create_BACKGROUND_Image(final int WIDTH, final String TITLE, final String UNIT_STRING, BufferedImage image) {
        if (WIDTH <= 0) {
            return null;
        }

        if (image == null) {
            image = UTIL.createImage(WIDTH, WIDTH, Transparency.TRANSLUCENT);
        }

        final Graphics2D G2 = image.createGraphics();
        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

        final int IMAGE_WIDTH = image.getWidth();
        final int IMAGE_HEIGHT = image.getHeight();

        switch (getFrameType()) {
            case SQUARE:
                BACKGROUND_FACTORY.createLinearBackground(WIDTH, WIDTH, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image);
                break;
            case ROUND:

            default:
                BACKGROUND_FACTORY.createRadialBackground(WIDTH, getBackgroundColor(), getModel().getCustomBackground(), getModel().getTextureColor(), image);
                break;
        }

        // Draw the custom layer if selected
        if (isCustomLayerVisible()) {
            G2.drawImage(UTIL.getScaledInstance(getCustomLayer(), IMAGE_WIDTH, IMAGE_HEIGHT, RenderingHints.VALUE_INTERPOLATION_BICUBIC), 0, 0, null);
        }

        final FontRenderContext RENDER_CONTEXT = new FontRenderContext(null, true, true);

        if (!TITLE.isEmpty()) {
            // Use custom label color if selected
            if (isLabelColorFromThemeEnabled()) {
                G2.setColor(getModel().getBackgroundColor().LABEL_COLOR);
            } else {
                G2.setColor(getModel().getLabelColor());
            }

            // Use custom font if selected
            if (isTitleAndUnitFontEnabled()) {
                G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.04672897196261682 * IMAGE_WIDTH)));
            } else {
                G2.setFont(new Font("Verdana", 0, (int) (0.04672897196261682 * IMAGE_WIDTH)));
            }
            final TextLayout TITLE_LAYOUT = new TextLayout(TITLE, G2.getFont(), RENDER_CONTEXT);
            final Rectangle2D TITLE_BOUNDARY = TITLE_LAYOUT.getBounds();
            G2.drawString(TITLE, (float) ((IMAGE_WIDTH - TITLE_BOUNDARY.getWidth()) / 2.0), 0.3f * IMAGE_HEIGHT + TITLE_LAYOUT.getAscent() - TITLE_LAYOUT.getDescent());
        }

        if (!UNIT_STRING.isEmpty()) {
            // Use custom label color if selected
            if (isLabelColorFromThemeEnabled()) {
                G2.setColor(getModel().getBackgroundColor().LABEL_COLOR);
            } else {
                G2.setColor(getModel().getLabelColor());
            }

            // Use custom font if selected
            if (isTitleAndUnitFontEnabled()) {
                G2.setFont(new Font(getTitleAndUnitFont().getFamily(), 0, (int) (0.04672897196261682 * IMAGE_WIDTH)));
            } else {
                G2.setFont(new Font("Verdana", 0, (int) (0.04672897196261682 * IMAGE_WIDTH)));
            }
            final TextLayout UNIT_LAYOUT = new TextLayout(UNIT_STRING, G2.getFont(), RENDER_CONTEXT);
            final Rectangle2D UNIT_BOUNDARY = UNIT_LAYOUT.getBounds();
            G2.drawString(UNIT_STRING, (float) ((IMAGE_WIDTH - UNIT_BOUNDARY.getWidth()) / 2.0), 0.38f * IMAGE_HEIGHT + UNIT_LAYOUT.getAscent() - UNIT_LAYOUT.getDescent());
        }

        G2.dispose();

        return image;
    }
protected BufferedImage create_BACKGROUND_Image ( final int WIDTH , final String TITLE , final String UNIT_STRING , BufferedImage image ) { if ( WIDTH <= 0 ) { return null ; } if ( image == null ) { image = UTIL . createImage ( WIDTH , WIDTH , Transparency . TRANSLUCENT ) ; } final Graphics2D G2 = image . createGraphics ( ) ; G2 . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; final int IMAGE_WIDTH = image . getWidth ( ) ; final int IMAGE_HEIGHT = image . getHeight ( ) ; switch ( getFrameType ( ) ) { case SQUARE : BACKGROUND_FACTORY . createLinearBackground ( WIDTH , WIDTH , getBackgroundColor ( ) , getModel ( ) . getCustomBackground ( ) , getModel ( ) . getTextureColor ( ) , image ) ; break ; case ROUND : default : BACKGROUND_FACTORY . createRadialBackground ( WIDTH , getBackgroundColor ( ) , getModel ( ) . getCustomBackground ( ) , getModel ( ) . getTextureColor ( ) , image ) ; break ; } if ( isCustomLayerVisible ( ) ) { G2 . drawImage ( UTIL . getScaledInstance ( getCustomLayer ( ) , IMAGE_WIDTH , IMAGE_HEIGHT , RenderingHints . VALUE_INTERPOLATION_BICUBIC ) , 0 , 0 , null ) ; } final FontRenderContext RENDER_CONTEXT = new FontRenderContext ( null , true , true ) ; if ( ! TITLE . isEmpty ( ) ) { if ( isLabelColorFromThemeEnabled ( ) ) { G2 . setColor ( getModel ( ) . getBackgroundColor ( ) . LABEL_COLOR ) ; } else { G2 . setColor ( getModel ( ) . getLabelColor ( ) ) ; } if ( isTitleAndUnitFontEnabled ( ) ) { G2 . setFont ( new Font ( getTitleAndUnitFont ( ) . getFamily ( ) , 0 , ( int ) ( 0.04672897196261682 * IMAGE_WIDTH ) ) ) ; } else { G2 . setFont ( new Font ( "Verdana" , 0 , ( int ) ( 0.04672897196261682 * IMAGE_WIDTH ) ) ) ; } final TextLayout TITLE_LAYOUT = new TextLayout ( TITLE , G2 . getFont ( ) , RENDER_CONTEXT ) ; final Rectangle2D TITLE_BOUNDARY = TITLE_LAYOUT . getBounds ( ) ; G2 . drawString ( TITLE , ( float ) ( ( IMAGE_WIDTH - TITLE_BOUNDARY . getWidth ( ) ) / 2.0 ) , 0.3f * IMAGE_HEIGHT + TITLE_LAYOUT . getAscent ( ) - TITLE_LAYOUT . getDescent ( ) ) ; } if ( ! UNIT_STRING . isEmpty ( ) ) { if ( isLabelColorFromThemeEnabled ( ) ) { G2 . setColor ( getModel ( ) . getBackgroundColor ( ) . LABEL_COLOR ) ; } else { G2 . setColor ( getModel ( ) . getLabelColor ( ) ) ; } if ( isTitleAndUnitFontEnabled ( ) ) { G2 . setFont ( new Font ( getTitleAndUnitFont ( ) . getFamily ( ) , 0 , ( int ) ( 0.04672897196261682 * IMAGE_WIDTH ) ) ) ; } else { G2 . setFont ( new Font ( "Verdana" , 0 , ( int ) ( 0.04672897196261682 * IMAGE_WIDTH ) ) ) ; } final TextLayout UNIT_LAYOUT = new TextLayout ( UNIT_STRING , G2 . getFont ( ) , RENDER_CONTEXT ) ; final Rectangle2D UNIT_BOUNDARY = UNIT_LAYOUT . getBounds ( ) ; G2 . drawString ( UNIT_STRING , ( float ) ( ( IMAGE_WIDTH - UNIT_BOUNDARY . getWidth ( ) ) / 2.0 ) , 0.38f * IMAGE_HEIGHT + UNIT_LAYOUT . getAscent ( ) - UNIT_LAYOUT . getDescent ( ) ) ; } G2 . dispose ( ) ; return image ; }
Returns the background image with the currently active backgroundcolor
with the given width, title and unitstring.
@param WIDTH
@param TITLE
@param UNIT_STRING
@param image
@return buffered image containing the background with the selected background design