public static Optional<InteractiveSegment> render(final Segment document,final int x,final int y,final int maxWidth,final int maxHeight,final int yOffset,final FontRenderer renderer,final int mouseX,final int mouseY){
  final Minecraft mc=Minecraft.getMinecraft();
  GlStateManager.pushAttrib();
  GL11.glDisable(GL11.GL_ALPHA_TEST);
  GlStateManager.color(1,1,1,1);
  GL11.glClear(GL11.GL_DEPTH_BUFFER_BIT);
  GlStateManager.enableDepth();
  GlStateManager.depthFunc(GL11.GL_LEQUAL);
  GlStateManager.depthMask(true);
  GlStateManager.colorMask(false,false,false,false);
  GlStateManager.pushMatrix();
  GL11.glTranslatef(0,0,500);
  GL11.glBegin(GL11.GL_QUADS);
  GL11.glVertex2f(0,y);
  GL11.glVertex2f(mc.displayWidth,y);
  GL11.glVertex2f(mc.displayWidth,0);
  GL11.glVertex2f(0,0);
  GL11.glVertex2f(0,mc.displayHeight);
  GL11.glVertex2f(mc.displayWidth,mc.displayHeight);
  GL11.glVertex2f(mc.displayWidth,y + maxHeight);
  GL11.glVertex2f(0,y + maxHeight);
  GL11.glEnd();
  GlStateManager.popMatrix();
  GlStateManager.colorMask(true,true,true,true);
  Optional<InteractiveSegment> hovered=Optional.empty();
  int indent=0;
  int currentY=y - yOffset;
  final int minY=y - lineHeight(renderer);
  final int maxY=y + maxHeight + lineHeight(renderer);
  Segment segment=document;
  while (segment != null) {
    final int segmentHeight=segment.nextY(indent,maxWidth,renderer);
    if (currentY + segmentHeight >= minY && currentY <= maxY) {
      final Optional<InteractiveSegment> result=segment.render(x,currentY,indent,maxWidth,renderer,mouseX,mouseY);
      if (!hovered.isPresent()) {
        hovered=result;
      }
    }
    currentY+=segmentHeight;
    indent=segment.nextX(indent,maxWidth,renderer);
    segment=segment.next();
  }
  if (mouseX < x || mouseX > x + maxWidth || mouseY < y || mouseY > y + maxHeight) {
    hovered=Optional.empty();
  }
  hovered.ifPresent(null);
  GlStateManager.popAttrib();
  GlStateManager.bindTexture(0);
  return hovered;
}

public static Optional < InteractiveSegment > render ( final Segment document , final int x , final int y , final int maxWidth , final int maxHeight , final int yOffset , final FontRenderer renderer , final int mouseX , final int mouseY ) { final Minecraft mc = Minecraft . getMinecraft ( ) ; GlStateManager . pushAttrib ( ) ; GL11 . glDisable ( GL11 . GL_ALPHA_TEST ) ; GlStateManager . color ( 1 , 1 , 1 , 1 ) ; GL11 . glClear ( GL11 . GL_DEPTH_BUFFER_BIT ) ; GlStateManager . enableDepth ( ) ; GlStateManager . depthFunc ( GL11 . GL_LEQUAL ) ; GlStateManager . depthMask ( true ) ; GlStateManager . colorMask ( false , false , false , false ) ; GlStateManager . pushMatrix ( ) ; GL11 . glTranslatef ( 0 , 0 , 500 ) ; GL11 . glBegin ( GL11 . GL_QUADS ) ; GL11 . glVertex2f ( 0 , y ) ; GL11 . glVertex2f ( mc . displayWidth , y ) ; GL11 . glVertex2f ( mc . displayWidth , 0 ) ; GL11 . glVertex2f ( 0 , 0 ) ; GL11 . glVertex2f ( 0 , mc . displayHeight ) ; GL11 . glVertex2f ( mc . displayWidth , mc . displayHeight ) ; GL11 . glVertex2f ( mc . displayWidth , y + maxHeight ) ; GL11 . glVertex2f ( 0 , y + maxHeight ) ; GL11 . glEnd ( ) ; GlStateManager . popMatrix ( ) ; GlStateManager . colorMask ( true , true , true , true ) ; Optional < InteractiveSegment > hovered = Optional . empty ( ) ; int indent = 0 ; int currentY = y - yOffset ; final int minY = y - lineHeight ( renderer ) ; final int maxY = y + maxHeight + lineHeight ( renderer ) ; Segment segment = document ; while ( segment != null ) { final int segmentHeight = segment . nextY ( indent , maxWidth , renderer ) ; if ( currentY + segmentHeight >= minY && currentY <= maxY ) { final Optional < InteractiveSegment > result = segment . render ( x , currentY , indent , maxWidth , renderer , mouseX , mouseY ) ; if ( ! hovered . isPresent ( ) ) { hovered = result ; } } currentY += segmentHeight ; indent = segment . nextX ( indent , maxWidth , renderer ) ; segment = segment . next ( ) ; } if ( mouseX < x || mouseX > x + maxWidth || mouseY < y || mouseY > y + maxHeight ) { hovered = Optional . empty ( ) ; } hovered . ifPresent ( null ) ; GlStateManager . popAttrib ( ) ; GlStateManager . bindTexture ( 0 ) ; return hovered ; }
renders a list of segments and tooltips if a segment with a tooltip is hovered . returns the hovered interactive segment , if any .
