import java.awt.*; class intersectionPoint extends point { public shape s1, s2; protected boolean pExists = true; protected double dragX, dragY; protected int whichPoint; public intersectionPoint(shape S1, shape S2, int WhichPoint) { s1 = S1; s2 = S2; whichPoint = WhichPoint; UpdateCoordinates(); } public intersectionPoint(shape S1, shape S2) { s1 = S1; s2 = S2; whichPoint = 1; UpdateCoordinates(); } public boolean exists() { UpdateCoordinates(); return(pExists); } public void UpdateCoordinates() { point p = s1.intersect(s2, whichPoint); if (p == null) p = s2.intersect(s1, whichPoint); if (p == null) { pExists = false; } else { x = p.x; y = p.y; pExists = true; } } public void draw(GeometryWindow G) { if (!exists() || hidden) return; UpdateCoordinates(); if (pExists) super.draw(G); } public void resetTranslated() { translated = false; s1.resetTranslated(); s2.resetTranslated(); } public boolean translate(double dx, double dy) { if (translated) return(true); translated = true; s1.translate(dx, dy); s2.translate(dx, dy); return(true); } public boolean mouseDown(double X, double Y) { if (hidden) return(false); if (gMath.distance(x, y, X, Y) < clickRange) { dragging = true; double dx = X - x; double dy = Y - y; resetTranslated(); s1.translate(dx, dy); s2.translate(dx, dy); UpdateCoordinates(); dragX = X; dragY = Y; return(true); } return(false); } public boolean mouseDrag(double X, double Y) { if (dragging == true) { double dx = X - dragX; double dy = Y - dragY; resetTranslated(); s1.translate(dx, dy); s2.translate(dx, dy); UpdateCoordinates(); dragX = X; dragY = Y; return(true); } return(false); } public boolean mouseUp(double X, double Y) { dragging = false; return(false); } }