@Override public void paint(Graphics g){
  int a[]=arr;
  int y=0;
  int deltaY=0, deltaX=0, evenY=0;
  Dimension currentSize=getSize();
  int currentHeight=currentSize.height;
  int currentWidth=currentSize.width;
  if (!currentSize.equals(initialSize)) {
    evenY=(currentHeight - initialSize.height) % 2;
    deltaY=(currentHeight - initialSize.height) / 2;
    deltaX=(currentWidth - initialSize.width) / 2;
    if (deltaY < 0) {
      deltaY=0;
      evenY=0;
    }
    if (deltaX < 0) {
      deltaX=0;
    }
  }
  g.setColor(getBackground());
  y=currentHeight - deltaY - 1;
  for (int i=a.length; --i >= 0; y-=2) {
    g.drawLine(deltaX + arr[i],y,currentWidth,y);
  }
  g.setColor(Color.black);
  y=currentHeight - deltaY - 1;
  for (int i=a.length; --i >= 0; y-=2) {
    g.drawLine(deltaX,y,deltaX + arr[i],y);
  }
  if (h1 >= 0) {
    g.setColor(Color.red);
    y=deltaY + evenY + h1 * 2 + 1;
    g.drawLine(deltaX,y,deltaX + initialSize.width,y);
  }
  if (h2 >= 0) {
    g.setColor(Color.blue);
    y=deltaY + evenY + h2 * 2 + 1;
    g.drawLine(deltaX,y,deltaX + initialSize.width,y);
  }
}

@ Override public void paint ( Graphics g ) { int a [ ] = arr ; int y = 0 ; int deltaY = 0 , deltaX = 0 , evenY = 0 ; Dimension currentSize = getSize ( ) ; int currentHeight = currentSize . height ; int currentWidth = currentSize . width ; if ( ! currentSize . equals ( initialSize ) ) { evenY = ( currentHeight - initialSize . height ) % 2 ; deltaY = ( currentHeight - initialSize . height ) / 2 ; deltaX = ( currentWidth - initialSize . width ) / 2 ; if ( deltaY < 0 ) { deltaY = 0 ; evenY = 0 ; } if ( deltaX < 0 ) { deltaX = 0 ; } } g . setColor ( getBackground ( ) ) ; y = currentHeight - deltaY - 1 ; for ( int i = a . length ; -- i >= 0 ; y -= 2 ) { g . drawLine ( deltaX + arr [ i ] , y , currentWidth , y ) ; } g . setColor ( Color . black ) ; y = currentHeight - deltaY - 1 ; for ( int i = a . length ; -- i >= 0 ; y -= 2 ) { g . drawLine ( deltaX , y , deltaX + arr [ i ] , y ) ; } if ( h1 >= 0 ) { g . setColor ( Color . red ) ; y = deltaY + evenY + h1 * 2 + 1 ; g . drawLine ( deltaX , y , deltaX + initialSize . width , y ) ; } if ( h2 >= 0 ) { g . setColor ( Color . blue ) ; y = deltaY + evenY + h2 * 2 + 1 ; g . drawLine ( deltaX , y , deltaX + initialSize . width , y ) ; } }
paint the array of numbers as a list of horizontal lines of varying lengths .
