package ecoparasite.svg;

import ecoparasite.representation.ValeursXY;
import ecoparasite.svg.elements.ElementsFactory;

public class SVGResizing {

    private double minX;
    private double maxX;
    private double minY;
    private double maxY;

    public SVGResizing(
        double minXGrad,
        double minYGrad,
        double maxXGrad,
        double maxYGrad
    ){
           this.minX = minXGrad;
           this.maxX = maxXGrad;
           this.minY = minYGrad;
           this.maxY = maxYGrad;
    }

    public double getMinX() {
        return minX;
    }

    public double getMaxX() {
        return maxX;
    }

    public double getMinY() {
        return minY;
    }

    public double getMaxY() {
        return maxY;
    }

    public Coordonnees resize(ValeursXY vxy ){
        return this.resize( vxy.getX(), vxy.getY() );
    }

    public Coordonnees resize( double X, double Y ){
        double surface = ElementsFactory.SVG_SIZE - 2 * ElementsFactory.SVG_OFFSET;

        double convX = ( X - minX ) / ( maxX - minX );
        double convY = ( Y - minY ) / ( maxY - minY );

        double SVG_X = ElementsFactory.SVG_OFFSET + convX * surface;
        double SVG_Y = ElementsFactory.SVG_SIZE - ElementsFactory.SVG_OFFSET - convY * surface;

        return new Coordonnees(SVG_X, SVG_Y);
    }

}
