diff --git a/ProyectoConciertoApp/src/Vista/VentanaConcierto.java b/ProyectoConciertoApp/src/Vista/VentanaConcierto.java new file mode 100644 index 0000000..6e064bf --- /dev/null +++ b/ProyectoConciertoApp/src/Vista/VentanaConcierto.java @@ -0,0 +1,228 @@ +/* + * 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; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.GridLayout; +import java.awt.Polygon; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.BorderFactory; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + + +/** + * + * @author mario + */ + + + 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() { + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + int mouseX = e.getX(); + int mouseY = e.getY(); + + if (isPointInsidePolygon(mouseX, mouseY, xPoints, yPoints)) { + JOptionPane.showMessageDialog(null, "Zona Plata"); + } else if (isPointInsidePolygon(mouseX, mouseY, xPoints2, yPoints2)) { + JOptionPane.showMessageDialog(null, "Zona Oro"); + } else if (isPointInsidePolygon(mouseX, mouseY, xPoints3, yPoints3)) { + JOptionPane.showMessageDialog(null, "Zona Platino"); + } else if (isPointInsidePolygon(mouseX, mouseY, xPoints4, yPoints4)) { + JOptionPane.showMessageDialog(null, "Zona Diamante"); + } + } + + @Override + public void mouseEntered(MouseEvent e) { + Object source = e.getSource(); + if (source instanceof Component) { + Component component = (Component) source; + component.setForeground(component.getForeground().darker()); + repaint(); + } + } + + @Override + public void mouseExited(MouseEvent e) { + Object source = e.getSource(); + if (source instanceof Component) { + Component component = (Component) source; + component.setForeground(currentColor); + repaint(); + } + } + }); + } + + private boolean isPointInsidePolygon(int x, int y, int[] xPoints, int[] yPoints) { + Polygon polygon = new Polygon(xPoints, yPoints, xPoints.length); + return polygon.contains(x, y); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + // Dibujar el cuarto polígono (Diamante) + 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); + + + } + } + +public class VentanaConcierto extends JFrame { + private JPanel panelLienzoAccesorios,panelLienzoCara,panelLienzoRopaS, panelLienzoRopaI; + + public VentanaConcierto() { + configurarVentana(); + } + + private void configurarVentana() { + setTitle("AvatART"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setSize(810, 650); + setLocationRelativeTo(null); + + getContentPane().setBackground(new Color(200, 160, 255)); // Lila + + JPanel panelLienzo = new JPanel(); + panelLienzo.setLayout(new GridLayout(4, 1)); // 4 filas, 1 columna + panelLienzo.setBorder(BorderFactory.createLineBorder(Color.BLACK)); + + + JPanel panelLienzoContenedor = new JPanel(new BorderLayout()); + panelLienzoContenedor.add(panelLienzo, BorderLayout.CENTER); + panelLienzoContenedor.setBackground(new Color(200, 160, 255)); // Lila + panelLienzoContenedor.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); // Añade un espacio alrededor + + JPanel panelComboBox = new JPanel(); + panelComboBox.setLayout(new GridLayout(8, 1, 0, 20)); // Espacio vertical entre componentes + panelComboBox.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); + panelComboBox.setBackground(new Color(200, 160, 255)); // Lila + + JLabel label1 = new JLabel("Elige tus accesorios"); + label1.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); + JLabel label2 = new JLabel("Elige tu cabeza"); + label2.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); + JLabel label3 = new JLabel("Elige tu ropa superior"); + label3.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); + JLabel label4 = new JLabel("Elige tu ropa inferior"); + label4.setFont(new Font("Comic Sans MS", Font.BOLD, 20)); + + panelLienzoContenedor.add(new Zonas()); + + panelComboBox.add(label1); + panelComboBox.add(label2); + panelComboBox.add(label3); + panelComboBox.add(label4); + + + // Panel para el título "AvatArt" + JPanel panelTitulo = new JPanel(); + JLabel labelTitulo = new JLabel("AvatART", SwingConstants.LEFT); + labelTitulo.setFont(new Font("Comic Sans MS", Font.BOLD, 50)); + panelTitulo.add(labelTitulo); + panelTitulo.setBackground(new Color(200, 160, 255)); + + add(panelTitulo, BorderLayout.NORTH); + + add(panelComboBox, BorderLayout.WEST); + add(panelLienzoContenedor, BorderLayout.CENTER); + + setVisible(true); + } + + public static void main(String[] args) { + + VentanaConcierto vista = new VentanaConcierto(); + + } + +} +