[ b a c k   t o   i n d e x ]

package robot_graph;
import java.util.*;
/**
 * This method creates a graph that has corners of 90 degrees.
 * The input will be a scenero (landmark) and the address of 
 * the particular event (x, y).
 *
 *	USAGE:
 *			1) Construct a graph to startinserting landmarks.
 *				example: 	RobotGraph g = new RobotGraph();
 *			2) Insert landmarks as they are detected.
 *				(declairations) => int scenero, x, y;
 *				example:	g.construct(scenero, x, y); 
 *
 * Creation date: (11/28/2000 7:11:32 PM)
 * @author: William Martin - boneshakerbike@hotmail.com
 */
public class RobotGraph extends Graph{
	private int tempX = 0; 
	private int tempY = 0;			// Address variables
	private int tempVertexNumber = 1;	// Search control
	private Vertex v1, v2, v3; 			// Temp vertices
	private boolean beenHere; 			// been here!
/**
 * A Robot Graph is a graph used by a robot maze mapping modue.
 * Creation date: (11/28/2000 8:28:57 PM)
 */
public RobotGraph() {
	super("Robot Graph");
	beenHere = false;
}
/**
 * If we have been on this vertex before then return 
 * true else we havent and return false.
 * Creation date: (12/4/2000 3:08:06 PM)
 * @return boolean
 */
public boolean checkHeading() {
	return beenHere;
}
/**
 * This method will construct the graph as the 
 * landmarks and their address's are inserted.
 * This graph will have all vertices with paths
 * that are at 90 degrees only.  This graph is for
 * special use by a robot mapping module.
 * Creation date: (11/28/2000 7:24:12 PM)
 * @param landmark int
 * @param x int
 * @param y int
 */
public void construct(int landmark, int x, int y) {
	if (tempVertexNumber == 0) { 	//if first, set 
									//virtual node
		tempVertexNumber++;
		tempX = x;
		tempY = y;
	} else {
		//keep x's and y's from wandering
		//if (Math.abs(tempX - x) > Math.abs(tempY - y)) {
			//y = tempY;
		//} else {
		//	x = tempX;
		//}
		// if there are vertices in the area, adjust!
		if (this.adjustedVertex(x, y) == false) {
			this.addVertex(landmark, x, y);
			beenHere = false;
		}else{
			beenHere = true;
		}	
		if (tempVertexNumber == 1) { 	//this node is saved 
										//to connect to next 
										//node.
			v1 = this.findVertex(x, y); 	//set temp v1.
			tempVertexNumber++;
		} else { 	//add code to add edthise
					//and adjust
			v2 = this.findVertex(x, y);		//set temp v2
			if (this.findEdge(v1, v2) == null){
				Edge edge = this.addEdge(v1, v2);
			}
			v1 = v2; 						//now v1 thisets v2
		}
		tempX = x;
		tempY = y;
		
		if (this.adjustAllVertex(x, y) == true){}; 
	}
	System.out.println("Temp Vert. Number: " + String.valueOf(tempVertexNumber));
	System.out.println("x: " + String.valueOf(x));
	System.out.println("y: " + String.valueOf(y));
	System.out.println("temX: " + String.valueOf(tempX));
	System.out.println("tempY: " + String.valueOf(tempY));
	System.out.println("landmark " + String.valueOf(landmark));
	//System.out.println("landmark " + String.valueOf(scenero));
}
/**
 * This method returns a integer array that contains the 
 * entire graph to be sent to the client. 
 * 
 * Creation date: (10/04/2000 1:05:59 PM)
 * @return integer array
 */
public int[] graphDataArray() {
	int[] array = new int[this.vertices.size()*3];
	for (int i = 0; i < this.vertices.size(); i++) {
		Vertex v = (Vertex)this.vertices.elementAt(i);
		array[i] = v.landmark();
		i++;
		array[i] = v.xCoord;
		i++;
		array[i] = v.yCoord;
	}
	return array;
}
}