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

eu.hansolo.steelseries.gauges.Radial 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;


/**
 *
 * @author Gerrit Grunwald 
 */
public class Radial extends AbstractRadial
{                
    private int tickLabelPeriod; // Draw value at every nth tickmark      
    private java.awt.image.BufferedImage frameImage;
    private java.awt.image.BufferedImage backgroundImage;
    private java.awt.image.BufferedImage postsImage;
    private java.awt.image.BufferedImage trackImage;
    private java.awt.image.BufferedImage tickmarksImage;
    private java.awt.image.BufferedImage titleImage;
    private java.awt.image.BufferedImage lcdImage;
    private java.awt.image.BufferedImage pointerImage;
    private java.awt.image.BufferedImage pointerShadowImage;
    private java.awt.image.BufferedImage foregroundImage;
    private java.awt.image.BufferedImage thresholdImage;
    private java.awt.image.BufferedImage minMeasuredImage;
    private java.awt.image.BufferedImage maxMeasuredImage;
    private java.awt.image.BufferedImage disabledImage;          
    private double angle;
    private final java.awt.geom.Point2D CENTER = new java.awt.geom.Point2D.Double();
    private final java.awt.geom.Point2D LCD_POSITION = new java.awt.geom.Point2D.Double();
    private boolean section3DEffectVisible;
    private java.awt.RadialGradientPaint section3DEffect;
    private final java.awt.geom.Point2D TRACK_OFFSET = new java.awt.geom.Point2D.Double();
    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 double unitStringWidth;
    private java.awt.font.TextLayout valueLayout;
    private final java.awt.geom.Rectangle2D VALUE_BOUNDARY = new java.awt.geom.Rectangle2D.Double();    
    

        
    public Radial()
    {
        super();                  
        setLcdVisible(true);
        switch(getGaugeType())
        {
            case TYPE1:                    
                tickLabelPeriod = 20;
                break;
                
            case TYPE2:                
                tickLabelPeriod = 10; 
                break;
                
            case TYPE3:                    
                tickLabelPeriod = 10; 
                break;
                
            case TYPE4:                
                tickLabelPeriod = 10;
                break;
                
            default:                
                tickLabelPeriod = 10;
                break;
        }                                         
        angle = 0;              
        section3DEffectVisible = false;                
        init(getInnerBounds().width, getInnerBounds().height);
    }

    @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);

        if (postsImage != null)
        {
            postsImage.flush();
        }
        switch(getGaugeType())
        {
            case TYPE1:
                postsImage = create_POSTS_Image(WIDTH, eu.hansolo.steelseries.tools.PostPosition.CENTER, eu.hansolo.steelseries.tools.PostPosition.MAX_CENTER_TOP, eu.hansolo.steelseries.tools.PostPosition.MIN_LEFT);                    
                break;

            case TYPE2:
                postsImage = create_POSTS_Image(WIDTH, eu.hansolo.steelseries.tools.PostPosition.CENTER, eu.hansolo.steelseries.tools.PostPosition.MIN_LEFT, eu.hansolo.steelseries.tools.PostPosition.MAX_RIGHT);
                break;

            case TYPE3:
                postsImage = create_POSTS_Image(WIDTH, eu.hansolo.steelseries.tools.PostPosition.CENTER, eu.hansolo.steelseries.tools.PostPosition.MAX_CENTER_BOTTOM, eu.hansolo.steelseries.tools.PostPosition.MAX_RIGHT);
                break;

            case TYPE4:
                postsImage = create_POSTS_Image(WIDTH, eu.hansolo.steelseries.tools.PostPosition.CENTER, eu.hansolo.steelseries.tools.PostPosition.MIN_BOTTOM, eu.hansolo.steelseries.tools.PostPosition.MAX_BOTTOM);
                break;

            default:
                postsImage = create_POSTS_Image(WIDTH, eu.hansolo.steelseries.tools.PostPosition.CENTER, eu.hansolo.steelseries.tools.PostPosition.MIN_BOTTOM, eu.hansolo.steelseries.tools.PostPosition.MAX_BOTTOM);
                break;
        }                            

        if (trackImage != null)
        {
            trackImage.flush();
        }                                        
        TRACK_OFFSET.setLocation(0, 0);
        CENTER.setLocation(getGaugeBounds().getCenterX(), getGaugeBounds().getCenterX());                    
        trackImage = create_TRACK_Image(WIDTH, getFreeAreaAngle(), getTickmarkOffset(), getMinValue(), getMaxValue(), getAngleStep(), getTrackStart(), getTrackSection(), getTrackStop(), getTrackStartColor(), getTrackSectionColor(), getTrackStopColor(), 0.38f, CENTER, getTickmarkDirection(), TRACK_OFFSET);

        if (tickmarksImage != null)
        {
            tickmarksImage.flush();
        }
        tickmarksImage = create_TICKMARKS_Image(WIDTH, getFreeAreaAngle(), getTickmarkOffset(), getMinValue(), getMaxValue(), getAngleStep(), tickLabelPeriod, getScaleDividerPower(), isDrawTicks(), isDrawTickLabels(), getTickmarkSections());                   

        if (titleImage != null)
        {
            titleImage.flush();
        }
        titleImage = create_TITLE_Image(WIDTH, getTitle(), getUnitString());

        if (lcdImage != null)
        {
            lcdImage.flush();
        }
        switch(getGaugeType())
        {
            case TYPE1:
                lcdImage = create_LCD_Image((int) (WIDTH * 0.55), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
                break;

            case TYPE2:
                lcdImage = create_LCD_Image((int) (WIDTH * 0.55), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
                break;

            case TYPE3:
                lcdImage = create_LCD_Image((int) (WIDTH * 0.4), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
                break;

            case TYPE4:
                lcdImage = create_LCD_Image((int) (WIDTH * 0.4), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
                break;

            default:
                lcdImage = create_LCD_Image((int) (WIDTH * 0.4), (int) (WIDTH * 0.15), getLcdColor(), getCustomLcdBackground());
                break;
        }            
        LCD_POSITION.setLocation(((getGaugeBounds().width - lcdImage.getWidth()) / 2.0), (getGaugeBounds().height * 0.55));

        if (pointerImage != null)
        {
            pointerImage.flush();
        }
        pointerImage = create_POINTER_Image(WIDTH, getPointerType());

        if (pointerShadowImage != null)
        {
            pointerShadowImage.flush();
        }
        pointerShadowImage = create_POINTER_SHADOW_Image(WIDTH, getPointerType());

        if (foregroundImage != null)
        {
            foregroundImage.flush();
        }
        foregroundImage = create_FOREGROUND_Image(WIDTH, false, getForegroundType());

        if (thresholdImage != null)
        {
            thresholdImage.flush();
        }
        thresholdImage = create_THRESHOLD_Image(WIDTH);

        if (minMeasuredImage != null)
        {
            minMeasuredImage.flush();
        }
        minMeasuredImage = create_MEASURED_VALUE_Image(WIDTH, new java.awt.Color(0, 23, 252, 255));

        if (maxMeasuredImage != null)
        {
            maxMeasuredImage.flush();
        }
        maxMeasuredImage = create_MEASURED_VALUE_Image(WIDTH, new java.awt.Color(252, 29, 0, 255));


        if (disabledImage != null)
        {
            disabledImage.flush();
        }
        disabledImage = create_DISABLED_Image(WIDTH);                        
            
        // Create areas if not empty
        if (!getAreas().isEmpty())
        {
            createAreas();
        }
        // Create sections if not empty
        if (!getSections().isEmpty())
        {
            createSections();
        }
        // Create the sections 3d effect gradient overlay
        if (section3DEffectVisible)
        {
            section3DEffect = create_3D_RADIAL_GRADIENT(WIDTH, 0.38f);
        }
        
        setCurrentLedImage(getLedImageOff());
        
        return this;
    }

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

        G2.setRenderingHint(java.awt.RenderingHints.KEY_ANTIALIASING, java.awt.RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_RENDERING, java.awt.RenderingHints.VALUE_RENDER_QUALITY);
        //G2.setRenderingHint(java.awt.RenderingHints.KEY_DITHERING, java.awt.RenderingHints.VALUE_DITHER_ENABLE);
        //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_FRACTIONALMETRICS, java.awt.RenderingHints.VALUE_FRACTIONALMETRICS_ON);
        G2.setRenderingHint(java.awt.RenderingHints.KEY_TEXT_ANTIALIASING, java.awt.RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        G2.translate(getInnerBounds().x, getInnerBounds().y);        
        final java.awt.geom.AffineTransform OLD_TRANSFORM = G2.getTransform();

        // Draw the frame
        if (isFrameVisible())
        {
            G2.drawImage(frameImage, 0, 0, null);
        }

        // Draw the background        
        if (isBackgroundVisible())
        {
            G2.drawImage(backgroundImage, 0, 0, null);
        }
                
        // Draw the areas
        if (isAreasVisible())
        {
            for (eu.hansolo.steelseries.tools.Section area : getAreas())
            {
                G2.setColor(area.getColor());
                G2.fill(area.getFilledArea());
            }
        }
        
        // Draw the sections
        if (isSectionsVisible())
        {
            for (eu.hansolo.steelseries.tools.Section section : getSections())
            {
                G2.setColor(section.getColor());
                G2.fill(section.getSectionArea());
                if (section3DEffectVisible)
                {
                    G2.setPaint(section3DEffect);
                    G2.fill(section.getSectionArea());
                }
            }
        }

        // Draw the track
        if (isTrackVisible())
        {
            G2.drawImage(trackImage, 0, 0, null);
        }
        
        // Draw the tickmarks
        G2.drawImage(tickmarksImage, 0, 0, null);

        // Draw threshold indicator
        if (isThresholdVisible())
        {
            G2.rotate(getRotationOffset() + (getThreshold() - getMinValue()) * getAngleStep(), CENTER.getX(), CENTER.getY());            
            G2.drawImage(thresholdImage, (int) (getGaugeBounds().width * 0.480369999), (int) (getGaugeBounds().height * 0.13), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw min measured value indicator
        if (isMinMeasuredValueVisible())
        {
            G2.rotate(getRotationOffset() + (getMinMeasuredValue() - getMinValue()) * getAngleStep(), CENTER.getX(), CENTER.getY());
            G2.drawImage(minMeasuredImage, (int) (getGaugeBounds().width * 0.4865), (int) (getGaugeBounds().height * 0.105), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw max measured value indicator
        if (isMaxMeasuredValueVisible())
        {
            G2.rotate(getRotationOffset() + (getMaxMeasuredValue() - getMinValue()) * getAngleStep(), CENTER.getX(), CENTER.getY());
            G2.drawImage(maxMeasuredImage, (int) (getGaugeBounds().width * 0.4865), (int) (getGaugeBounds().height * 0.105), null);
            G2.setTransform(OLD_TRANSFORM);
        }

        // Draw title and unit
        G2.drawImage(titleImage, 0, 0, null);

        // Draw LED if enabled
        if (isLedVisible())
        {
            G2.drawImage(getCurrentLedImage(), (int) (getGaugeBounds().width * getLedPositionX()), (int) (getGaugeBounds().height * getLedPositionY()), null);
        }

        // Draw LCD display
        if (isLcdVisible())
        {
            //G2.drawImage(lcdImage, (int) ((getGaugeBounds().width - lcdImage.getWidth()) / 2.0), (int) (getGaugeBounds().height * 0.55), null);
            G2.drawImage(lcdImage, (int) (LCD_POSITION.getX()), (int) (LCD_POSITION.getY()), null);
            
            if (getLcdColor() == eu.hansolo.steelseries.tools.LcdColor.CUSTOM)
            {
                G2.setColor(getCustomLcdForeground());
            }
            else
            {
                G2.setColor(getLcdColor().TEXT_COLOR);
            }
            G2.setFont(getLcdUnitFont());                        
            if (isLcdUnitStringVisible())
            {
                unitLayout = new java.awt.font.TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
                UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
                G2.drawString(getLcdUnitString(), (int) (LCD_POSITION.getX() + (lcdImage.getWidth() - UNIT_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.03), (int) (LCD_POSITION.getY() + lcdImage.getHeight() * 0.76f));
                unitStringWidth = UNIT_BOUNDARY.getWidth();
            }
            else
            {
                unitStringWidth = 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) (LCD_POSITION.getX() + (lcdImage.getWidth() - unitStringWidth - VALUE_BOUNDARY.getWidth()) - lcdImage.getWidth() * 0.09), (int) (LCD_POSITION.getY() + lcdImage.getHeight() * 0.76f));
        }
        
        // Draw the pointer
        angle = getRotationOffset() + (getValue() - getMinValue()) * getAngleStep();
        G2.rotate(angle + (Math.cos(Math.toRadians(angle - getRotationOffset() - 91.5))), CENTER.getX(), CENTER.getY());
        G2.drawImage(pointerShadowImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);
        G2.rotate(angle, CENTER.getX(), CENTER.getY());
        G2.drawImage(pointerImage, 0, 0, null);
        G2.setTransform(OLD_TRANSFORM);

        // Draw posts
        G2.drawImage(postsImage, 0, 0, null);
        
        // Draw the foreground        
        if (isForegroundVisible())
        {
            G2.drawImage(foregroundImage, 0, 0, null);
        }
        
        // Draw disabled image if component isEnabled() == false
        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);
                
        if (isValueCoupled())
        {
            setLcdValue(value);            
        }
        repaint(getInnerBounds());                        
    }
        
    public int getTickLabelPeriod()
    {
        return this.tickLabelPeriod;
    }

    public void setTickLabelPeriod(final int TICK_LABEL_PERIOD)
    {
        this.tickLabelPeriod = TICK_LABEL_PERIOD;        
        init(getInnerBounds().width, getInnerBounds().height);
        repaint(getInnerBounds());
    }
        
    /**
     * Returns true if the 3d effect gradient overlay for the sections is visible
     * @return true if the 3d effect gradient overlay for the sections is visible
     */
    public boolean isSection3DEffectVisible()
    {
        return this.section3DEffectVisible;
    }
    
    /**
     * Defines the visibility of the 3d effect gradient overlay for the sections
     * @param SECTION_3D_EFFECT_VISIBLE 
     */
    public void setSection3DEffectVisible(final boolean SECTION_3D_EFFECT_VISIBLE)
    {
        this.section3DEffectVisible = SECTION_3D_EFFECT_VISIBLE;
        init(getInnerBounds().width, getInnerBounds().height);
        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 void createAreas()
    {
        final double ORIGIN_CORRECTION;
        final double ANGLE_STEP;

        if (backgroundImage != null)
        {
            switch(getGaugeType())
            {
                case TYPE1:
                    ORIGIN_CORRECTION = 180;
                    ANGLE_STEP = 90 / (getMaxValue() - getMinValue());
                    break;

                case TYPE2:
                    ORIGIN_CORRECTION = 180;
                    ANGLE_STEP = 180 / (getMaxValue() - getMinValue());
                    break;

                case TYPE3:
                    ORIGIN_CORRECTION = 270;
                    ANGLE_STEP = 270 / (getMaxValue() - getMinValue());
                    break;

                case TYPE4:
                    ORIGIN_CORRECTION = 240;
                    ANGLE_STEP = 300 / (getMaxValue() - getMinValue());
                    break;

                default:
                    ORIGIN_CORRECTION = 240;
                    ANGLE_STEP = 300 / (getMaxValue() - getMinValue());
                    break;
            }

            if (backgroundImage != null && !getAreas().isEmpty())
            {            
                final double RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
                final double FREE_AREA = backgroundImage.getWidth() / 2.0 - RADIUS;
                final java.awt.geom.Rectangle2D AREA_FRAME = new java.awt.geom.Rectangle2D.Double(backgroundImage.getMinX() + FREE_AREA, backgroundImage.getMinY() + FREE_AREA, 2 * RADIUS, 2 * RADIUS);           
                for (eu.hansolo.steelseries.tools.Section area : getAreas())
                {                
                    area.setFilledArea(new java.awt.geom.Arc2D.Double(AREA_FRAME, ORIGIN_CORRECTION - (area.getStart() * ANGLE_STEP) + (getMinValue() * ANGLE_STEP), -(area.getStop() - area.getStart()) * ANGLE_STEP, java.awt.geom.Arc2D.PIE));                
                }           
            }    
        }
    }
    //
    
    //     
    private void createSections()
    {                                            
        final double ORIGIN_CORRECTION;
        final double ANGLE_STEP;
        final double OUTER_RADIUS;
        final double INNER_RADIUS;
        final double FREE_AREA_OUTER_RADIUS;
        final double FREE_AREA_INNER_RADIUS;
        final java.awt.geom.Ellipse2D INNER;
        
        if (backgroundImage != null)
        {
            switch (getGaugeType())
            {
                case TYPE1:
                    ORIGIN_CORRECTION = 180.0;
                    ANGLE_STEP = 90.0 / (getMaxValue() - getMinValue());
                    OUTER_RADIUS = backgroundImage.getWidth() * 0.38f;
                    INNER_RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
                    FREE_AREA_OUTER_RADIUS = backgroundImage.getWidth() / 2.0 - OUTER_RADIUS;
                    FREE_AREA_INNER_RADIUS = backgroundImage.getWidth() / 2.0 - INNER_RADIUS;
                    INNER = new java.awt.geom.Ellipse2D.Double(backgroundImage.getMinX() + FREE_AREA_INNER_RADIUS, backgroundImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);
                    break;

                case TYPE2:
                    ORIGIN_CORRECTION = 180.0;
                    ANGLE_STEP = 180.0 / (getMaxValue() - getMinValue());
                    OUTER_RADIUS = backgroundImage.getWidth() * 0.38f;
                    INNER_RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
                    FREE_AREA_OUTER_RADIUS = backgroundImage.getWidth() / 2.0 - OUTER_RADIUS;
                    FREE_AREA_INNER_RADIUS = backgroundImage.getWidth() / 2.0 - INNER_RADIUS;
                    INNER = new java.awt.geom.Ellipse2D.Double(backgroundImage.getMinX() + FREE_AREA_INNER_RADIUS, backgroundImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);
                    break;

                case TYPE3:                
                    ORIGIN_CORRECTION = 270.0;
                    ANGLE_STEP = 270.0 / (getMaxValue() - getMinValue());          
                    OUTER_RADIUS = backgroundImage.getWidth() * 0.38f;
                    INNER_RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
                    FREE_AREA_OUTER_RADIUS = backgroundImage.getWidth() / 2.0 - OUTER_RADIUS;
                    FREE_AREA_INNER_RADIUS = backgroundImage.getWidth() / 2.0 - INNER_RADIUS;
                    INNER = new java.awt.geom.Ellipse2D.Double(backgroundImage.getMinX() + FREE_AREA_INNER_RADIUS, backgroundImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);
                    break;

                case TYPE4:
                    ORIGIN_CORRECTION = 240.0;
                    ANGLE_STEP = 300.0 / (getMaxValue() - getMinValue());
                    OUTER_RADIUS = backgroundImage.getWidth() * 0.38f;
                    INNER_RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
                    FREE_AREA_OUTER_RADIUS = backgroundImage.getWidth() / 2.0 - OUTER_RADIUS;
                    FREE_AREA_INNER_RADIUS = backgroundImage.getWidth() / 2.0 - INNER_RADIUS;
                    INNER = new java.awt.geom.Ellipse2D.Double(backgroundImage.getMinX() + FREE_AREA_INNER_RADIUS, backgroundImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);
                    break;

                default:
                    ORIGIN_CORRECTION = 240.0;
                    ANGLE_STEP = 300.0 / (getMaxValue() - getMinValue());
                    OUTER_RADIUS = backgroundImage.getWidth() * 0.38f;
                    INNER_RADIUS = backgroundImage.getWidth() * 0.38f - backgroundImage.getWidth() * 0.04f;
                    FREE_AREA_OUTER_RADIUS = backgroundImage.getWidth() / 2.0 - OUTER_RADIUS;
                    FREE_AREA_INNER_RADIUS = backgroundImage.getWidth() / 2.0 - INNER_RADIUS;
                    INNER = new java.awt.geom.Ellipse2D.Double(backgroundImage.getMinX() + FREE_AREA_INNER_RADIUS, backgroundImage.getMinY() + FREE_AREA_INNER_RADIUS, 2 * INNER_RADIUS, 2 * INNER_RADIUS);
                    break;
            }

            for (eu.hansolo.steelseries.tools.Section section : getSections())
            {                            
                final double ANGLE_START = ORIGIN_CORRECTION - (section.getStart() * ANGLE_STEP) + (getMinValue() * ANGLE_STEP);
                final double ANGLE_EXTEND = -(section.getStop() - section.getStart()) * ANGLE_STEP;                

                final java.awt.geom.Arc2D OUTER_ARC = new java.awt.geom.Arc2D.Double(java.awt.geom.Arc2D.PIE);
                OUTER_ARC.setFrame(backgroundImage.getMinX() + FREE_AREA_OUTER_RADIUS, backgroundImage.getMinY() + FREE_AREA_OUTER_RADIUS, 2 * OUTER_RADIUS, 2 * OUTER_RADIUS);
                OUTER_ARC.setAngleStart(ANGLE_START);
                OUTER_ARC.setAngleExtent(ANGLE_EXTEND);
                final java.awt.geom.Area SECTION = new java.awt.geom.Area(OUTER_ARC);

                SECTION.subtract(new java.awt.geom.Area(INNER));

                section.setSectionArea(SECTION);
            }      
        }
    }
    //     
    
    @Override
    public String toString()
    {
        return "Radial " + getGaugeType();
    }  
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy