// classes defining graph arc or link structure // author: p gray // date: 26 june 98 import java.awt.*; class Link { static int maxLinkId = 0; int id; Node nodes[] = new Node[2]; boolean selected = false; Link(Node startNode, Node endNode) { id = maxLinkId++; nodes[0] = startNode; nodes[1] = endNode; } // accessing public String id() { return Integer.toString(id); } public boolean hasNode(Node node) { if ((nodes[0] == node) | (nodes[1] == node)) return(true); else return(false); } public int getID() { return(id); } // selection methods public boolean isSelected() { return selected; } public void select() { selected = true; } public void unselect() { selected = false; } // displaying public void display(Graphics g) { if (selected) g.setColor(Color.red); else g.setColor(Color.black); g.drawLine(nodes[0].origX()+(nodes[0].width/2), nodes[0].origY()+(nodes[0].height/2),nodes[1].origX()+(nodes[0].width/2), nodes[1].origY()+(nodes[0].height/2)); } }