protected BufferedImage create_TRACK_Image(final int WIDTH, final int HEIGHT, final double MIN_VALUE,
                                                              final double MAX_VALUE, final double TRACK_START,
                                                              final double TRACK_SECTION, final double TRACK_STOP,
                                                              final Color TRACK_START_COLOR,
                                                              final Color TRACK_SECTION_COLOR,
                                                              final Color TRACK_STOP_COLOR,
                                                              BufferedImage image) {
        if (WIDTH <= 0 || HEIGHT <= 0) {
            return UTIL.createImage(1, 1, Transparency.TRANSLUCENT);
        }

        if (TRACK_STOP > MAX_VALUE) {
            throw new IllegalArgumentException("Please adjust track start and/or track stop values");
        }

        if (image == null) {
            image = UTIL.createImage(WIDTH, HEIGHT, 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();

        final Rectangle2D TRACK;
        final Point2D TRACK_START_POINT;
        final Point2D TRACK_STOP_POINT;

        if (getOrientation() == Orientation.VERTICAL) {
            // Vertical orientation
            TRACK = new Rectangle2D.Double(IMAGE_WIDTH * 0.315, IMAGE_HEIGHT * 0.1276, IMAGE_WIDTH * 0.05, IMAGE_HEIGHT * 0.7280);
            TRACK_START_POINT = new Point2D.Double(0, TRACK.getMaxY());
            TRACK_STOP_POINT = new Point2D.Double(0, TRACK.getMinY());
        } else {
            // Horizontal orientation
            TRACK = new Rectangle2D.Double(IMAGE_WIDTH * 0.139, IMAGE_HEIGHT * 0.6285714285714286, IMAGE_WIDTH * 0.735, IMAGE_HEIGHT * 0.05);
            TRACK_START_POINT = new Point2D.Double(TRACK.getMinX(), 0);
            TRACK_STOP_POINT = new Point2D.Double(TRACK.getMaxX(), 0);
        }

        // Calculate the track start and stop position for the gradient
        final float TRACK_START_POSITION = (float) ((TRACK_START - MIN_VALUE) / (MAX_VALUE - MIN_VALUE));
        final float TRACK_STOP_POSITION = (float) ((TRACK_STOP - MIN_VALUE) / (MAX_VALUE - MIN_VALUE));

        final Color FULLY_TRANSPARENT = new Color(0.0f, 0.0f, 0.0f, 0.0f);

        final float[] TRACK_FRACTIONS;
        final Color[] TRACK_COLORS;

        // Three color gradient from trackStart over trackSection to trackStop
        final float TRACK_SECTION_POSITION = (float) ((TRACK_SECTION - MIN_VALUE) / (MAX_VALUE - MIN_VALUE));

        TRACK_FRACTIONS = new float[]{
            0.0f,
            TRACK_START_POSITION + 0.001f,
            TRACK_START_POSITION + 0.002f,
            TRACK_SECTION_POSITION,
            TRACK_STOP_POSITION - 0.002f,
            TRACK_STOP_POSITION - 0.001f,
            1.0f
        };

        TRACK_COLORS = new Color[]{
            FULLY_TRANSPARENT,
            FULLY_TRANSPARENT,
            TRACK_START_COLOR,
            TRACK_SECTION_COLOR,
            TRACK_STOP_COLOR,
            FULLY_TRANSPARENT,
            FULLY_TRANSPARENT
        };
        Util.INSTANCE.validateGradientPoints(TRACK_START_POINT, TRACK_STOP_POINT);
        final LinearGradientPaint TRACK_GRADIENT = new LinearGradientPaint(TRACK_START_POINT, TRACK_STOP_POINT, TRACK_FRACTIONS, TRACK_COLORS);
        G2.setPaint(TRACK_GRADIENT);
        G2.fill(TRACK);

        G2.dispose();

        return image;
    }
protected BufferedImage create_TRACK_Image ( final int WIDTH , final int HEIGHT , final double MIN_VALUE , final double MAX_VALUE , final double TRACK_START , final double TRACK_SECTION , final double TRACK_STOP , final Color TRACK_START_COLOR , final Color TRACK_SECTION_COLOR , final Color TRACK_STOP_COLOR , BufferedImage image ) { if ( WIDTH <= 0 || HEIGHT <= 0 ) { return UTIL . createImage ( 1 , 1 , Transparency . TRANSLUCENT ) ; } if ( TRACK_STOP > MAX_VALUE ) { throw new IllegalArgumentException ( "Please adjust track start and/or track stop values" ) ; } if ( image == null ) { image = UTIL . createImage ( WIDTH , HEIGHT , 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 ( ) ; final Rectangle2D TRACK ; final Point2D TRACK_START_POINT ; final Point2D TRACK_STOP_POINT ; if ( getOrientation ( ) == Orientation . VERTICAL ) { TRACK = new Rectangle2D . Double ( IMAGE_WIDTH * 0.315 , IMAGE_HEIGHT * 0.1276 , IMAGE_WIDTH * 0.05 , IMAGE_HEIGHT * 0.7280 ) ; TRACK_START_POINT = new Point2D . Double ( 0 , TRACK . getMaxY ( ) ) ; TRACK_STOP_POINT = new Point2D . Double ( 0 , TRACK . getMinY ( ) ) ; } else { TRACK = new Rectangle2D . Double ( IMAGE_WIDTH * 0.139 , IMAGE_HEIGHT * 0.6285714285714286 , IMAGE_WIDTH * 0.735 , IMAGE_HEIGHT * 0.05 ) ; TRACK_START_POINT = new Point2D . Double ( TRACK . getMinX ( ) , 0 ) ; TRACK_STOP_POINT = new Point2D . Double ( TRACK . getMaxX ( ) , 0 ) ; } final float TRACK_START_POSITION = ( float ) ( ( TRACK_START - MIN_VALUE ) / ( MAX_VALUE - MIN_VALUE ) ) ; final float TRACK_STOP_POSITION = ( float ) ( ( TRACK_STOP - MIN_VALUE ) / ( MAX_VALUE - MIN_VALUE ) ) ; final Color FULLY_TRANSPARENT = new Color ( 0.0f , 0.0f , 0.0f , 0.0f ) ; final float [ ] TRACK_FRACTIONS ; final Color [ ] TRACK_COLORS ; final float TRACK_SECTION_POSITION = ( float ) ( ( TRACK_SECTION - MIN_VALUE ) / ( MAX_VALUE - MIN_VALUE ) ) ; TRACK_FRACTIONS = new float [ ] { 0.0f , TRACK_START_POSITION + 0.001f , TRACK_START_POSITION + 0.002f , TRACK_SECTION_POSITION , TRACK_STOP_POSITION - 0.002f , TRACK_STOP_POSITION - 0.001f , 1.0f } ; TRACK_COLORS = new Color [ ] { FULLY_TRANSPARENT , FULLY_TRANSPARENT , TRACK_START_COLOR , TRACK_SECTION_COLOR , TRACK_STOP_COLOR , FULLY_TRANSPARENT , FULLY_TRANSPARENT } ; Util . INSTANCE . validateGradientPoints ( TRACK_START_POINT , TRACK_STOP_POINT ) ; final LinearGradientPaint TRACK_GRADIENT = new LinearGradientPaint ( TRACK_START_POINT , TRACK_STOP_POINT , TRACK_FRACTIONS , TRACK_COLORS ) ; G2 . setPaint ( TRACK_GRADIENT ) ; G2 . fill ( TRACK ) ; G2 . dispose ( ) ; return image ; }
Returns the track image with the given values.
@param WIDTH
@param HEIGHT
@param MIN_VALUE
@param MAX_VALUE
@param TRACK_START
@param TRACK_SECTION
@param TRACK_STOP
@param TRACK_START_COLOR
@param TRACK_SECTION_COLOR
@param TRACK_STOP_COLOR
@param image
@return a buffered image of the track colored with the given values