All Downloads are FREE. Search and download functionalities are using the official Maven repository.

eu.hansolo.steelseries.gauges.DigitalRadial Maven / Gradle / Ivy

Go to download

The SteelSeries is a javabeans component library that contains gauges. You will find linear and radial gauges. In addition you will also find digital displays, indicators from cars and some instruments from airplanes and sailboats.

There is a newer version: 3.9.30
Show newest version
package eu.hansolo.steelseries.gauges;


public class DigitalRadial extends AbstractRadial
{            
    private int noOfActiveLeds = 0;
    private final java.awt.GraphicsConfiguration GFX_CONF = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration();
    private java.awt.image.BufferedImage frameImage;
    private java.awt.image.BufferedImage backgroundImage;
    private java.awt.image.BufferedImage lcdImage;
    private java.awt.image.BufferedImage foregroundImage;
    private java.awt.image.BufferedImage disabledImage;
    private java.awt.image.BufferedImage ledGreenOff = GFX_CONF.createCompatibleImage(24, 24, java.awt.Transparency.TRANSLUCENT);
    private java.awt.image.BufferedImage ledYellowOff = GFX_CONF.createCompatibleImage(24, 24, java.awt.Transparency.TRANSLUCENT);
    private java.awt.image.BufferedImage ledRedOff = GFX_CONF.createCompatibleImage(24, 24, java.awt.Transparency.TRANSLUCENT);
    private java.awt.image.BufferedImage ledGreenOn = GFX_CONF.createCompatibleImage(24, 24, java.awt.Transparency.TRANSLUCENT);
    private java.awt.image.BufferedImage ledYellowOn = GFX_CONF.createCompatibleImage(24, 24, java.awt.Transparency.TRANSLUCENT);
    private java.awt.image.BufferedImage ledRedOn = GFX_CONF.createCompatibleImage(24, 24, java.awt.Transparency.TRANSLUCENT);    
    private java.awt.Color valueColor = new java.awt.Color(255, 0, 0, 255);
    private java.awt.Point[] ledPosition;            
    private final java.awt.font.FontRenderContext RENDER_CONTEXT = new java.awt.font.FontRenderContext(null, true, true);
    private java.awt.font.TextLayout unitLayout;
    private final java.awt.geom.Rectangle2D UNIT_BOUNDARY = new java.awt.geom.Rectangle2D.Double();
    private java.awt.font.TextLayout valueLayout;
    private final java.awt.geom.Rectangle2D VALUE_BOUNDARY = new java.awt.geom.Rectangle2D.Double();
    private enum LedColor
    {
        GREEN,
        YELLOW,
        RED
    };    


    public DigitalRadial()
    {
        super();
        setUnitString("");                  
    }
        
    @Override
    public final AbstractGauge init(final int WIDTH, final int HEIGHT)
    {
        if (isDigitalFont())
        {
            setLcdValueFont(LCD_DIGITAL_FONT.deriveFont(0.7f * WIDTH * 0.15f));
        }
        else
        {
            setLcdValueFont(LCD_STANDARD_FONT.deriveFont(0.625f * WIDTH * 0.15f));       
        }

        if (getUseCustomLcdUnitFont())
        {
            setLcdUnitFont(getCustomLcdUnitFont().deriveFont(0.25f * WIDTH * 0.15f));
        }
        else
        {
            setLcdUnitFont(LCD_STANDARD_FONT.deriveFont(0.25f * WIDTH * 0.15f));
        }
        
        if (frameImage != null)
        {
            frameImage.flush();
        }
        frameImage = create_FRAME_Image(WIDTH);
        if (backgroundImage != null)
        {
            backgroundImage.flush();
        }
        backgroundImage = create_BACKGROUND_Image(WIDTH, getTitle(), getUnitString());
        if (foregroundImage != null)
        {
            foregroundImage.flush();
        }
        if (lcdImage != null)
        {
            lcdImage.flush();
        }        
        lcdImage = create_LCD_Image((int) (WIDTH * 0.48), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
        foregroundImage = create_FOREGROUND_Image(WIDTH, false, getForegroundType());
        if (disabledImage != null)
        {
            disabledImage.flush();
        }
        disabledImage = create_DISABLED_Image(WIDTH);
        
        ledPosition = new java.awt.Point[]
        {
            // LED 1
            new java.awt.Point((int) (WIDTH * 0.186915887850467), (int)(WIDTH *0.649532710280374)),
            // LED 2
            new java.awt.Point((int) (WIDTH * 0.116822429906542), (int)(WIDTH *0.546728971962617)),
            // LED 3
            new java.awt.Point((int) (WIDTH * 0.088785046728972), (int)(WIDTH *0.41588785046729)),
            // LED 4
            new java.awt.Point((int) (WIDTH * 0.116822429906542), (int)(WIDTH *0.285046728971963)),
            // LED 5
            new java.awt.Point((int) (WIDTH * 0.177570093457944), (int)(WIDTH *0.182242990654206)),
            // LED 6
            new java.awt.Point((int) (WIDTH * 0.280373831775701), (int)(WIDTH *0.117222429906542)),
            // LED 7
            new java.awt.Point((int) (WIDTH * 0.411214953271028), (int)(WIDTH *0.0794392523364486)),
            // LED 8
            new java.awt.Point((int) (WIDTH * 0.542056074766355), (int)(WIDTH *0.117222429906542)),
            // LED 9
            new java.awt.Point((int) (WIDTH * 0.649532710280374), (int)(WIDTH *0.182242990654206)),
            // LED 10
            new java.awt.Point((int) (WIDTH * 0.719626168224299), (int)(WIDTH *0.285046728971963)),
            // LED 11
            new java.awt.Point((int) (WIDTH * 0.738317757009346), (int)(WIDTH *0.41588785046729)),
            // LED 12
            new java.awt.Point((int) (WIDTH * 0.710280373831776), (int)(WIDTH *0.546728971962617)),
            // LED 13
            new java.awt.Point((int) (WIDTH * 0.64018691588785), (int)(WIDTH *0.649532710280374))
        };
        ledGreenOff.flush();
        ledGreenOff = create_LED_OFF_Image(WIDTH, LedColor.GREEN);
        ledYellowOff.flush();
        ledYellowOff = create_LED_OFF_Image(WIDTH, LedColor.YELLOW);
        ledRedOff.flush();
        ledRedOff = create_LED_OFF_Image(WIDTH, LedColor.RED);
        ledGreenOn.flush();
        ledGreenOn = create_LED_ON_Image(WIDTH, LedColor.GREEN);
        ledYellowOn.flush();
        ledYellowOn = create_LED_ON_Image(WIDTH, LedColor.YELLOW);
        ledRedOn.flush();
        ledRedOn = create_LED_ON_Image(WIDTH, LedColor.RED);

        return this;
    }

    @Override
    protected void paintComponent(java.awt.Graphics g)
    {
        if (!isInitialized())
        {            
            return;
        }
        
        super.paintComponent(g);
        final java.awt.Graphics2D G2 = (java.awt.Graphics2D) g.create();

        G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        G2.translate(getInnerBounds().x, getInnerBounds().y);

        if (isFrameVisible())
        {
            G2.drawImage(frameImage, 0, 0, null);
        }

        if (isBackgroundVisible())
        {
            G2.drawImage(backgroundImage, 0, 0, null);
        }

        for (int i = 0 ; i < 13 ; i++)
        {
            if (i < 7)
            {
                if (i < noOfActiveLeds)
                {
                    G2.drawImage(ledGreenOn, ledPosition[i].x, ledPosition[i].y, null);
                }
                else
                {
                    G2.drawImage(ledGreenOff, ledPosition[i].x, ledPosition[i].y, null);
                }
            }

            if (i >= 7 && i < 12)
            {
                if (i < noOfActiveLeds)
                {
                    G2.drawImage(ledYellowOn, ledPosition[i].x, ledPosition[i].y, null);
                }
                else
                {
                    G2.drawImage(ledYellowOff, ledPosition[i].x, ledPosition[i].y, null);
                }
            }

            if (i == 12)
            {
                if (i < noOfActiveLeds)
                {
                    G2.drawImage(ledRedOn, ledPosition[i].x, ledPosition[i].y, null);
                }
                else
                {
                    G2.drawImage(ledRedOff, ledPosition[i].x, ledPosition[i].y, null);
                }
            }
        }

        // Draw LCD display        
        if (isLcdVisible())
        {            
            G2.drawImage(lcdImage, (int) ((getGaugeBounds().width - lcdImage.getWidth()) / 2.0), (int) (getGaugeBounds().height * 0.425), null);

            if (getLcdColor() == eu.hansolo.steelseries.tools.LcdColor.CUSTOM)
            {
                G2.setColor(getCustomLcdForeground());
            }
            else
            {
                G2.setColor(getLcdColor().TEXT_COLOR);
            }
            G2.setFont(getLcdUnitFont());            
            final double UNIT_STRING_WIDTH;
            if (isLcdUnitStringVisible())
            {
                unitLayout = new java.awt.font.TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
                UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
                G2.drawString(getLcdUnitString(), (int) (((getGaugeBounds().width - lcdImage.getWidth()) / 2.0) + (lcdImage.getWidth() - UNIT_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.03), (int) ((getGaugeBounds().height * 0.425) + lcdImage.getHeight() * 0.76f));
                UNIT_STRING_WIDTH = UNIT_BOUNDARY.getWidth();
            }
            else
            {
                UNIT_STRING_WIDTH = 0;
            }
            G2.setFont(getLcdValueFont());
            valueLayout = new java.awt.font.TextLayout(formatLcdValue(getLcdValue()), G2.getFont(), RENDER_CONTEXT);
            VALUE_BOUNDARY.setFrame(valueLayout.getBounds());        
            G2.drawString(formatLcdValue(getLcdValue()), (int) (((getGaugeBounds().width - lcdImage.getWidth()) / 2.0) + (lcdImage.getWidth() - UNIT_STRING_WIDTH - VALUE_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.09), (int) ((getGaugeBounds().height * 0.425) + lcdImage.getHeight() * 0.76f));
        }
        
        if (isForegroundVisible())
        {
            G2.drawImage(foregroundImage, 0, 0, null);
        }

        if (!isEnabled())
        {
            G2.drawImage(disabledImage, 0, 0, null);
        }
        
        G2.translate(-getInnerBounds().x, -getInnerBounds().y);

        G2.dispose();
    }
    
    @Override
    public void setValue(double value)
    {
        super.setValue(value);

        // Set active leds relating to the new value
        calcNoOfActiveLed();
                
        if (isValueCoupled())
        {
            setLcdValue(value);
        }
        repaint(getInnerBounds());
    }

    @Override
    public void setMinValue(final double MIN_VALUE)
    {
        super.setMinValue(MIN_VALUE);
        calcNoOfActiveLed();
        repaint(getInnerBounds());
    }

    @Override
    public void setMaxValue(final double MAX_VALUE)
    {
        super.setMaxValue(MAX_VALUE);
        calcNoOfActiveLed();
        repaint(getInnerBounds());
    }

    private void calcNoOfActiveLed()
    {
        noOfActiveLeds = (int) (13 / (getMaxValue() - getMinValue()) * getValue());
    }

    public java.awt.Color getValueColor()
    {
        return this.valueColor;
    }

    public void setValueColor(final java.awt.Color VALUE_COLOR)
    {
        this.valueColor = VALUE_COLOR;
        repaint(getInnerBounds());
    }
        
    @Override
    public java.awt.geom.Point2D getCenter()
    {
        return new java.awt.geom.Point2D.Double(backgroundImage.getWidth() / 2.0 + getInnerBounds().x, backgroundImage.getHeight() / 2.0 + getInnerBounds().y);
    }

    @Override
    public java.awt.geom.Rectangle2D getBounds2D()
    {
        return new java.awt.geom.Rectangle2D.Double(backgroundImage.getMinX(), backgroundImage.getMinY(), backgroundImage.getWidth(), backgroundImage.getHeight());
    }

    private java.awt.image.BufferedImage create_LED_OFF_Image(final int WIDTH, final LedColor LED_COLOR)
    {
        final java.awt.image.BufferedImage IMAGE = GFX_CONF.createCompatibleImage((int) (WIDTH * 0.1775700935), (int) (WIDTH * 0.1775700935), java.awt.Transparency.TRANSLUCENT);
        final java.awt.Graphics2D G2 = IMAGE.createGraphics();
        G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
        final int IMAGE_WIDTH = IMAGE.getWidth();
        final int IMAGE_HEIGHT = IMAGE.getHeight();

        // Led background
        final java.awt.geom.Ellipse2D E_LED1_BG = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.21052631735801697, IMAGE_HEIGHT * 0.21052631735801697, IMAGE_WIDTH * 0.5526316165924072, IMAGE_HEIGHT * 0.5526316165924072);
        final java.awt.geom.Point2D E_LED1_BG_START = new java.awt.geom.Point2D.Double(0, E_LED1_BG.getBounds2D().getMinY() );
        final java.awt.geom.Point2D E_LED1_BG_STOP = new java.awt.geom.Point2D.Double(0, E_LED1_BG.getBounds2D().getMaxY() );
        final float[] E_LED1_BG_FRACTIONS =
        {
            0.0f,
            1.0f
        };
        final java.awt.Color[] E_LED1_BG_COLORS =
        {
            new java.awt.Color(0, 0, 0, 229),
            new java.awt.Color(153, 153, 153, 255)
        };        
        final java.awt.LinearGradientPaint E_LED1_BG_GRADIENT = new java.awt.LinearGradientPaint(E_LED1_BG_START, E_LED1_BG_STOP, E_LED1_BG_FRACTIONS, E_LED1_BG_COLORS);
        G2.setPaint(E_LED1_BG_GRADIENT);
        G2.fill(E_LED1_BG);

        // Led foreground
        final java.awt.geom.Ellipse2D LED_FG = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.2368421107530594, IMAGE_HEIGHT * 0.2368421107530594, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5);
        final java.awt.geom.Point2D LED_FG_CENTER = new java.awt.geom.Point2D.Double(LED_FG.getCenterX(), LED_FG.getCenterY());
        final float[] LED_FG_FRACTIONS =
        {
            0.0f,
            0.14f,
            0.15f,
            1.0f
        };
        java.awt.Color[] ledFgColors;

        switch(LED_COLOR)
        {
            case GREEN:              
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(28, 126, 0, 255),
                    new java.awt.Color(28, 126, 0, 255),
                    new java.awt.Color(28, 126, 0, 255),
                    new java.awt.Color(27, 100, 0, 255)
                };
                break;

            case YELLOW:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(164, 128, 8, 255),
                    new java.awt.Color(158, 125, 10, 255),
                    new java.awt.Color(158, 125, 10, 255),
                    new java.awt.Color(130, 96, 25, 255)
                };
                break;

            case RED:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(248, 0, 0, 255),
                    new java.awt.Color(248, 0, 0, 255),
                    new java.awt.Color(248, 0, 0, 255),
                    new java.awt.Color(63, 0, 0, 255)
                };
                break;

            default:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(28, 126, 0, 255),
                    new java.awt.Color(28, 126, 0, 255),
                    new java.awt.Color(28, 126, 0, 255),
                    new java.awt.Color(27, 100, 0, 255)
                };
                break;
        }

        final java.awt.RadialGradientPaint LED_FG_GRADIENT = new java.awt.RadialGradientPaint(LED_FG_CENTER, 0.25f * IMAGE_WIDTH, LED_FG_FRACTIONS, ledFgColors);
        G2.setPaint(LED_FG_GRADIENT);
        G2.fill(LED_FG);

        // Led inner shadow
        final java.awt.geom.Ellipse2D E_LED1_INNERSHADOW = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.2368421107530594, IMAGE_HEIGHT * 0.2368421107530594, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5);
        final java.awt.geom.Point2D E_LED1_INNERSHADOW_CENTER = new java.awt.geom.Point2D.Double( (0.47368421052631576 * IMAGE_WIDTH), (0.47368421052631576 * IMAGE_HEIGHT) );
        final float[] E_LED1_INNERSHADOW_FRACTIONS =
        {
            0.0f,
            0.86f,
            1.0f
        };
        final java.awt.Color[] E_LED1_INNERSHADOW_COLORS =
        {
            new java.awt.Color(0, 0, 0, 0),
            new java.awt.Color(0, 0, 0, 88),
            new java.awt.Color(0, 0, 0, 102)
        };
        final java.awt.RadialGradientPaint E_LED1_INNERSHADOW_GRADIENT = new java.awt.RadialGradientPaint(E_LED1_INNERSHADOW_CENTER, (float)(0.25 * IMAGE_WIDTH), E_LED1_INNERSHADOW_FRACTIONS, E_LED1_INNERSHADOW_COLORS);
        G2.setPaint(E_LED1_INNERSHADOW_GRADIENT);
        G2.fill(E_LED1_INNERSHADOW);

        // Led highlight
        final java.awt.geom.Ellipse2D E_LED1_HL = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.3947368562221527, IMAGE_HEIGHT * 0.31578946113586426, IMAGE_WIDTH * 0.21052631735801697, IMAGE_HEIGHT * 0.1315789520740509);
        final java.awt.geom.Point2D E_LED1_HL_START = new java.awt.geom.Point2D.Double(0, E_LED1_HL.getBounds2D().getMinY() );
        final java.awt.geom.Point2D E_LED1_HL_STOP = new java.awt.geom.Point2D.Double(0, E_LED1_HL.getBounds2D().getMaxY() );
        final float[] E_LED1_HL_FRACTIONS =
        {
            0.0f,
            1.0f
        };
        final java.awt.Color[] E_LED1_HL_COLORS =
        {
            new java.awt.Color(255, 255, 255, 102),
            new java.awt.Color(255, 255, 255, 0)
        };
        final java.awt.LinearGradientPaint E_LED1_HL_GRADIENT = new java.awt.LinearGradientPaint(E_LED1_HL_START, E_LED1_HL_STOP, E_LED1_HL_FRACTIONS, E_LED1_HL_COLORS);
        G2.setPaint(E_LED1_HL_GRADIENT);
        G2.fill(E_LED1_HL);

        G2.dispose();

        return IMAGE;
    }

    private java.awt.image.BufferedImage create_LED_ON_Image(final int WIDTH, final LedColor LED_COLOR)
    {        
        final java.awt.image.BufferedImage IMAGE = GFX_CONF.createCompatibleImage((int) (WIDTH * 0.1775700935), (int) (WIDTH * 0.1775700935), java.awt.Transparency.TRANSLUCENT);
        final java.awt.Graphics2D G2 = IMAGE.createGraphics();
        G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_ALPHA_INTERPOLATION, java.awt.RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_COLOR_RENDERING, java.awt.RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_STROKE_CONTROL, java.awt.RenderingHints.VALUE_STROKE_PURE);
        final int IMAGE_WIDTH = IMAGE.getWidth();
        final int IMAGE_HEIGHT = IMAGE.getHeight();

        // Led background
        final java.awt.geom.Ellipse2D E_LED1_BG = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.21052631735801697, IMAGE_HEIGHT * 0.21052631735801697, IMAGE_WIDTH * 0.5526316165924072, IMAGE_HEIGHT * 0.5526316165924072);
        final java.awt.geom.Point2D E_LED1_BG_START = new java.awt.geom.Point2D.Double(0, E_LED1_BG.getBounds2D().getMinY() );
        final java.awt.geom.Point2D E_LED1_BG_STOP = new java.awt.geom.Point2D.Double(0, E_LED1_BG.getBounds2D().getMaxY() );
        final float[] E_LED1_BG_FRACTIONS =
        {
            0.0f,
            1.0f
        };
        final java.awt.Color[] E_LED1_BG_COLORS =
        {
            new java.awt.Color(0, 0, 0, 229),
            new java.awt.Color(153, 153, 153, 255)
        };
        final java.awt.LinearGradientPaint E_LED1_BG_GRADIENT = new java.awt.LinearGradientPaint(E_LED1_BG_START, E_LED1_BG_STOP, E_LED1_BG_FRACTIONS, E_LED1_BG_COLORS);
        G2.setPaint(E_LED1_BG_GRADIENT);
        G2.fill(E_LED1_BG);

        // Led glow
        final java.awt.geom.Ellipse2D LED_GLOW = new java.awt.geom.Ellipse2D.Double(0.0, 0.0, IMAGE_WIDTH, IMAGE_HEIGHT);
        final java.awt.geom.Point2D LED_GLOW_CENTER = new java.awt.geom.Point2D.Double(LED_GLOW.getCenterX(), LED_GLOW.getCenterY());
        final float[] LED_GLOW_FRACTIONS =
        {
            0.0f,
            0.57f,
            0.71f,
            0.72f,
            0.85f,
            0.93f,
            0.9301f,
            0.99f
        };
        java.awt.Color[] ledGlowColors;

        switch(LED_COLOR)
        {
            case GREEN:
                ledGlowColors = new java.awt.Color[]
                {
                    new java.awt.Color(165, 255, 0, 255),
                    new java.awt.Color(165, 255, 0, 101),
                    new java.awt.Color(165, 255, 0, 63),
                    new java.awt.Color(165, 255, 0, 62),
                    new java.awt.Color(165, 255, 0, 31),
                    new java.awt.Color(165, 255, 0, 13),
                    new java.awt.Color(165, 255, 0, 12),
                    new java.awt.Color(165, 255, 0, 0)
                };
                break;

            case YELLOW:
                ledGlowColors = new java.awt.Color[]
                {
                    new java.awt.Color(255, 102, 0, 255),
                    new java.awt.Color(255, 102, 0, 101),
                    new java.awt.Color(255, 102, 0, 63),
                    new java.awt.Color(255, 102, 0, 62),
                    new java.awt.Color(255, 102, 0, 31),
                    new java.awt.Color(255, 102, 0, 13),
                    new java.awt.Color(255, 102, 0, 12),
                    new java.awt.Color(255, 102, 0, 0)
                };
                break;

            case RED:
                ledGlowColors = new java.awt.Color[]
                {
                    new java.awt.Color(255, 0, 0, 255),
                    new java.awt.Color(255, 0, 0, 101),
                    new java.awt.Color(255, 0, 0, 63),
                    new java.awt.Color(255, 0, 0, 62),
                    new java.awt.Color(255, 0, 0, 31),
                    new java.awt.Color(255, 0, 0, 13),
                    new java.awt.Color(255, 0, 0, 12),
                    new java.awt.Color(255, 0, 0, 0)
                };
                break;

            default:
                ledGlowColors = new java.awt.Color[]
                {
                    new java.awt.Color(165, 255, 0, 255),
                    new java.awt.Color(165, 255, 0, 101),
                    new java.awt.Color(165, 255, 0, 63),
                    new java.awt.Color(165, 255, 0, 62),
                    new java.awt.Color(165, 255, 0, 31),
                    new java.awt.Color(165, 255, 0, 13),
                    new java.awt.Color(165, 255, 0, 12),
                    new java.awt.Color(165, 255, 0, 0)
                };
                break;
        }
        final java.awt.RadialGradientPaint LED_GLOW_GRADIENT = new java.awt.RadialGradientPaint(LED_GLOW_CENTER, 0.5f * IMAGE_WIDTH, LED_GLOW_FRACTIONS, ledGlowColors);
        G2.setPaint(LED_GLOW_GRADIENT);
        G2.fill(LED_GLOW);

        // Led foreground
        final java.awt.geom.Ellipse2D LED_FG = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.2368421107530594, IMAGE_HEIGHT * 0.2368421107530594, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5);
        final java.awt.geom.Point2D LED_FG_CENTER = new java.awt.geom.Point2D.Double(LED_FG.getCenterX(), LED_FG.getCenterY());
        final float[] LED_FG_FRACTIONS =
        {
            0.0f,
            0.14f,
            0.15f,
            1.0f
        };
        java.awt.Color[] ledFgColors;

        switch(LED_COLOR)
        {
            case GREEN:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(154, 255, 137, 255),
                    new java.awt.Color(154, 255, 137, 255),
                    new java.awt.Color(154, 255, 137, 255),
                    new java.awt.Color(89, 255, 42, 255)
                };
                break;

            case YELLOW:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(251, 255, 140, 255),
                    new java.awt.Color(251, 255, 140, 255),
                    new java.awt.Color(251, 255, 140, 255),
                    new java.awt.Color(250, 249, 60, 255)
                };
                break;

            case RED:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(252, 53, 55, 255),
                    new java.awt.Color(252, 53, 55, 255),
                    new java.awt.Color(252, 53, 55, 255),
                    new java.awt.Color(255, 0, 0, 255)
                };
                break;

            default:
                ledFgColors = new java.awt.Color[]
                {
                    new java.awt.Color(154, 255, 137, 255),
                    new java.awt.Color(154, 255, 137, 255),
                    new java.awt.Color(154, 255, 137, 255),
                    new java.awt.Color(89, 255, 42, 255)
                };
                break;
        }
        
        final java.awt.RadialGradientPaint LED_FG_GRADIENT = new java.awt.RadialGradientPaint(LED_FG_CENTER, 0.25f * IMAGE_WIDTH, LED_FG_FRACTIONS, ledFgColors);
        G2.setPaint(LED_FG_GRADIENT);
        G2.fill(LED_FG);

        // Led inner shadow
        final java.awt.geom.Ellipse2D E_LED1_INNERSHADOW = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.2368421107530594, IMAGE_HEIGHT * 0.2368421107530594, IMAGE_WIDTH * 0.5, IMAGE_HEIGHT * 0.5);
        final java.awt.geom.Point2D E_LED1_INNERSHADOW_CENTER = new java.awt.geom.Point2D.Double( (0.47368421052631576 * IMAGE_WIDTH), (0.47368421052631576 * IMAGE_HEIGHT) );
        final float[] E_LED1_INNERSHADOW_FRACTIONS =
        {
            0.0f,
            0.86f,
            1.0f
        };
        final java.awt.Color[] E_LED1_INNERSHADOW_COLORS =
        {
            new java.awt.Color(0, 0, 0, 0),
            new java.awt.Color(0, 0, 0, 88),
            new java.awt.Color(0, 0, 0, 102)
        };
        final java.awt.RadialGradientPaint E_LED1_INNERSHADOW_GRADIENT = new java.awt.RadialGradientPaint(E_LED1_INNERSHADOW_CENTER, (float)(0.25 * IMAGE_WIDTH), E_LED1_INNERSHADOW_FRACTIONS, E_LED1_INNERSHADOW_COLORS);
        G2.setPaint(E_LED1_INNERSHADOW_GRADIENT);
        G2.fill(E_LED1_INNERSHADOW);

        // Led highlight
        final java.awt.geom.Ellipse2D E_LED1_HL = new java.awt.geom.Ellipse2D.Double(IMAGE_WIDTH * 0.3947368562221527, IMAGE_HEIGHT * 0.31578946113586426, IMAGE_WIDTH * 0.21052631735801697, IMAGE_HEIGHT * 0.1315789520740509);
        final java.awt.geom.Point2D E_LED1_HL_START = new java.awt.geom.Point2D.Double(0, E_LED1_HL.getBounds2D().getMinY() );
        final java.awt.geom.Point2D E_LED1_HL_STOP = new java.awt.geom.Point2D.Double(0, E_LED1_HL.getBounds2D().getMaxY() );
        final float[] E_LED1_HL_FRACTIONS =
        {
            0.0f,
            1.0f
        };
        final java.awt.Color[] E_LED1_HL_COLORS =
        {
            new java.awt.Color(255, 255, 255, 102),
            new java.awt.Color(255, 255, 255, 0)
        };
        final java.awt.LinearGradientPaint E_LED1_HL_GRADIENT = new java.awt.LinearGradientPaint(E_LED1_HL_START, E_LED1_HL_STOP, E_LED1_HL_FRACTIONS, E_LED1_HL_COLORS);
        G2.setPaint(E_LED1_HL_GRADIENT);
        G2.fill(E_LED1_HL);

        G2.dispose();

        return IMAGE;
    }

    @Override
    public String toString()
    {
        return "DigitalRadial";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy