public final void init(final int WIDTH, final int HEIGHT) {
        if (WIDTH <= 1 || HEIGHT <= 1) {
            return;
        }

        if (bgImage != null) {
            bgImage.flush();
        }

        if (lcdImage != null) {
            lcdImage.flush();
        }

        if (glowImageOn != null) {
            glowImageOn.flush();
        }
        glowImageOn = GlowImageFactory.INSTANCE.createLcdGlow(WIDTH, HEIGHT, glowColor, true);

        lcdImage = create_LCD_Image(WIDTH, HEIGHT, null);
        final double CORNER_RADIUS = WIDTH > HEIGHT ? (HEIGHT * 0.095) : (WIDTH * 0.095);
        disabledShape = new RoundRectangle2D.Double(0, 0, WIDTH, HEIGHT, CORNER_RADIUS, CORNER_RADIUS);
        if (isDigitalFont()) {
            lcdValueFont = LCD_DIGITAL_FONT.deriveFont(0.7f * getInnerBounds().height).deriveFont(Font.PLAIN);
            if (useCustomLcdUnitFont) {
                lcdUnitFont = customLcdUnitFont.deriveFont(0.2f * getInnerBounds().height);
            } else {
                lcdUnitFont = LCD_STANDARD_FONT.deriveFont(0.2f * getInnerBounds().height);
            }
        } else {
            lcdValueFont = LCD_STANDARD_FONT.deriveFont(0.625f * getInnerBounds().height);
            if (useCustomLcdUnitFont) {
                lcdUnitFont = customLcdUnitFont.deriveFont(0.2f * getInnerBounds().height);
            } else {
                lcdUnitFont = LCD_STANDARD_FONT.deriveFont(0.2f * getInnerBounds().height);
            }
        }
        lcdInfoFont = LCD_STANDARD_FONT.deriveFont(Font.BOLD, 0.18f * getInnerBounds().height);

        if (lcdThresholdImage != null) {
            lcdThresholdImage.flush();
        }
        lcdThresholdImage = create_LCD_THRESHOLD_Image((int) (HEIGHT * 0.2045454545), (int) (HEIGHT * 0.2045454545), lcdColor.TEXT_COLOR);

        if (!sections.isEmpty()) {
            sectionsBackground.clear();
            sectionsForeground.clear();

            final float[] HSB_START = (Color.RGBtoHSB(lcdColor.GRADIENT_START_COLOR.getRed(), lcdColor.GRADIENT_START_COLOR.getGreen(), lcdColor.GRADIENT_START_COLOR.getBlue(), null));
            final float[] HSB_FRACTION1 = (Color.RGBtoHSB(lcdColor.GRADIENT_FRACTION1_COLOR.getRed(), lcdColor.GRADIENT_FRACTION1_COLOR.getGreen(), lcdColor.GRADIENT_FRACTION1_COLOR.getBlue(), null));
            final float[] HSB_FRACTION2 = (Color.RGBtoHSB(lcdColor.GRADIENT_FRACTION2_COLOR.getRed(), lcdColor.GRADIENT_FRACTION2_COLOR.getGreen(), lcdColor.GRADIENT_FRACTION2_COLOR.getBlue(), null));
            final float[] HSB_FRACTION3 = (Color.RGBtoHSB(lcdColor.GRADIENT_FRACTION3_COLOR.getRed(), lcdColor.GRADIENT_FRACTION3_COLOR.getGreen(), lcdColor.GRADIENT_FRACTION3_COLOR.getBlue(), null));
            final float[] HSB_STOP = (Color.RGBtoHSB(lcdColor.GRADIENT_STOP_COLOR.getRed(), lcdColor.GRADIENT_STOP_COLOR.getGreen(), lcdColor.GRADIENT_STOP_COLOR.getBlue(), null));

            // Hue values of the gradient colors
            final float HUE_START = HSB_START[0];
            final float HUE_FRACTION1 = HSB_FRACTION1[0];
            final float HUE_FRACTION2 = HSB_FRACTION2[0];
            final float HUE_FRACTION3 = HSB_FRACTION3[0];
            final float HUE_STOP = HSB_STOP[0];

            // Brightness values of the gradient colors
            final float BRIGHTNESS_START = HSB_START[2];
            final float BRIGHTNESS_FRACTION1 = HSB_FRACTION1[2];
            final float BRIGHTNESS_FRACTION2 = HSB_FRACTION2[2];
            final float BRIGHTNESS_FRACTION3 = HSB_FRACTION3[2];
            final float BRIGHTNESS_STOP = HSB_STOP[2];

            for (Section section : sections) {
                final Color[] BACKGROUND_COLORS;
                final Color FOREGROUND_COLOR;
                final float[] HSB_SECTION = Color.RGBtoHSB(section.getColor().getRed(), section.getColor().getGreen(), section.getColor().getBlue(), null);
                final float HUE_SECTION = HSB_SECTION[0];
                final float SATURATION_SECTION = HSB_SECTION[1];
                final float BRIGHTNESS_SECTION = HSB_SECTION[2];
                if (!UTIL.isMonochrome(section.getColor())) {
                    // Section color is not monochrome
                    if (lcdColor == LcdColor.SECTIONS_LCD) {
                        BACKGROUND_COLORS = new Color[]{
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_START - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_FRACTION1 - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_FRACTION2 - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_FRACTION3 - 0.31f)),
                            new Color(Color.HSBtoRGB(HUE_SECTION, SATURATION_SECTION, BRIGHTNESS_STOP - 0.31f))
                        };
                    } else {
                        final float HUE_DIFF = HUE_SECTION - HUE_FRACTION3;
                        BACKGROUND_COLORS = new Color[]{
                            UTIL.setHue(lcdColor.GRADIENT_START_COLOR, (HUE_START + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_FRACTION1_COLOR, (HUE_FRACTION1 + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_FRACTION2_COLOR, (HUE_FRACTION2 + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_FRACTION3_COLOR, (HUE_FRACTION3 + HUE_DIFF) % 360),
                            UTIL.setHue(lcdColor.GRADIENT_STOP_COLOR, (HUE_STOP + HUE_DIFF) % 360)
                        };
                    }
                    FOREGROUND_COLOR = UTIL.setSaturationBrightness(section.getColor(), 0.57f, 0.83f);
                } else {
                    // Section color is monochrome
                    final float BRIGHTNESS_DIFF = BRIGHTNESS_SECTION - BRIGHTNESS_FRACTION1;

                    BACKGROUND_COLORS = new Color[]{
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_START_COLOR, 0, BRIGHTNESS_START + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_FRACTION1_COLOR, 0, BRIGHTNESS_FRACTION1 + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_FRACTION2_COLOR, 0, BRIGHTNESS_FRACTION2 + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_FRACTION3_COLOR, 0, BRIGHTNESS_FRACTION3 + BRIGHTNESS_DIFF),
                        UTIL.setSaturationBrightness(lcdColor.GRADIENT_STOP_COLOR, 0, BRIGHTNESS_STOP + BRIGHTNESS_DIFF)
                    };
                    if (UTIL.isDark(section.getColor())) {
                        FOREGROUND_COLOR = Color.WHITE;
                    } else {
                        FOREGROUND_COLOR = Color.BLACK;
                    }
                }
                sectionsBackground.add(create_LCD_Image(WIDTH, HEIGHT, BACKGROUND_COLORS));
                sectionsForeground.add(FOREGROUND_COLOR);
            }
        }

        // Quality overlay related parameters
        overlayCornerRadius = WIDTH > HEIGHT ? (HEIGHT * 0.095) - 1 : (WIDTH * 0.095) - 1;
        overlayFactor = (float) (lcdValue / (lcdMaxValue - lcdMinValue));
        if (Double.compare(overlayFactor, 1.0) > 0) {
            factor = 1.0f;
        } else if (Double.compare(overlayFactor, 0) < 0) {
            factor = 0.0f;
        } else {
            factor = overlayFactor;
        }
        overlayColors = new Color[] {
            UTIL.setAlpha(qualityOverlayLookup.getColorAt(factor), 0.5f),
            UTIL.setAlpha(qualityOverlayLookup.getColorAt(factor).darker(), 0.5f),
            UTIL.setAlpha(qualityOverlayLookup.getColorAt(factor), 0.5f)
        };
        final int INSET = (int) (qualityOverlay.getHeight() * 0.0909090909);
        overlayInsets.set(INSET, INSET, INSET, INSET);
        qualityOverlayLookup = new GradientWrapper(new Point2D.Double(overlayInsets.left, 0), new Point2D.Double(lcdImage.getMinX() + lcdImage.getWidth() - overlayInsets.right, 0), qualityOverlayFractions, qualityOverlayColors);
        qualityOverlayGradient = new LinearGradientPaint(new Point2D.Double(0, overlayInsets.top), new Point2D.Double(0, HEIGHT - overlayInsets.bottom), new float[]{0.0f, 0.5f, 1.0f}, overlayColors);
        qualityOverlay.setRoundRect(overlayInsets.left, overlayInsets.top, (INNER_BOUNDS.width * overlayFactor) - overlayInsets.left - overlayInsets.right, INNER_BOUNDS.height - overlayInsets.top - overlayInsets.bottom, overlayCornerRadius, overlayCornerRadius);

        // Prepare bargraph
        bargraphSegmentFactor = 20 / (lcdMaxValue - lcdMinValue);
        prepareBargraph(WIDTH, HEIGHT);
    }
public final void init ( final int WIDTH , final int HEIGHT ) { if ( WIDTH <= 1 || HEIGHT <= 1 ) { return ; } if ( bgImage != null ) { bgImage . flush ( ) ; } if ( lcdImage != null ) { lcdImage . flush ( ) ; } if ( glowImageOn != null ) { glowImageOn . flush ( ) ; } glowImageOn = GlowImageFactory . INSTANCE . createLcdGlow ( WIDTH , HEIGHT , glowColor , true ) ; lcdImage = create_LCD_Image ( WIDTH , HEIGHT , null ) ; final double CORNER_RADIUS = WIDTH > HEIGHT ? ( HEIGHT * 0.095 ) : ( WIDTH * 0.095 ) ; disabledShape = new RoundRectangle2D . Double ( 0 , 0 , WIDTH , HEIGHT , CORNER_RADIUS , CORNER_RADIUS ) ; if ( isDigitalFont ( ) ) { lcdValueFont = LCD_DIGITAL_FONT . deriveFont ( 0.7f * getInnerBounds ( ) . height ) . deriveFont ( Font . PLAIN ) ; if ( useCustomLcdUnitFont ) { lcdUnitFont = customLcdUnitFont . deriveFont ( 0.2f * getInnerBounds ( ) . height ) ; } else { lcdUnitFont = LCD_STANDARD_FONT . deriveFont ( 0.2f * getInnerBounds ( ) . height ) ; } } else { lcdValueFont = LCD_STANDARD_FONT . deriveFont ( 0.625f * getInnerBounds ( ) . height ) ; if ( useCustomLcdUnitFont ) { lcdUnitFont = customLcdUnitFont . deriveFont ( 0.2f * getInnerBounds ( ) . height ) ; } else { lcdUnitFont = LCD_STANDARD_FONT . deriveFont ( 0.2f * getInnerBounds ( ) . height ) ; } } lcdInfoFont = LCD_STANDARD_FONT . deriveFont ( Font . BOLD , 0.18f * getInnerBounds ( ) . height ) ; if ( lcdThresholdImage != null ) { lcdThresholdImage . flush ( ) ; } lcdThresholdImage = create_LCD_THRESHOLD_Image ( ( int ) ( HEIGHT * 0.2045454545 ) , ( int ) ( HEIGHT * 0.2045454545 ) , lcdColor . TEXT_COLOR ) ; if ( ! sections . isEmpty ( ) ) { sectionsBackground . clear ( ) ; sectionsForeground . clear ( ) ; final float [ ] HSB_START = ( Color . RGBtoHSB ( lcdColor . GRADIENT_START_COLOR . getRed ( ) , lcdColor . GRADIENT_START_COLOR . getGreen ( ) , lcdColor . GRADIENT_START_COLOR . getBlue ( ) , null ) ) ; final float [ ] HSB_FRACTION1 = ( Color . RGBtoHSB ( lcdColor . GRADIENT_FRACTION1_COLOR . getRed ( ) , lcdColor . GRADIENT_FRACTION1_COLOR . getGreen ( ) , lcdColor . GRADIENT_FRACTION1_COLOR . getBlue ( ) , null ) ) ; final float [ ] HSB_FRACTION2 = ( Color . RGBtoHSB ( lcdColor . GRADIENT_FRACTION2_COLOR . getRed ( ) , lcdColor . GRADIENT_FRACTION2_COLOR . getGreen ( ) , lcdColor . GRADIENT_FRACTION2_COLOR . getBlue ( ) , null ) ) ; final float [ ] HSB_FRACTION3 = ( Color . RGBtoHSB ( lcdColor . GRADIENT_FRACTION3_COLOR . getRed ( ) , lcdColor . GRADIENT_FRACTION3_COLOR . getGreen ( ) , lcdColor . GRADIENT_FRACTION3_COLOR . getBlue ( ) , null ) ) ; final float [ ] HSB_STOP = ( Color . RGBtoHSB ( lcdColor . GRADIENT_STOP_COLOR . getRed ( ) , lcdColor . GRADIENT_STOP_COLOR . getGreen ( ) , lcdColor . GRADIENT_STOP_COLOR . getBlue ( ) , null ) ) ; final float HUE_START = HSB_START [ 0 ] ; final float HUE_FRACTION1 = HSB_FRACTION1 [ 0 ] ; final float HUE_FRACTION2 = HSB_FRACTION2 [ 0 ] ; final float HUE_FRACTION3 = HSB_FRACTION3 [ 0 ] ; final float HUE_STOP = HSB_STOP [ 0 ] ; final float BRIGHTNESS_START = HSB_START [ 2 ] ; final float BRIGHTNESS_FRACTION1 = HSB_FRACTION1 [ 2 ] ; final float BRIGHTNESS_FRACTION2 = HSB_FRACTION2 [ 2 ] ; final float BRIGHTNESS_FRACTION3 = HSB_FRACTION3 [ 2 ] ; final float BRIGHTNESS_STOP = HSB_STOP [ 2 ] ; for ( Section section : sections ) { final Color [ ] BACKGROUND_COLORS ; final Color FOREGROUND_COLOR ; final float [ ] HSB_SECTION = Color . RGBtoHSB ( section . getColor ( ) . getRed ( ) , section . getColor ( ) . getGreen ( ) , section . getColor ( ) . getBlue ( ) , null ) ; final float HUE_SECTION = HSB_SECTION [ 0 ] ; final float SATURATION_SECTION = HSB_SECTION [ 1 ] ; final float BRIGHTNESS_SECTION = HSB_SECTION [ 2 ] ; if ( ! UTIL . isMonochrome ( section . getColor ( ) ) ) { if ( lcdColor == LcdColor . SECTIONS_LCD ) { BACKGROUND_COLORS = new Color [ ] { new Color ( Color . HSBtoRGB ( HUE_SECTION , SATURATION_SECTION , BRIGHTNESS_START - 0.31f ) ) , new Color ( Color . HSBtoRGB ( HUE_SECTION , SATURATION_SECTION , BRIGHTNESS_FRACTION1 - 0.31f ) ) , new Color ( Color . HSBtoRGB ( HUE_SECTION , SATURATION_SECTION , BRIGHTNESS_FRACTION2 - 0.31f ) ) , new Color ( Color . HSBtoRGB ( HUE_SECTION , SATURATION_SECTION , BRIGHTNESS_FRACTION3 - 0.31f ) ) , new Color ( Color . HSBtoRGB ( HUE_SECTION , SATURATION_SECTION , BRIGHTNESS_STOP - 0.31f ) ) } ; } else { final float HUE_DIFF = HUE_SECTION - HUE_FRACTION3 ; BACKGROUND_COLORS = new Color [ ] { UTIL . setHue ( lcdColor . GRADIENT_START_COLOR , ( HUE_START + HUE_DIFF ) % 360 ) , UTIL . setHue ( lcdColor . GRADIENT_FRACTION1_COLOR , ( HUE_FRACTION1 + HUE_DIFF ) % 360 ) , UTIL . setHue ( lcdColor . GRADIENT_FRACTION2_COLOR , ( HUE_FRACTION2 + HUE_DIFF ) % 360 ) , UTIL . setHue ( lcdColor . GRADIENT_FRACTION3_COLOR , ( HUE_FRACTION3 + HUE_DIFF ) % 360 ) , UTIL . setHue ( lcdColor . GRADIENT_STOP_COLOR , ( HUE_STOP + HUE_DIFF ) % 360 ) } ; } FOREGROUND_COLOR = UTIL . setSaturationBrightness ( section . getColor ( ) , 0.57f , 0.83f ) ; } else { final float BRIGHTNESS_DIFF = BRIGHTNESS_SECTION - BRIGHTNESS_FRACTION1 ; BACKGROUND_COLORS = new Color [ ] { UTIL . setSaturationBrightness ( lcdColor . GRADIENT_START_COLOR , 0 , BRIGHTNESS_START + BRIGHTNESS_DIFF ) , UTIL . setSaturationBrightness ( lcdColor . GRADIENT_FRACTION1_COLOR , 0 , BRIGHTNESS_FRACTION1 + BRIGHTNESS_DIFF ) , UTIL . setSaturationBrightness ( lcdColor . GRADIENT_FRACTION2_COLOR , 0 , BRIGHTNESS_FRACTION2 + BRIGHTNESS_DIFF ) , UTIL . setSaturationBrightness ( lcdColor . GRADIENT_FRACTION3_COLOR , 0 , BRIGHTNESS_FRACTION3 + BRIGHTNESS_DIFF ) , UTIL . setSaturationBrightness ( lcdColor . GRADIENT_STOP_COLOR , 0 , BRIGHTNESS_STOP + BRIGHTNESS_DIFF ) } ; if ( UTIL . isDark ( section . getColor ( ) ) ) { FOREGROUND_COLOR = Color . WHITE ; } else { FOREGROUND_COLOR = Color . BLACK ; } } sectionsBackground . add ( create_LCD_Image ( WIDTH , HEIGHT , BACKGROUND_COLORS ) ) ; sectionsForeground . add ( FOREGROUND_COLOR ) ; } } overlayCornerRadius = WIDTH > HEIGHT ? ( HEIGHT * 0.095 ) - 1 : ( WIDTH * 0.095 ) - 1 ; overlayFactor = ( float ) ( lcdValue / ( lcdMaxValue - lcdMinValue ) ) ; if ( Double . compare ( overlayFactor , 1.0 ) > 0 ) { factor = 1.0f ; } else if ( Double . compare ( overlayFactor , 0 ) < 0 ) { factor = 0.0f ; } else { factor = overlayFactor ; } overlayColors = new Color [ ] { UTIL . setAlpha ( qualityOverlayLookup . getColorAt ( factor ) , 0.5f ) , UTIL . setAlpha ( qualityOverlayLookup . getColorAt ( factor ) . darker ( ) , 0.5f ) , UTIL . setAlpha ( qualityOverlayLookup . getColorAt ( factor ) , 0.5f ) } ; final int INSET = ( int ) ( qualityOverlay . getHeight ( ) * 0.0909090909 ) ; overlayInsets . set ( INSET , INSET , INSET , INSET ) ; qualityOverlayLookup = new GradientWrapper ( new Point2D . Double ( overlayInsets . left , 0 ) , new Point2D . Double ( lcdImage . getMinX ( ) + lcdImage . getWidth ( ) - overlayInsets . right , 0 ) , qualityOverlayFractions , qualityOverlayColors ) ; qualityOverlayGradient = new LinearGradientPaint ( new Point2D . Double ( 0 , overlayInsets . top ) , new Point2D . Double ( 0 , HEIGHT - overlayInsets . bottom ) , new float [ ] { 0.0f , 0.5f , 1.0f } , overlayColors ) ; qualityOverlay . setRoundRect ( overlayInsets . left , overlayInsets . top , ( INNER_BOUNDS . width * overlayFactor ) - overlayInsets . left - overlayInsets . right , INNER_BOUNDS . height - overlayInsets . top - overlayInsets . bottom , overlayCornerRadius , overlayCornerRadius ) ; bargraphSegmentFactor = 20 / ( lcdMaxValue - lcdMinValue ) ; prepareBargraph ( WIDTH , HEIGHT ) ; }
<editor-fold defaultstate="collapsed" desc="Initialization">