// JDraw - FRect class
// Written by Jim Calciano, Melanie Lear, and PJ Waskiewicz
// November 18, 1998
// Class that extends our abstract class DrawObject, and will create
// a filled rectangle
import java.awt.*;
public class FRect extends DrawObject{
private int bigx, bigy, smallx, smally;
private Color color;
private int x1,x2,y1,y2,width,height,tempx,tempy;
// Constructor for when the rectangle is being drawn.
public FRect(int x1, int y1, int x2, int y2, Color color){
this.color = color;
this.x1 = x1;
this.x2 = x2;
this.y1 = y1;
this.y2 = y2;
// Make sure the rectangle will be drawn in the right direction
if (x2 > x1){
bigx = x2;
tempx = x1;
smallx = x1;
}
else {
bigx = x1;
tempx = x2;
smallx = x2;
}
if (y2>y1) {
bigy=y2;
tempy = y1;
smally=y1;
}
else{
bigy=y1;
tempy = y2;
smally=y2;
}
width = bigx - smallx;
height = bigy - smally;
}
// Constructor for when the rectangle will be drawn from opening a file
public FRect(int x1, int y1, int x2, int y2, Color color, String s){
tempx = x1;
tempy = y1;
width = x2;
height = y2;
this.color = color;
}
// Method for when writing to a file, returns a string will all attributes
// of the object to be written to the file
public String returnString(){
return (new String("frect" + " " + tempx + " " + tempy + " " + width
+ " " + height + " " + color.getRed() + "," +
color.getGreen() + "," + color.getBlue()));
}
public void paint (Graphics g){
g.setColor(color);
g.fillRect(tempx, tempy, width, height);
}
public Point firstSelPoint(){
return(new Point(tempx,tempy));
}
public Point secondSelPoint(){
return(new Point(width,height));
}
public Color selColor(){
return color;
}
public void setSelColor(Color c){}
public boolean areYouSelected(){
return false;
}
public void youAreSelected(boolean b){
}
public boolean getIfObjectClicked(){
return false;
}
public boolean getIfHandleClicked(){
return false;
}
public boolean intersects(int x, int y){
if ((tempx <= x && x<=(tempx+width)) && (tempy <= y && y <= (tempy+height)))
return true;
else
return false;
}
}