private void init ( final int WIDTH , final int HEIGHT ) { if ( WIDTH <= 1 || HEIGHT <= 1 ) { return ; } final double CORNER_RADIUS = WIDTH > HEIGHT ? ( HEIGHT * 0.095 ) : ( WIDTH * 0.095 ) ; if ( recreateImages ) { if ( sparkLineBackgroundImage != null ) { sparkLineBackgroundImage . flush ( ) ; } sparkLineBackgroundImage = create_SPARK_LINE_BACKGROUND_Image ( WIDTH , HEIGHT ) ; // set the clip shape CLIP_SHAPE . setRoundRect ( 1 , 1 , WIDTH - 2 , HEIGHT - 2 , CORNER_RADIUS - 1 , CORNER_RADIUS - 1 ) ; if ( startIndicatorImage != null ) { startIndicatorImage . flush ( ) ; } //startIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY); startIndicatorImage = create_START_STOP_INDICATOR_Image ( WIDTH ) ; if ( stopIndicatorImage != null ) { stopIndicatorImage . flush ( ) ; } //stopIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.GRAY); stopIndicatorImage = create_START_STOP_INDICATOR_Image ( WIDTH ) ; if ( loIndicatorImage != null ) { loIndicatorImage . flush ( ) ; } //loIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.BLUE); loIndicatorImage = create_LO_INDICATOR_Image ( WIDTH ) ; if ( hiIndicatorImage != null ) { hiIndicatorImage . flush ( ) ; } //hiIndicatorImage = createIndicatorImage(WIDTH, HEIGHT, ColorDef.RED); hiIndicatorImage = create_HI_INDICATOR_Image ( WIDTH ) ; } recreateImages = false ; disabledShape = new java . awt . geom . RoundRectangle2D . Double ( 0 , 0 , WIDTH , HEIGHT , CORNER_RADIUS , CORNER_RADIUS ) ; // Calculation and creation of sparkline itself pixelResolution = INNER_BOUNDS . getWidth ( ) / ( double ) timeFrame ; //offset = (int)(0.015 * WIDTH) < 4 ? 4 : (int)(0.015 * WIDTH); offset = ( int ) ( 0.06 * WIDTH ) < 8 ? 8 : ( int ) ( 0.06 * WIDTH ) ; baseLineY = INNER_BOUNDS . y + INNER_BOUNDS . height - ( ( 0 - lo ) * ( 1 / scaleY ) + offset ) ; if ( ! DATA_LIST . isEmpty ( ) ) { calculate ( WIDTH , HEIGHT ) ; } if ( sparkLineImage != null ) { sparkLineImage . flush ( ) ; } sparkLineImage = createSparkLineImage ( WIDTH , HEIGHT ) ; }
Initializes the sparkline component with the given width and height