package Visualizer;

import javax.swing.JComponent;
import java.awt.Graphics;
import java.awt.*;

public class rudderPosition extends JComponent {

    int xBound = 0;
    int yBound = 0;

    float rudderTravel = 0;

    rudderPosition(int currentXBound, int currentYBound) {
       xBound = currentXBound;
       yBound = currentYBound;
    }
  
    public void paint(Graphics g) {
        Graphics2D g2 = (Graphics2D) g;
        int spacer = 10;
        g.setColor(Color.gray);
        g2.fillRect(0, spacer, xBound, yBound - spacer);

        g2.setColor(Color.red);
        int width = (int) (xBound/2 * rudderTravel);
        //g2.drawRect(xBound/2, 0 +spacer, width, yBound);
        g2.fillRect(xBound/2, 0 + spacer, width, yBound);
        
        g.drawString("Yaw Left",0, yBound/2);
        int textWidth = g.getFontMetrics().stringWidth("Roll Right");
        g.drawString("Yaw Right", xBound - textWidth, yBound/2);
        // try {
        //     final BufferedImage image = ImageIO.read(new File("/Users/flyingtopher/Desktop/Code Citadel/School/2. Research/Fork Clone/XPlaneConnectCSP/Java/ProjectModels/Visualizer/assets/Rudder Pedals.png"));
        //     Image scaledImage = image.getScaledInstance(xBound, yBound, Image.SCALE_DEFAULT);
        //     g.drawImage(scaledImage, 0, 0, getFocusCycleRootAncestor());
        // } catch (IOException e) {
        //     System.out.print("Rudder Image Failed");
        // }
    }

    public void setX(float newX) {
        this.rudderTravel = newX;
    }

    public void setXBound(int newX) {
        this.xBound = newX;
    }

    public void setYBound(int newY) {
        this.yBound = newY;
    }

}