/* $Id: ImageSearchFilterTypeBImpl.java 125 2011-03-09 09:49:51Z ohura $ */
package smart_gs.dictionary.image;

import java.awt.Rectangle;

public class ImageSearchFilterTypeBImpl extends ImageSearchFilterImpl{

	/**
	 * 判定処理
	 * 
	 */
	@Override
	public boolean contains(Rectangle a,Rectangle b){
		int w = a.width;
		int h = a.height;
		int W = b.width;
		int H = b.height;
		
		if ((w | h | W | H) < 0) {
		    return false;
		}
		
		int x  = 0;
		int x2 = 0; 
		int X  = 0;
		int X2 = 0;
		int y  = 0;
		int y2 = 0; 
		int Y  = 0;
		int Y2 = 0;
		
		if(a.x < b.x){
			x  = a.x;
			x2 = a.x + a.width;
			int XX = b.x + (b.width / 2);
			X  = XX;
			X2 = XX + (b.width / 2); 

			y  = a.y;
			y2 = a.y + a.height;
			int YY  = b.y + (b.height / 2); 
			Y  = YY;
			Y2 = YY + (b.height / 2); 
		}else{
			int XX = a.x +  (a.width / 2);
			X  = XX;
			X2 = XX + (a.width / 2);
			x  = b.x / 2;
			x2 = b.x / 2 + b.width; 

			int YY = a.y + (a.height /2);
			Y  = YY;
			Y2 = YY + (a.height / 2);
			y  = b.y;
			y2 = b.y + b.height; 
		}
		/*
		System.out.println("x  =" + x);
		System.out.println("x2 =" + x2);
		System.out.println("x' =" + X);
		System.out.println("x2'=" + X2);
		*/
		if(X < x2 && x < X){
			if(Y < y2 && y < Y){
				return true;
			}
		}
		return false;
	}

}
