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

package robot_graph;
import java.awt.*;
/**
 * This class will take a graphics g, int landmark symbol, 
 * and two int coordinates, then draw the corresponding 
 * symbol at the given point.
 * Creation date: (11/17/2000 9:05:17 PM)
 * @author:	William Martin - mail@WilliamMartin.com 
 */
public class DrawLandmark {
	int x, y, landmark;
	Graphics g;
	private String address;
	//define the color to draw with.
	private Color nodeColor = Color.black;
	//set the nodesize and path distance to draw.
	//must be evenly divisable.
	private final static int NODE_SIZE	= 16;
	private final static int PATH_DIST	= 30;
	// The following is redundant but necessary for
	// documentation of the landmark values.
	private final static int CROSSROAD 			= 0;
	private final static int EAST_PATH 			= 1;
	private final static int SOUTH_PATH 		= 2;
	private final static int WEST_PATH 			= 3;
	private final static int NORTH_PATH 		= 4;
	private final static int SOUTH_EAST 		= 5;
	private final static int SOUTH_WEST 		= 6;
	private final static int NORTH_WEST 		= 7;
	private final static int NORTH_EAST 		= 8;
	private final static int EAST_WEST_SOUTH	= 9;
	private final static int NORTH_SOUTH_WEST	= 10;
	private final static int EAST_WEST_NORTH	= 11;
	private final static int NORTH_SOUTH_EAST 	= 12;
	private final static int VIRT_NORTH			= 13;
	private final static int VIRT_EAST			= 14;
	private final static int VIRT_SOUTH			= 15;
	private final static int VIRT_WEST			= 16;
	private final static int VIRT_NORTH_SOUTH	= 17;
	private final static int VIRT_EAST_WEST		= 18;
/**
 * Calls appropriate method depending on which landmark.
 */
public DrawLandmark(Graphics g, int landmark, int x, int y ) {
	super();
	this.g = g;
	this.landmark = landmark;
	this.x = x;
	this.y = y;
	
	switch(landmark){
		case CROSSROAD:
			drawNode();
			drawNorth();
			drawEast();
			drawSouth();
			drawWest();
			drawLabel("");//Can add additional ids
			break;
		case EAST_PATH:
			drawNode();
			drawEast();
			drawLabel("");
			break;
		case SOUTH_PATH:
			drawNode(); 
			drawSouth();
			drawLabel("");
			break;
		case WEST_PATH:
			drawNode(); 
			drawWest();
			drawLabel("");
			break;
		case NORTH_PATH:
			drawNode();
			drawNorth();
			drawLabel("");
			break;
		case SOUTH_EAST:
			drawNode();
			drawSouth();
			drawEast();
			drawLabel("");
			break;
		case SOUTH_WEST:
			drawNode();
			drawSouth();
			drawWest();
			drawLabel("");
			break;
		case NORTH_WEST:
			drawNode();
			drawNorth();
			drawWest();
			drawLabel("");
			break;
		case NORTH_EAST:
			drawNode();
			drawNorth();
			drawEast();
			drawLabel("");
			break;
		case EAST_WEST_SOUTH:
			drawNode();
			drawEast();
			drawWest();
			drawSouth();
			drawLabel("");
			break;
		case NORTH_SOUTH_WEST:
			drawNode();
			drawNorth();
			drawSouth();
			drawWest();
			drawLabel("");
			break;
		case EAST_WEST_NORTH:
			drawNode();
			drawEast();
			drawWest();
			drawNorth();
			drawLabel("");
			break;
		case NORTH_SOUTH_EAST:
			drawNode();
			drawNorth();
			drawSouth();
			drawEast();
			drawLabel("");
			break;
		case VIRT_NORTH:
			drawVirtualNode(x, y-(NODE_SIZE/2));
			drawSouth(x, y-(NODE_SIZE/2));
			drawLabel("");
			break;
		case VIRT_EAST:
			drawVirtualNode(x+(NODE_SIZE/2), y);
			drawWest(x+(NODE_SIZE/2), y);
			drawLabel("");
			break;
		case VIRT_SOUTH:
			drawVirtualNode(x, y+(NODE_SIZE/2));
			drawNorth(x, y+(NODE_SIZE/2));
			drawLabel("");
			break;
		case VIRT_WEST:
			drawVirtualNode(x-(NODE_SIZE/2), y);
			drawEast(x-(NODE_SIZE/2), y);
			drawLabel("");
			break;
		case VIRT_NORTH_SOUTH:
			drawVirtualNode((x),(y-PATH_DIST));
			drawSouth((x),(y-PATH_DIST));
			drawNorth((x),(y+PATH_DIST));
			drawVirtualNode((x),(y+PATH_DIST));
			drawLabel("");
			break;
		case VIRT_EAST_WEST:
			drawVirtualNode((x-PATH_DIST),(y));
			drawEast((x-PATH_DIST),(y));
			drawWest((x+PATH_DIST),(y));
			drawVirtualNode((x+PATH_DIST),(y));
			drawLabel("");
			break;
		default:
			drawLabel("ERROR DISPLAYING GRAPH");
	}
}
/**
 * Makes a line from edge of node to 
 * east of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawEast() {
	g.setColor(nodeColor);
	g.drawLine((x+(NODE_SIZE/2)), y, 
		       (x+PATH_DIST+(NODE_SIZE/2)), y);
}
/**
 * Makes a line from edge of node to 
 * east of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawEast(int x, int y) {
	g.setColor(nodeColor);
	g.drawLine((x+(NODE_SIZE/2)), y, 
		       (x+PATH_DIST+(NODE_SIZE/2)), y);
}
/**
 * This method will draw a label of a certain type at 
 * the given address.
 * Creation date: (11/20/2000 2:39:02 PM)
 * @param String lablel
 */
public void drawLabel(String label) {
	
	address = new String(" (" + 
						String.valueOf(x) + 
						", " +
						String.valueOf(y) +
						")");
	
	g.drawString((label+address), x+5, y-10);
}
/**
 * This method will draw a black filled in square 
 * at the given address in the given canvas.
 * Creation date: (11/17/2000 10:23:30 PM)
 */
public void drawNode() {
	g.setColor(nodeColor);
	g.fillRect(x-(NODE_SIZE/2),y-(NODE_SIZE/2),
			   NODE_SIZE,NODE_SIZE);
}
/**
 * Makes a line from edge of node to 
 * north of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawNorth() {
	g.setColor(nodeColor);
	g.drawLine(x, (y-(NODE_SIZE/2)), 
		       x, (y-PATH_DIST-(NODE_SIZE/2)));
}
/**
 * Makes a line from edge of node to 
 * north of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawNorth(int x, int y) {
	g.setColor(nodeColor);
	g.drawLine(x, (y-(NODE_SIZE/2)), 
		       x, (y-PATH_DIST-(NODE_SIZE/2)));
}
/**
 * Makes a line from edge of node to 
 * south of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawSouth() {
	g.setColor(nodeColor);
	g.drawLine(x, (y+(NODE_SIZE/2)), 
		       x, (y+PATH_DIST+(NODE_SIZE/2)));
}
/**
 * Makes a line from edge of node to 
 * south of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawSouth(int x, int y) {
	g.setColor(nodeColor);
	g.drawLine(x, (y+(NODE_SIZE/2)), 
		       x, (y+PATH_DIST+(NODE_SIZE/2)));
}
/**
 * Makes a node that is not filled in.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawVirtualNode() {
	g.setColor(nodeColor);
	g.drawRect(x-(NODE_SIZE/2),y-(NODE_SIZE/2),
			   NODE_SIZE,NODE_SIZE);
}
/**
 * Makes a node that is not filled in.
 * Creation date: (11/22/2000 9:37:15 AM)
 */
public void drawVirtualNode(int x, int y) {
	g.setColor(nodeColor);
	g.drawRect(x-(NODE_SIZE/2),y-(NODE_SIZE/2),
			   NODE_SIZE,NODE_SIZE);
}
/**
 * Makes a line from edge of node to 
 * west of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawWest() {
	g.setColor(nodeColor);
	g.drawLine((x-(NODE_SIZE/2)), y, 
		       (x-PATH_DIST-(NODE_SIZE/2)), y);
}
/**
 * Makes a line from edge of node to 
 * west of node.
 * Creation date: (11/18/2000 9:37:15 AM)
 */
public void drawWest(int x, int y) {
	g.setColor(nodeColor);
	g.drawLine((x-(NODE_SIZE/2)), y, 
		       (x-PATH_DIST-(NODE_SIZE/2)), y);
}
}