1  /*
  2   *  File:  DrawableRoundRect.java
  3   *
  4   *  A rounded rectangle class
  5   *
  6   *  Copyright:  Northeast Parallel Architectures Center
  7   *  
  8   */
  9  
 10  import java.awt.*;
 11  
 12  public class DrawableRoundRect extends DrawableRectangle {
 13  
 14    // Instance variables:
 15    protected int arcW, arcH;  // arcWidth and arcHeight
 16    
 17    public DrawableRoundRect( int new_x1, int new_y1, int new_x2, int new_y2 ) {
 18      super( new_x1, new_y1, new_x2, new_y2 );
 19      arcW = 100; arcH = 50;
 20    }
 21    
 22    public void setArc( int new_arcW, int new_arcH ) {
 23      arcW = new_arcW; arcH = new_arcH;
 24    }
 25  
 26    public void paint( Graphics g ) {
 27      int x = Math.min( x1, x2 );
 28      int y = Math.min( y1, y2 );
 29      int w = Math.abs( x2 - x1 );
 30      int h = Math.abs( y2 - y1 );
 31      g.setColor( color );
 32      if ( fill ) {
 33        g.fillRoundRect( x, y, w, h, arcW, arcH );
 34      } else {
 35        g.drawRoundRect( x, y, w, h, arcW, arcH );
 36      }
 37    }
 38    
 39  }