
package jp.riken.brain.ni.samuraigraph.base;

/**
 * A generic 2 element tuple that is represented by two double numbers.
 * 
 */
public class SGTuple2d implements Cloneable
{
	/**
	 * The x coordinate.
	 */
	public double x;

	/**
	 * The y coordinate.
	 */
	public double y;


	/**
	 * 
	 */
	public SGTuple2d(){}


	/**
	 * Constructs and initializes a SGTuple2d from the specified xy coordinates.
	 * @param x the x coordinate
	 * @param y the y coordinate
	 */
	public SGTuple2d( final double X, final double Y )
	{
		this.x = X;
		this.y = Y;
	}


	/**
	 * 
	 */
	public SGTuple2d( final SGTuple2d tuple )
	{
		this.x = tuple.x;
		this.y = tuple.y;
	}


	/**
	 * 
	 */
	public void setValues( final double X, final double Y )
	{
		this.x = X;
		this.y = Y;
	}


	/**
	 * 
	 */
	public String toString()
	{
		final String str = new String("(" + this.x + "," + this.y + ")");
		return str;
	}


	/**
	 * 
	 */
	public boolean equals( Object obj )
	{
		if( ( obj instanceof SGTuple2d ) == false ) return false;
		SGTuple2d t = (SGTuple2d)obj;
		if( t.x!=this.x || t.y!=this.y ) return false;
		return true;
	}


	/**
	 * 
	 *
	 */
	public void clear()
	{
		this.x = 0.0;
		this.y = 0.0;
	}


	/**
	 * 
	 */
	public Object clone()
	{
		try
		{
			return super.clone();
		}
		catch( CloneNotSupportedException ex )
		{
			// this shouldn't happen, since we are Cloneable
			throw new InternalError();
		}
	}

}
