
import java.awt.*;

public class pointOnShape extends point
{
     protected shape s;

     public pointOnShape()
     {
	  s = null;
	  x = 0; y = 0;
     }

     public pointOnShape(double X, double Y, shape S)
     {
	  s = S;
	  point p = s.coordOnShape(X, Y);
//	  s.addLinkedShape(this);
	  
	  x = p.x; y = p.y;
     }

     public boolean exists()
     {
	  return(s.exists());
     }

     public void SetPoint(double X, double Y)
     {
	  point p = s.coordOnShape(X, Y);
	  
	  x = p.x; y = p.y;
     }

     public void setX(double X) 
     { 
	  point p = s.coordOnShape(X, y); 
	  x = p.x; y = p.y;
     }

     public void setY(double Y)
     { 
	  point p = s.coordOnShape(x, Y); 
	  x = p.x; y = p.y;
     }

//     public void draw(GeometryWindow G)
//     {
//	  G.setColor(color);
//	  G.drawPoint(x, y);
//     }
     
     public void resetTranslated()
     {
	  translated = false;
	  
	  s.resetTranslated();
     }

     public boolean translate(double dx, double dy)
     {
	  if (translated)
	       return(true);

	  translated = true;

	  point p = s.coordOnShape(x + dx, y + dy);
	  x = p.x;
	  y = p.y;
	  
	  return(true);
     }

     public boolean mouseDown(double X, double Y)
     {
	  if (hidden)
	       return(false);

	  if (gMath.distance(x, y, X, Y) < clickRange)
	  {
	       dragging = true;
	       
	       point p = s.coordOnShape(X, Y);
	       x = p.x;
	       y = p.y;
	       return(true);
	  }
	  return(false);
     }

     public boolean mouseDrag(double X, double Y)
     {
	  if (dragging == true)
	  {
	       point p = s.coordOnShape(X, Y);
	       x = p.x;
	       y = p.y;
	       return(true);
	  }
	  return(false);
     }

     public boolean mouseUp(double X, double Y)
     {
	  dragging = false;
	  return(false);
     }
};






