//[Update:[Thu Jul 23 IST 2020]]
/*History:
**Sun Nov 03 2019
   Started.
*/
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class GraphicsPad
    implements Pad {
    final static int mult = 2000;
    int offX, offY;
    Graphics2D g;
    Vec2 curr;
    
    private boolean first = true;
    
    public GraphicsPad(Graphics2D g, int ox, int oy) {
        this.g = g;
        offX = ox;
        offY = oy;
    }
    public void startGroup() {}
    public void endGroup() {}

    void setOffset(int ox, int oy) {
        offX = ox;
        offY = oy;
    }
    int mx(double what) {
        return (int)(mult*what)+offX;
    }
    int my(double what) {
        return (int)(offY-mult*what);
    }

    public void startPic() {}
    public void endPic() {}
    public void startPath() {
        first = true;
    }
    public void endPath() {}
    boolean ignore = false;
    public void startPath1() {
        ignore = true;
    }
    public void endPath1() {
        ignore = false;
    }
    public void addPoint(Vec2 p) {
        if(ignore) return;
        if(!first) g.drawLine(mx(curr.x),my(curr.y),mx(p.x),my(p.y));
        first = false;
        curr = p;
    }

    public void drawPoint(Vec2 p) {
        g.fillOval(mx(p.x)-3,my(p.y)-3,7,7);
    }

}
