import java.awt.*;

// a draggable point with a fixed x-coordinate.
//
// Author:      Alexander Bogomolny, CTK Software, Inc.
// URL:         http://www.cut-the-knot.com
// Date:        November 30, 2000
// Copyright:   A. Bogomolny
//              Permission to use and modify the file is therefore granted
//              as long as this comment remains unchanged. Do this at your
//              own risk.
//
class VPoint extends MPoint
{
    // when hit, the point must be close
    // to the cursor horizontally,
    // but not necessarily vertically.
    // Use different accuracy in two directions
    //
    static int dx;
    static int dy;
    static public void SetDist(int x, int y)
    {
        dx = x;
        dy = y;
    }

    // Draggable points are best represented in screen
    // coordinates. For calculations in "real world",
    // use scales
    static Scale XScale;
    static Scale YScale;

    static public void SetScales(Scale xs, Scale ys)
    {
        XScale = xs;
        YScale = ys;
    }

    public VPoint(int a, int b)
    {
        super(a, b);
    }

    public boolean IsHit(int a, int b)
    {
        Defect.y = y - b;
        return Math.abs(a - x) < dx && Math.abs(b - y) < dy;
    }

    public void UpdateLocation(int a, int b)
    {
        y = Defect.y + b;
    }

    static public double ScaledX(double x)
    {
        return XScale.Do(x);
    }

    public double ScaledX()
    {
        return XScale.Do(x);
    }

    static public double ScaledY(double y)
    {
        return YScale.Do(y);
    }

    public double ScaledY()
    {
        return YScale.Do(y);
    }

    static public double ReverseY(double y)
    {
        return YScale.Reverse(y);
    }
}