question: protected void drawValueLabel ( DrawingContext context , Slice slice , double radius , Row row , int rowIndex ) { Comparable < ? > value = slice . end - slice . start ; Format format = getValueFormat ( ) ; if ( ( format == null ) && ( value instanceof Number ) ) { format = NumberFormat . getInstance ( ) ; } String text = ( format != null ) ? format . format ( value ) : value . toString ( ) ; ColorMapper colors = getValueColor ( ) ; Paint paint = colors . get ( rowIndex ) ; Font font = getValueFont ( ) ; double fontSize = font . getSize2D ( ) ; Location location = getValueLocation ( ) ; double alignX = getValueAlignmentX ( ) ; double alignY = getValueAlignmentY ( ) ; double rotation = getValueRotation ( ) ; double distance = getValueDistance ( ) ; if ( MathUtils . isCalculatable ( distance ) ) { distance *= fontSize ; } else { distance = 0.0 ; } double radiusRelOuter = getOuterRadius ( ) ; double radiusRelInner = getInnerRadius ( ) ; double radiusOuter = radius * radiusRelOuter ; double radiusInner = radius * radiusRelInner ; double distanceV = distance ; double labelPosV ; if ( location == Location . NORTH ) { labelPosV = radiusOuter + distanceV ; } else if ( location == Location . SOUTH ) { labelPosV = Math . max ( radiusInner - distanceV , 0 ) ; } else { double sliceHeight = radiusOuter - radiusInner ; if ( 2.0 * distance >= sliceHeight ) { alignY = 0.5 ; distanceV = 0.0 ; } labelPosV = radiusInner + distanceV + alignY * ( sliceHeight - 2.0 * distanceV ) ; } double sum = plot . getSum ( row . getSource ( ) ) ; if ( sum == 0.0 ) { return ; } double sliceStartRel = slice . start / sum ; double sliceEndRel = slice . end / sum ; double circumference = 2.0 * labelPosV * Math . PI ; double distanceRelH = distance / circumference ; double sliceWidthRel = sliceEndRel - sliceStartRel ; if ( 2.0 * distanceRelH >= sliceWidthRel ) { alignX = 0.5 ; distanceRelH = 0.0 ; } double labelPosRelH = sliceStartRel + distanceRelH + alignX * ( sliceWidthRel - 2.0 * distanceRelH ) ; double start = plot . getStart ( ) ; double angleStart = Math . toRadians ( - start ) ; double direction = 1.0 ; if ( ! plot . isClockwise ( ) ) { direction = - 1.0 ; } double angle = angleStart + direction * labelPosRelH * 2.0 * Math . PI ; double dirX = Math . cos ( angle ) ; double dirY = Math . sin ( angle ) ; Label label = new Label ( text ) ; label . setAlignmentX ( 1.0 - 0.5 * dirX - 0.5 ) ; label . setAlignmentY ( 0.5 * dirY + 0.5 ) ; label . setRotation ( rotation ) ; label . setColor ( paint ) ; label . setFont ( font ) ; Dimension2D sizeLabel = label . getPreferredSize ( ) ; double anchorX = 0.5 ; double anchorY = 0.5 ; if ( location == Location . NORTH || location == Location . SOUTH ) { anchorX = dirX * sizeLabel . getWidth ( ) / 2.0 ; anchorY = dirY * sizeLabel . getHeight ( ) / 2.0 ; if ( location == Location . SOUTH ) { anchorX = - anchorX ; anchorY = - anchorY ; } } double x = labelPosV * dirX + anchorX - sizeLabel . getWidth ( ) / 2.0 ; double y = labelPosV * dirY + anchorY - sizeLabel . getHeight ( ) / 2.0 ; double w = sizeLabel . getWidth ( ) ; double h = sizeLabel . getHeight ( ) ; label . setBounds ( x , y , w , h ) ; label . draw ( context ) ; }
target:  Draws the specified value label for the specified shape.