import java.awt.Graphics; public class Vertex { public double x; public double y; public Vertex(double x, double y) { this.x = (x < 1) ? 1 : (x > Parameters.WIDTH) ? Parameters.WIDTH : x; this.y = (y < 1) ? 1 : (y > Parameters.HEIGHT) ? Parameters.HEIGHT : y; } public void draw(Graphics g) { g.fillOval((int)(x-6), (int)(y-6), 12, 12); } public boolean equals(Vertex v) { // returns true if and are close enough // as defined by parameter EPSILON return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) <= Parameters.EPSILON2; } public boolean contains(Vertex v) { return (x-v.x)*(x-v.x) + (y-v.y)*(y-v.y) <= Parameters.NEAR2; } }