/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package Vista;

/**
 *
 * @author mario
 */
import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

class Zonas extends JPanel {

    private int[] xPoints0 = {5, 150, 350, 495, 415, 370, 130, 85}; // Coordenadas X de los puntos
    private int[] yPoints0 = {50, 10, 10, 50, 260, 410, 410, 260}; 

    private int[] xPoints = {30, 150, 350, 470, 450, 350, 150, 50}; // Coordenadas X de los puntos
    private int[] yPoints = {70, 30, 30, 70, 120, 80, 80, 120};     // Coordenadas Y de los puntos
    
    private int[] xPoints2 = {50, 150, 350, 450, 430, 350, 150, 70}; // Coordenadas X de los puntos
    private int[] yPoints2 = {125, 85, 85, 125, 170, 130, 130, 170}; 
    
    private int[] xPoints3 = {70, 150, 350, 430, 400, 350, 350, 150, 150, 100}; // Coordenadas X de los puntos
    private int[] yPoints3 = {177, 137, 137, 177, 252, 232, 177, 177, 232, 252}; 
    
    private int[] xPoints4 = {100, 180, 190, 310, 320, 400, 350, 300, 200, 150}; // Coordenadas X de los puntos
    private int[] yPoints4 = {259, 228, 289, 289, 228, 259, 400, 384, 384, 400}; 
    
    private int[] xPoints5 = {100, 400, 350, 150}; // Coordenadas X de los puntos
    private int[] yPoints5 = {420, 420, 480, 480};
    
    private Color fondo = new Color(246, 246, 246);
    
    private Color silverColor = new Color(192, 192, 192); // Plata
    private Color goldColor = new Color(255, 215, 0); // Oro
    
    private Color platinumColor = new Color(229, 228, 226); // Platino
    private Color diamondColor = new Color(224, 116, 186); // Diamante
    
    private Color currentColor; // Color actual del polígono

    public Zonas() {
        // No se añade MouseListener aquí
    }

    boolean isPointInsidePolygon(int x, int y, int[] xPoints, int[] yPoints) {
        Polygon polygon = new Polygon(xPoints, yPoints, xPoints.length);
        return polygon.contains(x, y);
    }

    int[] getXPoints() {
        return xPoints;
    }

    int[] getYPoints() {
        return yPoints;
    }

    int[] getXPoints2() {
        return xPoints2;
    }

    int[] getYPoints2() {
        return yPoints2;
    }

    int[] getXPoints3() {
        return xPoints3;
    }

    int[] getYPoints3() {
        return yPoints3;
    }

    int[] getXPoints4() {
        return xPoints4;
    }

    int[] getYPoints4() {
        return yPoints4;
    }

    int[] getXPoints5() {
        return xPoints5;
    }

    int[] getYPoints5() {
        return yPoints5;
    }

    Color getCurrentColor() {
        return currentColor;
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        g.setColor(fondo);
        g.fillPolygon(xPoints0, yPoints0, xPoints0.length);
        g.setColor(Color.black);
        g.drawPolygon(xPoints0, yPoints0, xPoints0.length);

        // Dibujar el primer polígono (Plata)
        currentColor = silverColor;
        g.setColor(currentColor);
        g.fillPolygon(xPoints, yPoints, xPoints.length);
        g.setColor(Color.black);
        g.drawPolygon(xPoints, yPoints, xPoints.length);
        
        // Dibujar el segundo polígono (Oro)
        currentColor = goldColor;
        g.setColor(currentColor);
        g.fillPolygon(xPoints2, yPoints2, xPoints2.length);
        g.setColor(Color.black);
        g.drawPolygon(xPoints2, yPoints2, xPoints2.length);
        
        // Dibujar el tercer polígono (Platino)
        currentColor = platinumColor;
        g.setColor(currentColor);
        g.fillPolygon(xPoints3, yPoints3, xPoints3.length);
        g.setColor(Color.black);
        g.drawPolygon(xPoints3, yPoints3, xPoints3.length);
        
        // Dibujar el cuarto polígono (Diamante)
        currentColor = diamondColor;
        g.setColor(currentColor);
        g.fillPolygon(xPoints4, yPoints4, xPoints4.length);
        g.setColor(Color.black);
        g.drawPolygon(xPoints4, yPoints4, xPoints4.length);
        
        // Dibujar el cuarto polígono (Diamante)
        currentColor = silverColor;
        g.setColor(currentColor);
        g.fillPolygon(xPoints5, yPoints5, xPoints5.length);
        g.setColor(Color.black);
        g.drawPolygon(xPoints5, yPoints5, xPoints5.length);
    }
}
