File "MyRectangle.java"
Full Path: /home/analogde/www/Ebook/Informatique/JAVA/Source_TLS/Move/MyRectangle.java
File size: 643 bytes
MIME-type: text/plain
Charset: utf-8
package toto;
import java.awt.*;
public class MyRectangle extends MyShape
{
// constructor
public MyRectangle(int firstX,int firstY,int secondX,int secondY, Color shapeColor )
{
super( firstX, firstY, secondX, secondY, shapeColor );
}
// end constructor
// draw a rectangle
public void draw( Graphics g )
{
int upperLeftX = Math.min( getX1(), getX2() );
int upperLeftY = Math.min( getY1(), getY2() );
int width = Math.abs( getX1() - getX2() );
int height = Math.abs( getY1() - getY2() );
g.setColor( getColor() );
g.fillRect( upperLeftX, upperLeftY, width, height );
}
// end method draw
} // end class MyRectangle