package ng.Algorithm.Layouts;
|
|
public class Rect {
|
private Piece source;
|
private int width;
|
private int length;
|
private double area;
|
public int x,y;
|
public int Row,Col;
|
public boolean isHeng=false;
|
private Piece.LayoutMode mode;
|
private Rect(){
|
|
}
|
|
public boolean canHeng(){
|
return mode==Piece.LayoutMode.Both || mode== Piece.LayoutMode.Heng;
|
}
|
|
|
public boolean canZhong(){
|
return mode==Piece.LayoutMode.Both || mode== Piece.LayoutMode.Zhong;
|
}
|
|
|
|
public Rect(Piece source){
|
this.width=source.width<=source.height?source.width:source.height;
|
this.length=source.width>=source.height?source.width:source.height;
|
this.area=this.width*this.length;
|
this.mode=source.Mode;
|
this.source=source;
|
|
}
|
|
|
public int getWidth(){
|
return this.width;
|
}
|
|
public int getLength(){
|
return this.length;
|
}
|
|
|
|
public double getArea(){
|
return this.area;
|
}
|
|
|
public int getXSize(){
|
return isHeng?this.length:this.width;
|
}
|
|
public int getYSize(){
|
return isHeng?this.width:this.length;
|
}
|
|
|
public Piece getSource(){
|
return source;
|
}
|
|
protected void CopyTo(Rect r){
|
r.source=this.source;
|
r.width=this.width;
|
r.length=this.length;
|
r.mode=this.mode;
|
r.isHeng=this.isHeng;
|
r.area=this.area;
|
r.Row=this.Row;
|
r.Col=this.Col;
|
r.x=this.x;
|
r.y=this.y;
|
}
|
|
|
public Rect CloneRect(){
|
Rect r=new Rect();
|
CopyTo(r);
|
return r;
|
}
|
}
|