/*  This file is part of the source code for 3D-XplorMath-J, Version 1.0 (January 2008).
 *  Copyright (c) 2008 The 3D-XplorMath Consortium (http://3d-xplormath.org).
 *  This source code is released under a BSD License, which allows redistribution   
 *  in source and binary form, with or without modification, provided copyright
 *  and license information are included, and with no warranty or guarantee of
 *  any kind.  For details, see http://3d-xplormath.org/j/source/BSDLicense.txt
 */
 
 package vmm.core.render;

import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import vmm.core.Transform;

public class RectShape2D extends GeometryElement2D {
	
	public final static int RECT = 0;
	public final static int FILLED_RECT = 1;
	public final static int OVAL = 2;
	public final static int FILLED_OVAL = 3;

	private int shape;
	private double x,y,width,height;
	
	
	
	public RectShape2D(int shape, double x, double y, double width, double height) {
		super();
		this.shape = shape;
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
	}



	protected void draw(Transform transform, Graphics2D g) {
		Point2D pt1 = new Point2D.Double(x,y);
		Point2D pt2 = new Point2D.Double(x+width,y+height);
		transform.windowToDrawingCoords(pt1);
		transform.windowToDrawingCoords(pt2);
		switch (shape) {
		case RECT:
			g.draw(new Rectangle2D.Double(pt1.getX(), pt1.getY(), pt2.getX()-pt1.getX(), pt2.getY()-pt1.getY()));
			break;
		case FILLED_RECT:
			g.fill(new Rectangle2D.Double(pt1.getX(), pt1.getY(), pt2.getX()-pt1.getX(), pt2.getY()-pt1.getY()));
			break;
		case OVAL:
			g.draw(new Ellipse2D.Double(pt1.getX(), pt1.getY(), pt2.getX()-pt1.getX(), pt2.getY()-pt1.getY()));
			break;
		case FILLED_OVAL:
			g.fill(new Ellipse2D.Double(pt1.getX(), pt1.getY(), pt2.getX()-pt1.getX(), pt2.getY()-pt1.getY()));
			break;
		}

	}

}
