This is the bit of code that does all of the drawing, but it's only drawing half of the arrow. When it's a vertical arrow (North or South), it cuts off the left side, and when it's horizontal (East or West) it cuts of the top, both centered right at the tip; becoming a perfect half an arrow.
public void paint(Graphics g) {
setSize(100, steps * 50);
for (int i = 1; i < steps + 1; i++) {
y = i * 20;
if (directions.peek() == "North") {
int[] xNPoints = {x, x + 6, x + 2, x + 2, x + 2, x + 2, x + 6};
int[] yNPoints = {y - 5, y, y, y, y + 10, y, y};
g.drawPolygon(xNPoints, yNPoints, 7);
}
else if (directions.peek() == "East") {
int[] xEPoints = {x + 10, x + 5, x + 5, x - 5, x - 5, x + 5, x + 5};
int[] yEPoints = {y, y + 6, y + 2, y + 2, y + 2, y + 2, y + 6};
g.drawPolygon(xEPoints, yEPoints, 7);
}
else if (directions.peek() == "South") {
int[] xSPoints = {x, x + 6, x + 2, x + 2, x + 2, x + 2, x + 6};
int[] ySPoints = {y + 5, y, y, y - 10, y - 10, y, y};
g.drawPolygon(xSPoints, ySPoints, 7);
}
else if (directions.peek() == "West") {
int[] xWPoints = {x - 5, x, x, x + 10, x + 10, x, x};
int[] yWPoints = {y, y + 6, y + 2, y + 2, y + 2, y + 2, y + 6};
g.drawPolygon(xWPoints, yWPoints, 7);
}
g.drawString((String)directions.pop(), 5, y + 5);
The goal of the program is to return a set of user provided directions in reverse order, and I have a lot to clean up (add exceptions, clean up the GUI), but all of the code aside from what I just provided is used for prompting and storing the user's input for how many steps there are and what they are.