question: private static void drawRootGuideline ( ViewTransform transform , Graphics2D g , ConstraintWidgetContainer root , Guideline guideline , boolean isSelected ) { Graphics2D g2 = ( Graphics2D ) g . create ( ) ; g2 . setStroke ( SnapDraw . sThinDashedStroke ) ; int l = transform . getSwingX ( root . getDrawX ( ) ) ; int t = transform . getSwingY ( root . getDrawY ( ) ) ; int r = transform . getSwingX ( root . getDrawX ( ) + root . getWidth ( ) ) ; int b = transform . getSwingY ( root . getDrawY ( ) + root . getHeight ( ) ) ; g . setFont ( sFont ) ; if ( guideline . getOrientation ( ) == Guideline . VERTICAL ) { int x = transform . getSwingX ( guideline . getDrawX ( ) ) ; g2 . drawLine ( x , t , x , b ) ; int offset = 2 ; int circleSize = GUIDDELINE_ICON_SIZE / 2 + 1 ; Shape circle = new Ellipse2D . Float ( x - circleSize , t - 2 * circleSize - offset , 2 * circleSize , 2 * circleSize ) ; g . fill ( circle ) ; int relative = guideline . getRelativeBehaviour ( ) ; if ( relative == Guideline . RELATIVE_PERCENT ) { int iconWidth = sGuidelinePercent . getWidth ( null ) ; int iconHeight = sGuidelinePercent . getHeight ( null ) ; g . drawImage ( sGuidelinePercent , x - GUIDDELINE_ICON_SIZE / 2 , t - GUIDDELINE_ICON_SIZE - 3 , x + GUIDDELINE_ICON_SIZE / 2 , t - 3 , 0 , 0 , iconWidth , iconHeight , null ) ; if ( isSelected ) { int percent = ( guideline . getX ( ) * 100 ) / root . getWidth ( ) ; ConnectionDraw . drawCircledText ( g , sFont , String . valueOf ( percent ) , x , t + 20 ) ; } } else if ( relative == Guideline . RELATIVE_BEGIN ) { int iconWidth = sGuidelineArrowLeft . getWidth ( null ) ; int iconHeight = sGuidelineArrowLeft . getHeight ( null ) ; int ty = t - ConnectionDraw . ARROW_SIDE - offset / 2 ; g . drawImage ( sGuidelineArrowLeft , x - GUIDDELINE_ICON_SIZE / 2 , t - GUIDDELINE_ICON_SIZE - 3 , x + GUIDDELINE_ICON_SIZE / 2 , t - 3 , 0 , 0 , iconWidth , iconHeight , null ) ; if ( isSelected ) { ConnectionDraw . drawHorizontalMarginIndicator ( g , String . valueOf ( guideline . getX ( ) ) , l , x , ty + 20 ) ; } } else if ( relative == Guideline . RELATIVE_END ) { int iconWidth = sGuidelineArrowRight . getWidth ( null ) ; int iconHeight = sGuidelineArrowRight . getHeight ( null ) ; int ty = t - ConnectionDraw . ARROW_SIDE - offset / 2 ; g . drawImage ( sGuidelineArrowRight , x - GUIDDELINE_ICON_SIZE / 2 + 1 , t - GUIDDELINE_ICON_SIZE - 3 , x + GUIDDELINE_ICON_SIZE / 2 , t - 3 , 0 , 0 , iconWidth , iconHeight , null ) ; if ( isSelected ) { ConnectionDraw . drawHorizontalMarginIndicator ( g , String . valueOf ( root . getWidth ( ) - guideline . getX ( ) ) , x , r , ty + 20 ) ; } } } else { int y = transform . getSwingY ( guideline . getDrawY ( ) ) ; g2 . drawLine ( l , y , r , y ) ; int offset = 2 ; int circleSize = GUIDDELINE_ICON_SIZE / 2 + 1 ; Shape circle = new Ellipse2D . Float ( l - 2 * circleSize - offset , y - circleSize , 2 * circleSize , 2 * circleSize ) ; g . fill ( circle ) ; int relative = guideline . getRelativeBehaviour ( ) ; if ( relative == Guideline . RELATIVE_PERCENT ) { int iconWidth = sGuidelinePercent . getWidth ( null ) ; int iconHeight = sGuidelinePercent . getHeight ( null ) ; g . drawImage ( sGuidelinePercent , l - GUIDDELINE_ICON_SIZE - 3 , y - GUIDDELINE_ICON_SIZE / 2 , l - 3 , y + GUIDDELINE_ICON_SIZE / 2 , 0 , 0 , iconWidth , iconHeight , null ) ; if ( isSelected ) { int percent = ( guideline . getY ( ) * 100 ) / root . getHeight ( ) ; ConnectionDraw . drawCircledText ( g , sFont , String . valueOf ( percent ) , l + 20 , y ) ; } } else if ( relative == Guideline . RELATIVE_BEGIN ) { int iconWidth = sGuidelineArrowUp . getWidth ( null ) ; int iconHeight = sGuidelineArrowUp . getHeight ( null ) ; g . drawImage ( sGuidelineArrowUp , l - GUIDDELINE_ICON_SIZE - 3 , y - GUIDDELINE_ICON_SIZE / 2 , l - 3 , y + GUIDDELINE_ICON_SIZE / 2 , 0 , 0 , iconWidth , iconHeight , null ) ; if ( isSelected ) { ConnectionDraw . drawVerticalMarginIndicator ( g , String . valueOf ( guideline . getY ( ) ) , l + 20 , t , y ) ; } } else if ( relative == Guideline . RELATIVE_END ) { int iconWidth = sGuidelineArrowDown . getWidth ( null ) ; int iconHeight = sGuidelineArrowDown . getHeight ( null ) ; Polygon arrow = ConnectionDraw . getBottomArrow ( ) ; g . drawImage ( sGuidelineArrowDown , l - GUIDDELINE_ICON_SIZE - 3 , y - GUIDDELINE_ICON_SIZE / 2 + 1 , l - 3 , y + GUIDDELINE_ICON_SIZE / 2 , 0 , 0 , iconWidth , iconHeight , null ) ; if ( isSelected ) { ConnectionDraw . drawVerticalMarginIndicator ( g , String . valueOf ( root . getHeight ( ) - guideline . getY ( ) ) , l + 20 , y , b ) ; } } } g2 . dispose ( ) ; }
target:  Draw the guideline of a root ConstraintLayout