Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package paintbasico2d; import Dibujo.UserShape; import Sonido.VentanaInternaGrabacion; import Sonido.VentanaInternaReproductor; import Video.VentanaInternaCamara; import Video.VentanaInternaJMFPlayer; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Dimension; import java.awt.GradientPaint; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Point; import java.awt.Toolkit; import java.awt.color.ColorSpace; import java.awt.color.ICC_ColorSpace; import java.awt.color.ICC_Profile; import java.awt.color.ICC_ProfileGray; import java.awt.event.WindowEvent; import java.awt.geom.AffineTransform; import java.awt.image.AffineTransformOp; import java.awt.image.BandCombineOp; import java.awt.image.BufferedImage; import java.awt.image.ColorConvertOp; import java.awt.image.ConvolveOp; import java.awt.image.Kernel; import java.awt.image.LookupOp; import java.awt.image.LookupTable; import java.awt.image.RescaleOp; import java.awt.image.ShortLookupTable; import java.awt.image.WritableRaster; import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; import java.io.IOException; import java.net.URL; import java.util.Random; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.media.Buffer; import javax.media.CannotRealizeException; import javax.media.Manager; import javax.media.MediaLocator; import javax.media.NoPlayerException; import javax.media.Player; import javax.media.control.FrameGrabbingControl; import javax.media.format.VideoFormat; import javax.media.util.BufferToImage; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileNameExtensionFilter; import org.apache.commons.io.*; import sm.image.ThresholdOp; /** *Clase del programa Principal en la que salen todas las opciones del programa, esta se instanciar solo una vez * * @author Angel */ public class VentanaPrincipal extends javax.swing.JFrame { /** * Creates new form VentanaPrincipal */ public VentanaPrincipal() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ BufferedImage img = null; private FileNameExtensionFilter filter = new FileNameExtensionFilter("Archivo de Sonido aceptado", "wav"); private FileNameExtensionFilter filterImg = new FileNameExtensionFilter("Archivos aceptados de imgenes", "png", "jpg"); private FileNameExtensionFilter filterImgJPG = new FileNameExtensionFilter("*.jpg", "jpg", "JPG"); private FileNameExtensionFilter filterImgPNG = new FileNameExtensionFilter("*.png", "png", "PNG"); private FileNameExtensionFilter filterVideo = new FileNameExtensionFilter("Arcivos de Video aceptado", "avi"); private VentanaInternaJMFPlayer video; private VentanaInternaCamara camara; @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { buttonGroup1 = new javax.swing.ButtonGroup(); jMenu3 = new javax.swing.JMenu(); jMenuItem2 = new javax.swing.JMenuItem(); buttonGroupRelleno = new javax.swing.ButtonGroup(); buttonGroupDiscontinuidad = new javax.swing.ButtonGroup(); jPanelAbajo = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel(); jPanelColor = new javax.swing.JPanel(); jButtonRojo = new javax.swing.JButton(); jButtonAzul = new javax.swing.JButton(); jButtonNegro = new javax.swing.JButton(); jButtonBlanco = new javax.swing.JButton(); jButtonAmarillo = new javax.swing.JButton(); jButtonVerde = new javax.swing.JButton(); jButtonColorDiferente = new javax.swing.JButton(); jPanelGrosor = new javax.swing.JPanel(); jSpinner1 = new javax.swing.JSpinner(); jPanelRellenoEditar = new javax.swing.JPanel(); jCheckBoxEditar = new javax.swing.JCheckBox(); jRadioButtonSinRelleno = new javax.swing.JRadioButton(); jRadioButtonConRelleno = new javax.swing.JRadioButton(); jRadioButtonDegradadoHorizontal = new javax.swing.JRadioButton(); jRadioButtonContinua = new javax.swing.JRadioButton(); jRadioButtonDiscontinua = new javax.swing.JRadioButton(); jRadioButtonDegradadoVertical = new javax.swing.JRadioButton(); jPanelBrilloFiltro = new javax.swing.JPanel(); jComboBox2 = new javax.swing.JComboBox(); jSliderBrillo = new javax.swing.JSlider(); jPanelContraste = new javax.swing.JPanel(); jButton4 = new javax.swing.JButton(); jButton5 = new javax.swing.JButton(); jButton6 = new javax.swing.JButton(); jPanelRotacion = new javax.swing.JPanel(); jSliderRotacion = new javax.swing.JSlider(); jButton180grados = new javax.swing.JButton(); jButton270grados = new javax.swing.JButton(); jButton90grados = new javax.swing.JButton(); jPanelEscala = new javax.swing.JPanel(); jButtonAgrandar = new javax.swing.JButton(); jButtonAchicar = new javax.swing.JButton(); jPanel2 = new javax.swing.JPanel(); jButtonDegradado1 = new javax.swing.JButton(); jButtonDegradado2 = new javax.swing.JButton(); jPanel3 = new javax.swing.JPanel(); UmbralGrisSlider = new javax.swing.JSlider(); UmbralColorSlider = new javax.swing.JSlider(); jLabelBarraEstado = new javax.swing.JLabel(); escritorio = new javax.swing.JDesktopPane(); jToolBarPintar = new javax.swing.JToolBar(); jToggleButtonPunto = new javax.swing.JToggleButton(); jToggleButtonLinea = new javax.swing.JToggleButton(); jToggleButtonRectangulo = new javax.swing.JToggleButton(); jToggleButtonElipse = new javax.swing.JToggleButton(); jToggleButtonCUrva = new javax.swing.JToggleButton(); jToggleButtonTrazoLibre = new javax.swing.JToggleButton(); jMenuBar1 = new javax.swing.JMenuBar(); jMenuArchivo = new javax.swing.JMenu(); jMenuItemAbrir = new javax.swing.JMenuItem(); jMenuItemGrabar_Sonido = new javax.swing.JMenuItem(); jMenuImagen = new javax.swing.JMenu(); jMenuItemNuevoImagen = new javax.swing.JMenuItem(); jMenuItemGuardarImagen = new javax.swing.JMenuItem(); jMenu2 = new javax.swing.JMenu(); jMenuItemCapturarVideo = new javax.swing.JMenuItem(); jMenuItem1 = new javax.swing.JMenuItem(); jMenuEdicion = new javax.swing.JMenu(); jCheckBoxMenuItemOcultaBarraEstado = new javax.swing.JCheckBoxMenuItem(); jMenu1 = new javax.swing.JMenu(); jMenuItemAbrirWebCam = new javax.swing.JMenuItem(); jMenuItemCapturarWebCam = new javax.swing.JMenuItem(); jMenu5 = new javax.swing.JMenu(); duplicar = new javax.swing.JMenuItem(); jSeparator1 = new javax.swing.JPopupMenu.Separator(); Negativo = new javax.swing.JMenuItem(); EscalaGrises = new javax.swing.JMenuItem(); jMenuItem3 = new javax.swing.JMenuItem(); jMenu4 = new javax.swing.JMenu(); jMenuItemAcerca = new javax.swing.JMenuItem(); jMenu3.setText("jMenu3"); jMenuItem2.setText("jMenuItem2"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Evaluacion Sistemas Multimedia"); setForeground(java.awt.Color.gray); setIconImage(getIconImage()); jPanelAbajo.setLayout(new java.awt.BorderLayout()); jPanelColor.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Color Borde", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); jButtonRojo.setBackground(java.awt.Color.red); jButtonRojo.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonRojoMouseClicked(evt); } }); jButtonAzul.setBackground(java.awt.Color.blue); jButtonAzul.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonAzulMouseClicked(evt); } }); jButtonNegro.setBackground(new java.awt.Color(0, 0, 0)); jButtonNegro.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonNegroMouseClicked(evt); } }); jButtonBlanco.setBackground(new java.awt.Color(255, 255, 255)); jButtonBlanco.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonBlancoMouseClicked(evt); } }); jButtonAmarillo.setBackground(java.awt.Color.yellow); jButtonAmarillo.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonAmarilloMouseClicked(evt); } }); jButtonVerde.setBackground(java.awt.Color.green); jButtonVerde.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { jButtonVerdeMouseClicked(evt); } }); jButtonColorDiferente.setText("Color Relleno"); jButtonColorDiferente.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonColorDiferenteActionPerformed(evt); } }); javax.swing.GroupLayout jPanelColorLayout = new javax.swing.GroupLayout(jPanelColor); jPanelColor.setLayout(jPanelColorLayout); jPanelColorLayout.setHorizontalGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelColorLayout.createSequentialGroup().addContainerGap().addGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonColorDiferente, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanelColorLayout.createSequentialGroup().addGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButtonBlanco, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jButtonNegro, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelColorLayout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonRojo, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelColorLayout.createSequentialGroup().addGap(7, 7, 7) .addComponent(jButtonAmarillo, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonVerde, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonAzul, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 0, Short.MAX_VALUE))) .addContainerGap())); jPanelColorLayout.setVerticalGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelColorLayout.createSequentialGroup().addContainerGap() .addGroup(jPanelColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonAzul, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonNegro, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonRojo, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanelColorLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jButtonAmarillo, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonVerde, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonBlanco, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonColorDiferente).addContainerGap())); jPanelGrosor.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Grosor", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION)); jSpinner1.setModel(new javax.swing.SpinnerNumberModel(1, 1, 15, 1)); jSpinner1.setMinimumSize(new java.awt.Dimension(50, 20)); jSpinner1.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jSpinner1StateChanged(evt); } }); jPanelGrosor.add(jSpinner1); jPanelRellenoEditar.setBorder(javax.swing.BorderFactory.createTitledBorder("Zona Editable")); jCheckBoxEditar.setText("Editar"); jCheckBoxEditar.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jCheckBoxEditarStateChanged(evt); } }); buttonGroupRelleno.add(jRadioButtonSinRelleno); jRadioButtonSinRelleno.setText("Sin relleno"); jRadioButtonSinRelleno.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonSinRellenoActionPerformed(evt); } }); buttonGroupRelleno.add(jRadioButtonConRelleno); jRadioButtonConRelleno.setText("Relleno 1 color"); jRadioButtonConRelleno.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jRadioButtonConRellenoStateChanged(evt); } }); jRadioButtonConRelleno.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonConRellenoActionPerformed(evt); } }); buttonGroupRelleno.add(jRadioButtonDegradadoHorizontal); jRadioButtonDegradadoHorizontal.setText("Degradado horizontal"); jRadioButtonDegradadoHorizontal.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonDegradadoHorizontalActionPerformed(evt); } }); buttonGroupDiscontinuidad.add(jRadioButtonContinua); jRadioButtonContinua.setText("Continua"); jRadioButtonContinua.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonContinuaActionPerformed(evt); } }); buttonGroupDiscontinuidad.add(jRadioButtonDiscontinua); jRadioButtonDiscontinua.setText("Discontinua"); jRadioButtonDiscontinua.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jRadioButtonDiscontinuaStateChanged(evt); } }); jRadioButtonDiscontinua.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonDiscontinuaActionPerformed(evt); } }); buttonGroupRelleno.add(jRadioButtonDegradadoVertical); jRadioButtonDegradadoVertical.setText("Degradado Vertical"); jRadioButtonDegradadoVertical.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jRadioButtonDegradadoVerticalActionPerformed(evt); } }); javax.swing.GroupLayout jPanelRellenoEditarLayout = new javax.swing.GroupLayout(jPanelRellenoEditar); jPanelRellenoEditar.setLayout(jPanelRellenoEditarLayout); jPanelRellenoEditarLayout.setHorizontalGroup(jPanelRellenoEditarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRellenoEditarLayout.createSequentialGroup() .addComponent(jCheckBoxEditar, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanelRellenoEditarLayout.createSequentialGroup() .addGroup(jPanelRellenoEditarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jRadioButtonContinua, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButtonDiscontinua)) .addGap(18, 18, 18) .addGroup(jPanelRellenoEditarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jRadioButtonSinRelleno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButtonConRelleno, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jRadioButtonDegradadoHorizontal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanelRellenoEditarLayout.createSequentialGroup() .addComponent(jRadioButtonDegradadoVertical).addGap(0, 0, Short.MAX_VALUE))) .addGap(40, 40, 40))); jPanelRellenoEditarLayout.setVerticalGroup(jPanelRellenoEditarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRellenoEditarLayout.createSequentialGroup().addComponent(jCheckBoxEditar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanelRellenoEditarLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelRellenoEditarLayout.createSequentialGroup() .addComponent(jRadioButtonContinua) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButtonDiscontinua)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelRellenoEditarLayout.createSequentialGroup() .addComponent(jRadioButtonSinRelleno) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButtonConRelleno) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButtonDegradadoHorizontal) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jRadioButtonDegradadoVertical))))); jPanelBrilloFiltro.setBorder(javax.swing.BorderFactory.createTitledBorder("Brillo / Filtro")); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Emborronamiento media", "Emborronamiento binomial", "Enfoque", "Relieve", "Detector de fronteras laplaciano" })); jComboBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2ActionPerformed(evt); } }); jSliderBrillo.setMaximum(200); jSliderBrillo.setMinimum(-200); jSliderBrillo.setToolTipText(""); jSliderBrillo.setValue(0); jSliderBrillo.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jSliderBrilloStateChanged(evt); } }); jSliderBrillo.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jSliderBrilloFocusLost(evt); } }); javax.swing.GroupLayout jPanelBrilloFiltroLayout = new javax.swing.GroupLayout(jPanelBrilloFiltro); jPanelBrilloFiltro.setLayout(jPanelBrilloFiltroLayout); jPanelBrilloFiltroLayout.setHorizontalGroup(jPanelBrilloFiltroLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelBrilloFiltroLayout.createSequentialGroup() .addComponent(jSliderBrillo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) .addGroup(jPanelBrilloFiltroLayout.createSequentialGroup().addContainerGap() .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanelBrilloFiltroLayout.setVerticalGroup(jPanelBrilloFiltroLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelBrilloFiltroLayout .createSequentialGroup().addContainerGap() .addComponent(jSliderBrillo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 11, Short.MAX_VALUE) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); jPanelContraste.setBorder(javax.swing.BorderFactory.createTitledBorder("Contraste")); jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/contraste.png"))); // NOI18N jButton4.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/iluminar.png"))); // NOI18N jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); } }); jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/oscurecer.png"))); // NOI18N jButton6.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton6ActionPerformed(evt); } }); javax.swing.GroupLayout jPanelContrasteLayout = new javax.swing.GroupLayout(jPanelContraste); jPanelContraste.setLayout(jPanelContrasteLayout); jPanelContrasteLayout.setHorizontalGroup(jPanelContrasteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelContrasteLayout.createSequentialGroup().addContainerGap() .addGroup(jPanelContrasteLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) .addContainerGap(24, Short.MAX_VALUE))); jPanelContrasteLayout.setVerticalGroup( jPanelContrasteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelContrasteLayout.createSequentialGroup().addContainerGap() .addComponent(jButton4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton5) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton6))); jPanelRotacion.setBorder(javax.swing.BorderFactory.createTitledBorder("Rotacin")); jSliderRotacion.setMajorTickSpacing(90); jSliderRotacion.setMaximum(360); jSliderRotacion.setPaintTicks(true); jSliderRotacion.setToolTipText(""); jSliderRotacion.setValue(180); jSliderRotacion.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jSliderRotacionStateChanged(evt); } }); jSliderRotacion.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { jSliderRotacionFocusLost(evt); } }); jButton180grados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/rotacion180.png"))); // NOI18N jButton180grados.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton180gradosActionPerformed(evt); } }); jButton270grados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/rotacion270.png"))); // NOI18N jButton270grados.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton270gradosActionPerformed(evt); } }); jButton90grados.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/rotacion90.png"))); // NOI18N jButton90grados.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton90gradosActionPerformed(evt); } }); javax.swing.GroupLayout jPanelRotacionLayout = new javax.swing.GroupLayout(jPanelRotacion); jPanelRotacion.setLayout(jPanelRotacionLayout); jPanelRotacionLayout.setHorizontalGroup( jPanelRotacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRotacionLayout.createSequentialGroup().addContainerGap() .addComponent(jButton180grados) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton270grados) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton90grados) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelRotacionLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jSliderRotacion, javax.swing.GroupLayout.PREFERRED_SIZE, 177, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(33, 33, 33))); jPanelRotacionLayout.setVerticalGroup(jPanelRotacionLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelRotacionLayout.createSequentialGroup().addGap(25, 25, 25) .addComponent(jSliderRotacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup( jPanelRotacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButton90grados, javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(jPanelRotacionLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton180grados).addComponent(jButton270grados))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanelEscala.setBorder(javax.swing.BorderFactory.createTitledBorder("Escala")); jPanelEscala.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { jPanelEscalaMouseEntered(evt); } public void mouseExited(java.awt.event.MouseEvent evt) { jPanelEscalaMouseExited(evt); } }); jButtonAgrandar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/aumentar.png"))); // NOI18N jButtonAgrandar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { jButtonAgrandarMouseEntered(evt); } }); jButtonAgrandar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonAgrandarActionPerformed(evt); } }); jButtonAchicar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/disminuir.png"))); // NOI18N jButtonAchicar.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt) { jButtonAchicarMouseEntered(evt); } }); jButtonAchicar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonAchicarActionPerformed(evt); } }); javax.swing.GroupLayout jPanelEscalaLayout = new javax.swing.GroupLayout(jPanelEscala); jPanelEscala.setLayout(jPanelEscalaLayout); jPanelEscalaLayout.setHorizontalGroup(jPanelEscalaLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelEscalaLayout.createSequentialGroup() .addGroup(jPanelEscalaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonAgrandar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jButtonAchicar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(0, 14, Short.MAX_VALUE))); jPanelEscalaLayout .setVerticalGroup(jPanelEscalaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelEscalaLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButtonAgrandar) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonAchicar))); jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Color Degradado")); jButtonDegradado1.setText("Deg. 1"); jButtonDegradado1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonDegradado1ActionPerformed(evt); } }); jButtonDegradado2.setText("Deg. 2"); jButtonDegradado2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButtonDegradado2ActionPerformed(evt); } }); javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); jPanel2.setLayout(jPanel2Layout); jPanel2Layout.setHorizontalGroup(jPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap() .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jButtonDegradado1).addComponent(jButtonDegradado2)) .addContainerGap(13, Short.MAX_VALUE))); jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel2Layout.createSequentialGroup().addComponent(jButtonDegradado1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButtonDegradado2).addGap(0, 0, Short.MAX_VALUE))); jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Umbralizacion")); UmbralGrisSlider.setBorder(javax.swing.BorderFactory.createTitledBorder("Grises")); UmbralGrisSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { UmbralGrisSliderStateChanged(evt); } }); UmbralGrisSlider.addFocusListener(new java.awt.event.FocusAdapter() { public void focusLost(java.awt.event.FocusEvent evt) { UmbralGrisSliderFocusLost(evt); } }); UmbralColorSlider.setBorder(javax.swing.BorderFactory.createTitledBorder("Color")); UmbralColorSlider.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { UmbralColorSliderStateChanged(evt); } }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel3Layout.setHorizontalGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE).addGroup(jPanel3Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(UmbralGrisSlider, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(UmbralColorSlider, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))); jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel3Layout.createSequentialGroup() .addComponent(UmbralGrisSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(UmbralColorSlider, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE))); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(18, 18, 18) .addComponent(jPanelColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanelGrosor, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanelRellenoEditar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanelBrilloFiltro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanelContraste, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanelRotacion, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanelEscala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(31, 31, 31))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup().addGap(0, 0, 0).addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jPanelEscala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7).addComponent(jPanelGrosor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jPanelRellenoEditar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanelContraste, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanelRotacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jPanelColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(jPanelBrilloFiltro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGap(0, 0, Short.MAX_VALUE))); jPanelAbajo.add(jPanel1, java.awt.BorderLayout.CENTER); jLabelBarraEstado.setText("Label"); jLabelBarraEstado .setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); jPanelAbajo.add(jLabelBarraEstado, java.awt.BorderLayout.SOUTH); getContentPane().add(jPanelAbajo, java.awt.BorderLayout.PAGE_END); javax.swing.GroupLayout escritorioLayout = new javax.swing.GroupLayout(escritorio); escritorio.setLayout(escritorioLayout); escritorioLayout.setHorizontalGroup(escritorioLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 1160, Short.MAX_VALUE)); escritorioLayout.setVerticalGroup(escritorioLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 322, Short.MAX_VALUE)); getContentPane().add(escritorio, java.awt.BorderLayout.CENTER); jToolBarPintar.setRollover(true); buttonGroup1.add(jToggleButtonPunto); jToggleButtonPunto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Lapiz.gif"))); // NOI18N jToggleButtonPunto.setFocusable(false); jToggleButtonPunto.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jToggleButtonPunto.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToggleButtonPunto.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButtonPuntoActionPerformed(evt); } }); jToolBarPintar.add(jToggleButtonPunto); buttonGroup1.add(jToggleButtonLinea); jToggleButtonLinea.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Linea.gif"))); // NOI18N jToggleButtonLinea.setFocusable(false); jToggleButtonLinea.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jToggleButtonLinea.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToggleButtonLinea.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButtonLineaActionPerformed(evt); } }); jToolBarPintar.add(jToggleButtonLinea); buttonGroup1.add(jToggleButtonRectangulo); jToggleButtonRectangulo .setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Rectangulo.gif"))); // NOI18N jToggleButtonRectangulo.setFocusable(false); jToggleButtonRectangulo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jToggleButtonRectangulo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToggleButtonRectangulo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButtonRectanguloActionPerformed(evt); } }); jToolBarPintar.add(jToggleButtonRectangulo); buttonGroup1.add(jToggleButtonElipse); jToggleButtonElipse.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Ovalo.gif"))); // NOI18N jToggleButtonElipse.setFocusable(false); jToggleButtonElipse.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jToggleButtonElipse.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToggleButtonElipse.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButtonElipseActionPerformed(evt); } }); jToolBarPintar.add(jToggleButtonElipse); buttonGroup1.add(jToggleButtonCUrva); jToggleButtonCUrva.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Curva.gif"))); // NOI18N jToggleButtonCUrva.setFocusable(false); jToggleButtonCUrva.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jToggleButtonCUrva.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToggleButtonCUrva.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButtonCUrvaActionPerformed(evt); } }); jToolBarPintar.add(jToggleButtonCUrva); buttonGroup1.add(jToggleButtonTrazoLibre); jToggleButtonTrazoLibre.setIcon(new javax.swing.ImageIcon(getClass().getResource("/iconos/Libre.gif"))); // NOI18N jToggleButtonTrazoLibre.setFocusable(false); jToggleButtonTrazoLibre.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jToggleButtonTrazoLibre.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); jToggleButtonTrazoLibre.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jToggleButtonTrazoLibreActionPerformed(evt); } }); jToolBarPintar.add(jToggleButtonTrazoLibre); getContentPane().add(jToolBarPintar, java.awt.BorderLayout.NORTH); jMenuArchivo.setText("Archivo"); jMenuItemAbrir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemAbrir.setText("Abrir"); jMenuItemAbrir.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemAbrirActionPerformed(evt); } }); jMenuArchivo.add(jMenuItemAbrir); jMenuItemGrabar_Sonido.setText("Grabar"); jMenuItemGrabar_Sonido.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemGrabar_SonidoActionPerformed(evt); } }); jMenuArchivo.add(jMenuItemGrabar_Sonido); jMenuImagen.setText("Imagen"); jMenuItemNuevoImagen.setText("Nuevo Imagen"); jMenuItemNuevoImagen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemNuevoImagenActionPerformed(evt); } }); jMenuImagen.add(jMenuItemNuevoImagen); jMenuItemGuardarImagen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK)); jMenuItemGuardarImagen.setText("Guardar Imagen"); jMenuItemGuardarImagen.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemGuardarImagenActionPerformed(evt); } }); jMenuImagen.add(jMenuItemGuardarImagen); jMenuArchivo.add(jMenuImagen); jMenu2.setText("Video"); jMenuItemCapturarVideo.setText("Capturar"); jMenuItemCapturarVideo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemCapturarVideoActionPerformed(evt); } }); jMenu2.add(jMenuItemCapturarVideo); jMenuArchivo.add(jMenu2); jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK)); jMenuItem1.setText("Salir"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); jMenuArchivo.add(jMenuItem1); jMenuBar1.add(jMenuArchivo); jMenuEdicion.setText("Edicin"); jCheckBoxMenuItemOcultaBarraEstado.setSelected(true); jCheckBoxMenuItemOcultaBarraEstado.setText("Ocultar Barra de Estado"); jCheckBoxMenuItemOcultaBarraEstado.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { jCheckBoxMenuItemOcultaBarraEstadoStateChanged(evt); } }); jMenuEdicion.add(jCheckBoxMenuItemOcultaBarraEstado); jMenuBar1.add(jMenuEdicion); jMenu1.setText("Camara"); jMenuItemAbrirWebCam.setText("Abrir"); jMenuItemAbrirWebCam.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemAbrirWebCamActionPerformed(evt); } }); jMenu1.add(jMenuItemAbrirWebCam); jMenuItemCapturarWebCam.setText("Capturar"); jMenuItemCapturarWebCam.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemCapturarWebCamActionPerformed(evt); } }); jMenu1.add(jMenuItemCapturarWebCam); jMenuBar1.add(jMenu1); jMenu5.setText("Imagen"); duplicar.setText("Duplicar"); duplicar.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { duplicarActionPerformed(evt); } }); jMenu5.add(duplicar); jMenu5.add(jSeparator1); Negativo.setText("Negativo"); Negativo.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { NegativoActionPerformed(evt); } }); jMenu5.add(Negativo); EscalaGrises.setText("Escala de Grises"); EscalaGrises.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { EscalaGrisesActionPerformed(evt); } }); jMenu5.add(EscalaGrises); jMenuItem3.setText("Sobel"); jMenuItem3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem3ActionPerformed(evt); } }); jMenu5.add(jMenuItem3); jMenuBar1.add(jMenu5); jMenu4.setText("Ayuda"); jMenuItemAcerca.setText("Acerca de ..."); jMenuItemAcerca.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItemAcercaActionPerformed(evt); } }); jMenu4.add(jMenuItemAcerca); jMenuBar1.add(jMenu4); setJMenuBar(jMenuBar1); pack(); }// </editor-fold>//GEN-END:initComponents private void jMenuItemNuevoImagenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemNuevoImagenActionPerformed int x, y; x = (int) (Math.random() * (20 - 200) + 200); y = (int) (Math.random() * (20 - 200) + 200); VentanaInterna vi = new VentanaInterna(); escritorio.add(vi); vi.setVisible(true); vi.setLocation(x, y); }//GEN-LAST:event_jMenuItemNuevoImagenActionPerformed private void jCheckBoxMenuItemOcultaBarraEstadoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBoxMenuItemOcultaBarraEstadoStateChanged this.jLabelBarraEstado.setVisible(this.jCheckBoxMenuItemOcultaBarraEstado.isSelected()); }//GEN-LAST:event_jCheckBoxMenuItemOcultaBarraEstadoStateChanged private void jButtonNegroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonNegroMouseClicked VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetColor(Color.black); } vi = (VentanaInterna) this.escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape shape = vi.getLienzo().getSelectedShape(); if (shape != null) { //shape.setisRelleno(true); // shape.setisGradiente(false); shape.setColorRelleno(Color.black); //shape.setColorTrazo(Color.RED); vi.repaint(); } } //repaint(); }//GEN-LAST:event_jButtonNegroMouseClicked private void jButtonBlancoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonBlancoMouseClicked VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetColor(Color.WHITE); } vi = (VentanaInterna) this.escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape shape = vi.getLienzo().getSelectedShape(); if (shape != null) { // shape.setisRelleno(true); // shape.setisGradiente(false); shape.setColorRelleno(Color.WHITE); //shape.setColorTrazo(Color.RED); vi.repaint(); } } //repaint(); }//GEN-LAST:event_jButtonBlancoMouseClicked private void jButtonRojoMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonRojoMouseClicked VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetColor(Color.red); } vi = (VentanaInterna) this.escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape shape = vi.getLienzo().getSelectedShape(); if (shape != null) { // shape.setisRelleno(true); // shape.setisGradiente(false); shape.setColorRelleno(Color.RED); //shape.setColorTrazo(Color.RED); vi.repaint(); } } //repaint(); }//GEN-LAST:event_jButtonRojoMouseClicked private void jButtonAzulMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAzulMouseClicked VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetColor(Color.blue); } vi = (VentanaInterna) this.escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape shape = vi.getLienzo().getSelectedShape(); if (shape != null) { // shape.setisRelleno(true); // shape.setisGradiente(false); shape.setColorRelleno(Color.blue); //shape.setColorTrazo(Color.RED); vi.repaint(); } } //repaint(); }//GEN-LAST:event_jButtonAzulMouseClicked private void jButtonAmarilloMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAmarilloMouseClicked VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetColor(Color.yellow); } vi = (VentanaInterna) this.escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape shape = vi.getLienzo().getSelectedShape(); if (shape != null) { // shape.setisRelleno(true); // shape.setisGradiente(false); shape.setColorRelleno(Color.yellow); //shape.setColorTrazo(Color.RED); vi.repaint(); } } //repaint(); }//GEN-LAST:event_jButtonAmarilloMouseClicked private void jButtonVerdeMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonVerdeMouseClicked VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetColor(Color.green); } vi = (VentanaInterna) this.escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape shape = vi.getLienzo().getSelectedShape(); if (shape != null) { // shape.setisRelleno(true); //shape.setisGradiente(false); shape.setColorRelleno(Color.green); //shape.setColorTrazo(Color.RED); vi.repaint(); } } //repaint(); }//GEN-LAST:event_jButtonVerdeMouseClicked private void jToggleButtonPuntoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonPuntoActionPerformed VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetForma(0); } this.jLabelBarraEstado.setText("Punto"); }//GEN-LAST:event_jToggleButtonPuntoActionPerformed private void jToggleButtonLineaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonLineaActionPerformed VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetForma(1); } this.jLabelBarraEstado.setText("Linea"); }//GEN-LAST:event_jToggleButtonLineaActionPerformed private void jToggleButtonRectanguloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonRectanguloActionPerformed VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetForma(2); } this.jLabelBarraEstado.setText("Rectangulo"); }//GEN-LAST:event_jToggleButtonRectanguloActionPerformed private void jToggleButtonElipseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonElipseActionPerformed VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetForma(3); } this.jLabelBarraEstado.setText("Elipse"); }//GEN-LAST:event_jToggleButtonElipseActionPerformed private void jMenuItemGuardarImagenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemGuardarImagenActionPerformed VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame(); BufferedImage img = vi.getLienzo().getImage(); JFileChooser dlg = new JFileChooser(); dlg.setFileFilter(filterImgJPG); dlg.setFileFilter(filterImgPNG); int resp = dlg.showSaveDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { try { File f = dlg.getSelectedFile(); File newFile = null; vi.getLienzo().volcarImg(img); newFile = new File(f.getAbsolutePath() + ".jpg"); ImageIO.write(img, "jpg", newFile); } catch (Exception ex) { System.err.println("Error al guardar la imagen."); } } }//GEN-LAST:event_jMenuItemGuardarImagenActionPerformed private void jCheckBoxEditarStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jCheckBoxEditarStateChanged //Lienzo.SetEditar(this.jCheckBoxEditar.isSelected()); VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetEditar(this.jCheckBoxEditar.isSelected()); } }//GEN-LAST:event_jCheckBoxEditarStateChanged private void jSpinner1StateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSpinner1StateChanged VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); float a = (Integer) this.jSpinner1.getValue(); if (vi.getLienzo().getEditar()) { UserShape s = vi.getLienzo().getSelectedShape(); if (s != null) { s.setStroke(a); } } else { vi.getLienzo().SetStroke(a); } repaint(); } // Lienzo.SetStroke(new BasicStroke(((Integer)this.jSpinner1.getValue()).intValue())); repaint(); }//GEN-LAST:event_jSpinner1StateChanged private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed int index = jComboBox2.getSelectedIndex(); Kernel k; VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (ImgSource != null) { try { switch (index) { case 0: k = KernelProducer.createKernel(KernelProducer.TYPE_MEDIA_3x3); break; case 1: k = KernelProducer.createKernel(KernelProducer.TYPE_BINOMIAL_3x3); break; case 2: k = KernelProducer.createKernel(KernelProducer.TYPE_ENFOQUE_3x3); break; case 3: k = KernelProducer.createKernel(KernelProducer.TYPE_RELIEVE_3x3); break; case 4: k = KernelProducer.createKernel(KernelProducer.TYPE_LAPLACIANA_3x3); break; default: k = null; } ConvolveOp cop = new ConvolveOp(k); BufferedImage imgdest = cop.filter(ImgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); } } } }//GEN-LAST:event_jComboBox2ActionPerformed private void jSliderBrilloStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSliderBrilloStateChanged VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (img == null) img = ImgSource; if (ImgSource != null) { try { float slider = jSliderBrillo.getValue(); RescaleOp rop = new RescaleOp(1.0F, slider, null); BufferedImage imgdest = rop.filter(this.img, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); } } } }//GEN-LAST:event_jSliderBrilloStateChanged private void jSliderBrilloFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jSliderBrilloFocusLost img = null; }//GEN-LAST:event_jSliderBrilloFocusLost BufferedImage convertImageType(BufferedImage img, int type) { if (img == null) return null; BufferedImage imgOut = new BufferedImage(img.getWidth(), img.getHeight(), type); Graphics2D g2d = imgOut.createGraphics(); g2d.drawImage(img, 0, 0, null); return imgOut; } private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); BufferedImage image = convertImageType(ImgSource, BufferedImage.TYPE_INT_RGB); if (ImgSource != null) { try { LookupTable It = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_SFUNCION); LookupOp lop = new LookupOp(It, null); BufferedImage imgdest = lop.filter(image, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("Error"); } } } }//GEN-LAST:event_jButton4ActionPerformed private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); BufferedImage image = convertImageType(ImgSource, BufferedImage.TYPE_INT_RGB); if (ImgSource != null) { try { LookupTable It = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_LOGARITHM); LookupOp lop = new LookupOp(It, null); BufferedImage imgdest = lop.filter(image, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("Error"); } } } }//GEN-LAST:event_jButton5ActionPerformed private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); BufferedImage image = convertImageType(ImgSource, BufferedImage.TYPE_INT_RGB); if (ImgSource != null) { try { LookupTable It = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_POWER); LookupOp lop = new LookupOp(It, null); BufferedImage imgdest = lop.filter(image, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("Error"); } } } }//GEN-LAST:event_jButton6ActionPerformed private void jButtonAgrandarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAgrandarActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (ImgSource != null) { AffineTransform at = AffineTransform.getScaleInstance(1.25, 1.25); try { AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage imgdest = atop.filter(ImgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("error"); } } } }//GEN-LAST:event_jButtonAgrandarActionPerformed private void jButtonAchicarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonAchicarActionPerformed VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (ImgSource != null) { AffineTransform at = AffineTransform.getScaleInstance(0.75, 0.75); try { AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage imgdest = atop.filter(ImgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("error"); } } } // TODO add your handling code here: }//GEN-LAST:event_jButtonAchicarActionPerformed private void jButton180gradosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton180gradosActionPerformed VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (ImgSource != null) { double r = Math.toRadians(180); Point p = new Point(ImgSource.getWidth() / 2, ImgSource.getHeight() / 2); AffineTransform at = AffineTransform.getRotateInstance(r, p.x, p.y); try { AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage imgdest = atop.filter(ImgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("error"); } } } }//GEN-LAST:event_jButton180gradosActionPerformed private void jButton270gradosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton270gradosActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (ImgSource != null) { double r = Math.toRadians(270); Point p = new Point(ImgSource.getWidth() / 2, ImgSource.getHeight() / 2); AffineTransform at = AffineTransform.getRotateInstance(r, p.x, p.y); try { AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage imgdest = atop.filter(ImgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("error"); } } } }//GEN-LAST:event_jButton270gradosActionPerformed private void jButton90gradosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton90gradosActionPerformed VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (ImgSource != null) { double r = Math.toRadians(90); Point p = new Point(ImgSource.getWidth() / 2, ImgSource.getHeight() / 2); AffineTransform at = AffineTransform.getRotateInstance(r, p.x, p.y); try { AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage imgdest = atop.filter(ImgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("error"); } } } }//GEN-LAST:event_jButton90gradosActionPerformed private void jSliderRotacionStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jSliderRotacionStateChanged VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (img == null) img = ImgSource; if (ImgSource != null) { try { double r = Math.toRadians(jSliderRotacion.getValue()); Point p = new Point(img.getWidth(null) / 2, img.getWidth(null) / 2); AffineTransform at = AffineTransform.getRotateInstance(r, p.x, p.y); AffineTransformOp atop = new AffineTransformOp(at, AffineTransformOp.TYPE_BILINEAR); BufferedImage imgdest = atop.filter(img, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println("error"); } } } }//GEN-LAST:event_jSliderRotacionStateChanged private void jSliderRotacionFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jSliderRotacionFocusLost // TODO add your handling code here: img = null; }//GEN-LAST:event_jSliderRotacionFocusLost private void jMenuItemGrabar_SonidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemGrabar_SonidoActionPerformed JFileChooser dlg = new JFileChooser(); dlg.setFileFilter(filter); int resp = dlg.showSaveDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { try { File f = dlg.getSelectedFile(); VentanaInternaGrabacion rec = new VentanaInternaGrabacion(f); this.escritorio.add(rec); rec.setTitle(f.getName()); rec.setVisible(true); } catch (Exception ex) { System.err.println("Error"); } } }//GEN-LAST:event_jMenuItemGrabar_SonidoActionPerformed private void jPanelEscalaMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelEscalaMouseEntered this.jLabelBarraEstado.setText("Aumentar o disminuir el tamao de la imagen"); }//GEN-LAST:event_jPanelEscalaMouseEntered private void jPanelEscalaMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanelEscalaMouseExited this.jLabelBarraEstado.setText(" "); }//GEN-LAST:event_jPanelEscalaMouseExited private void jButtonAgrandarMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAgrandarMouseEntered this.jLabelBarraEstado.setText("Aumentar el tamao de la imagen"); }//GEN-LAST:event_jButtonAgrandarMouseEntered private void jButtonAchicarMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButtonAchicarMouseEntered this.jLabelBarraEstado.setText("Disminuir el tamao de la imagen"); }//GEN-LAST:event_jButtonAchicarMouseEntered /** Evento para abrir la webCam del objeto VentanaInternaCamara * * * */ private void jMenuItemAbrirWebCamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAbrirWebCamActionPerformed try { camara = new VentanaInternaCamara(); this.escritorio.add(camara); camara.setTitle("Web Cam"); camara.setVisible(true); camara.play(); } catch (Exception ex) { System.err.println("Error"); } }//GEN-LAST:event_jMenuItemAbrirWebCamActionPerformed /** Evento para capturar la imagen desde la webcam. * * */ private void jMenuItemCapturarWebCamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCapturarWebCamActionPerformed try { VentanaInternaCamara vc = null; VentanaInternaJMFPlayer vj = null; VentanaInterna vi = new VentanaInterna(); if (escritorio.getSelectedFrame() instanceof VentanaInternaJMFPlayer) { vj = (VentanaInternaJMFPlayer) escritorio.getSelectedFrame(); vi.getLienzo().setImage(vj.getFrame()); vi.setBounds(vj.getBounds()); } else { vc = (VentanaInternaCamara) escritorio.getSelectedFrame(); vi.getLienzo().setImage(vc.getFrame()); vi.setBounds(vc.getBounds()); } vi.setTitle("CAPTURA"); vi.setVisible(true); escritorio.add(vi); // } catch (Exception ex) { // System.err.println(ex); JOptionPane.showMessageDialog(null, "Error al hacer la captura " + ex); } }//GEN-LAST:event_jMenuItemCapturarWebCamActionPerformed private void jMenuItemCapturarVideoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemCapturarVideoActionPerformed // TODO add your handling code here: try { VentanaInternaJMFPlayer play = null; BufferedImage img2 = null; VentanaInterna vi; if (escritorio.getSelectedFrame() instanceof VentanaInternaJMFPlayer) play = (VentanaInternaJMFPlayer) (escritorio.getSelectedFrame()); if (play != null) { img2 = getFrame(play.getPlayer()); } vi = new VentanaInterna(); vi.getLienzo().setImage(img2); vi.setSize(img2.getWidth(), img2.getHeight()); this.escritorio.add(vi); vi.setVisible(true); } catch (Exception ex) { // System.err.println(ex); JOptionPane.showMessageDialog(null, "Error al hacer la captura " + ex); } }//GEN-LAST:event_jMenuItemCapturarVideoActionPerformed private void jButtonColorDiferenteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonColorDiferenteActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, "Elegir un color especfico para el Relleno", Color.BLACK); jButtonColorDiferente.setBackground(c); VentanaInterna vi; UserShape shape; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().setColorTrazo(c); } }//GEN-LAST:event_jButtonColorDiferenteActionPerformed private void jToggleButtonCUrvaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonCUrvaActionPerformed VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetForma(4); vi.getLienzo().setControl(1); } this.jLabelBarraEstado.setText("Curva"); }//GEN-LAST:event_jToggleButtonCUrvaActionPerformed private void jMenuItemAbrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAbrirActionPerformed // TODO add your handling code here: JFileChooser dlg = new JFileChooser(); dlg.setFileFilter(filter); dlg.setFileFilter(filterImg); dlg.setFileFilter(filterVideo); dlg.setFileFilter(filterImgJPG); dlg.setFileFilter(filterImgPNG); int resp = dlg.showOpenDialog(this); if (resp == JFileChooser.APPROVE_OPTION) { try { File f = dlg.getSelectedFile(); String extension = FilenameUtils.getExtension(f.getPath()); if ("png".equals(extension) || "PNG".equals(extension) || "jpg".equals(extension) || "JPG".equals(extension)) { BufferedImage img = ImageIO.read(f); VentanaInterna vi = new VentanaInterna(); vi.getLienzo().setImage(img); this.escritorio.add(vi); vi.setPreferredSize(new Dimension(img.getWidth(), img.getHeight())); vi.setTitle(f.getName()); vi.setVisible(true); } else if ("avi".equals(extension)) { VentanaInternaJMFPlayer v = new VentanaInternaJMFPlayer(); URL url = new URL("file:" + f.getAbsolutePath()); this.escritorio.add(v); v.setVisible(true); v.play(url); } else { VentanaInternaReproductor v = new VentanaInternaReproductor(f); this.escritorio.add(v); int x, y; x = (int) (Math.random() * (20 - 200) + 200); y = (int) (Math.random() * (20 - 200) + 200); v.setVisible(true); v.setLocation(x, y); } } catch (Exception ex) { System.err.println("No se ha podido abrir el fichero"); } } }//GEN-LAST:event_jMenuItemAbrirActionPerformed private void jMenuItemAcercaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemAcercaActionPerformed JOptionPane.showMessageDialog(null, "Sistemas Multimedia\nPractica Evaluacion Final\n" + "Versin: 1.0\n" + "Autor: Angel Jimenez de Cisneros Carreo", "Acerca de...", JOptionPane.INFORMATION_MESSAGE); }//GEN-LAST:event_jMenuItemAcercaActionPerformed private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed JOptionPane.showMessageDialog(jMenuImagen, "Gracias por utilizar nuestro programa."); this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING)); }//GEN-LAST:event_jMenuItem1ActionPerformed private void jRadioButtonConRellenoStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jRadioButtonConRellenoStateChanged // TODO add your handling code here: }//GEN-LAST:event_jRadioButtonConRellenoStateChanged private void jRadioButtonDiscontinuaStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jRadioButtonDiscontinuaStateChanged // TODO add your handling code here: }//GEN-LAST:event_jRadioButtonDiscontinuaStateChanged private void jRadioButtonDiscontinuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonDiscontinuaActionPerformed // TODO add your handling code here: VentanaInterna vi; UserShape shape; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { vi.getLienzo().setisContinua(this.jRadioButtonDiscontinua.isSelected()); shape = vi.getLienzo().getSelectedShape(); if (shape != null) shape.setContinua(false); vi.repaint(); } else { vi.getLienzo().setisContinua(false); } } }//GEN-LAST:event_jRadioButtonDiscontinuaActionPerformed private void jRadioButtonContinuaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonContinuaActionPerformed // TODO add your handling code here: VentanaInterna vi; UserShape shape; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { vi.getLienzo().setisContinua(this.jRadioButtonContinua.isSelected()); shape = vi.getLienzo().getSelectedShape(); if (shape != null) shape.setContinua(true); vi.repaint(); } else { vi.getLienzo().setisContinua(true); } } }//GEN-LAST:event_jRadioButtonContinuaActionPerformed private void showError() { JOptionPane.showMessageDialog(null, "Esta opcin solo se puede aplicar a una ventana de imgenes", "Error", JOptionPane.ERROR_MESSAGE); } private void jRadioButtonConRellenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonConRellenoActionPerformed VentanaInterna vi; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape s = vi.getLienzo().getSelectedShape(); if (s != null) { s.setisRelleno(true); s.setisGradiente(false); s.setColorTrazo(jButtonColorDiferente.getBackground()); vi.repaint(); } } else { vi.getLienzo().SetColor(Color.black); vi.getLienzo().SetRelleno(true); vi.getLienzo().SetColor(jButtonColorDiferente.getBackground()); } } // TODO add your handling code here: // VentanaInterna vi; // if(this.escritorio.getSelectedFrame()instanceof VentanaInterna){ // jRadioButtonConRelleno.setEnabled(true); // jRadioButtonConRelleno.setFocusable(true); // vi=(VentanaInterna)escritorio.getSelectedFrame(); // if(vi.getLienzo().getIsGradiente()){ // vi.getLienzo().setIsGradiente(false); // // } // if(vi.getLienzo().getEditar()){ // vi.getLienzo().SetRelleno(true); // } // vi.getLienzo().SetRelleno(true); // repaint(); // }else{ // this.showError(); // } }//GEN-LAST:event_jRadioButtonConRellenoActionPerformed private void jRadioButtonSinRellenoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonSinRellenoActionPerformed VentanaInterna vi; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape s = vi.getLienzo().getSelectedShape(); if (s != null) { s.setRelleno(false); s.setisGradiente(false); vi.repaint(); } } else { vi.getLienzo().SetRelleno(false); } } // TODO add your handling code here: // VentanaInterna vi; // if(this.escritorio.getSelectedFrame()instanceof VentanaInterna){ // jRadioButtonConRelleno.setEnabled(true); // jRadioButtonConRelleno.setFocusable(true); // vi=(VentanaInterna)escritorio.getSelectedFrame(); // if(vi.getLienzo().getIsGradiente()){ // vi.getLienzo().setIsGradiente(false); // } // vi.getLienzo().SetRelleno(false); // repaint(); // }else{ // this.showError(); // } }//GEN-LAST:event_jRadioButtonSinRellenoActionPerformed private void jButtonDegradado1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDegradado1ActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, "Elegir un color especfico para el degradado 1", Color.BLACK); jButtonDegradado1.setBackground(c); // VentanaInterna vi; // UserShape shape; // // if(escritorio.getSelectedFrame()instanceof VentanaInterna){ // vi=(VentanaInterna)escritorio.getSelectedFrame(); // vi.getLienzo().setColorTrazo(c); // } }//GEN-LAST:event_jButtonDegradado1ActionPerformed private void jButtonDegradado2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonDegradado2ActionPerformed // TODO add your handling code here: Color c = JColorChooser.showDialog(this, "Elegir un color especfico para el degradado 2", Color.BLACK); jButtonDegradado2.setBackground(c); // VentanaInterna vi; // UserShape shape; // // if(escritorio.getSelectedFrame()instanceof VentanaInterna){ // vi=(VentanaInterna)escritorio.getSelectedFrame(); // vi.getLienzo().setColorTrazo(c); // } }//GEN-LAST:event_jButtonDegradado2ActionPerformed private void jRadioButtonDegradadoHorizontalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonDegradadoHorizontalActionPerformed // TODO add your handling code here: VentanaInterna vi; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape s = vi.getLienzo().getSelectedShape(); if (s != null) { s.setRelleno(false); s.setisGradiente(true); s.setGradiente(new GradientPaint((float) s.getBounds2D().getX(), 0, this.jButtonDegradado1.getBackground(), (float) s.getBounds2D().getX() + (float) s.getBounds2D().getWidth(), 0, this.jButtonDegradado2.getBackground())); vi.repaint(); } } else { vi.getLienzo().SetRelleno(false); vi.getLienzo().setIsGradiente(true); GradientPaint g = new GradientPaint(0, 0, jButtonDegradado1.getBackground(), vi.getLienzo().getWidth(), 0, jButtonDegradado2.getBackground()); //vi.getLienzo().setGradiente(new GradientPaint(0,0, this.jButtonDegradado1.getBackground(), vi.getLienzo().getWidth(),0,this.jButtonDegradado2.getBackground())); vi.getLienzo().setGradiente(g); } } }//GEN-LAST:event_jRadioButtonDegradadoHorizontalActionPerformed private void jRadioButtonDegradadoVerticalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButtonDegradadoVerticalActionPerformed // TODO add your handling code here: VentanaInterna vi; if (escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi.getLienzo().getEditar()) { UserShape s = vi.getLienzo().getSelectedShape(); if (s != null) { s.setRelleno(false); s.setisGradiente(true); s.setGradiente(new GradientPaint(0, 0, jButtonDegradado1.getBackground(), 0, vi.getLienzo().getHeight(), jButtonDegradado2.getBackground())); vi.repaint(); } } else { vi.getLienzo().SetRelleno(false); vi.getLienzo().setIsGradiente(true); GradientPaint g = new GradientPaint(0, 0, jButtonDegradado1.getBackground(), 0, vi.getLienzo().getHeight(), jButtonDegradado2.getBackground()); //vi.getLienzo().setGradiente(new GradientPaint(0,0, this.jButtonDegradado1.getBackground(), vi.getLienzo().getWidth(),0,this.jButtonDegradado2.getBackground())); vi.getLienzo().setGradiente(g); } } }//GEN-LAST:event_jRadioButtonDegradadoVerticalActionPerformed private void jToggleButtonTrazoLibreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jToggleButtonTrazoLibreActionPerformed // TODO add your handling code here: VentanaInterna vi; if (this.escritorio.getSelectedFrame() instanceof VentanaInterna) { vi = (VentanaInterna) escritorio.getSelectedFrame(); vi.getLienzo().SetForma(5); } this.jLabelBarraEstado.setText("Curva"); }//GEN-LAST:event_jToggleButtonTrazoLibreActionPerformed private void UmbralGrisSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_UmbralGrisSliderStateChanged // TODO add your handling code here: // VentanaInterna vi=(VentanaInterna) escritorio.getSelectedFrame(); // if(vi.getLienzo().getImage()!=null){ // try{ // // ThresholdOp th=new ThresholdOp(UmbralGrisSlider.getValue()); // th.filterGreyLevel(vi.getLienzo().getImage(), imgdest); // vi.getLienzo().setImage(imgdest); // vi.getLienzo().repaint(); // }catch(IllegalArgumentException e){ // System.err.println(e.getLocalizedMessage()); // } // } VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (img == null) img = ImgSource; if (ImgSource != null) { try { int slider = UmbralGrisSlider.getValue(); ThresholdOp thOp = new ThresholdOp(slider); //RescaleOp(1.0F, slider, null); BufferedImage imgdest = thOp.filterGreyLevel(img, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); } } } }//GEN-LAST:event_UmbralGrisSliderStateChanged private void UmbralGrisSliderFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_UmbralGrisSliderFocusLost // TODO add your handling code here: img = null; }//GEN-LAST:event_UmbralGrisSliderFocusLost private void UmbralColorSliderStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_UmbralColorSliderStateChanged // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage ImgSource = vi.getLienzo().getImage(); if (img == null) img = ImgSource; if (ImgSource != null) { try { int slider = UmbralColorSlider.getValue(); UmbralizacionOp um = new UmbralizacionOp(slider); //ThresholdOp thOp= new ThresholdOp(slider); //RescaleOp(1.0F, slider, null); BufferedImage imgdest = um.filter(img, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); } } } }//GEN-LAST:event_UmbralColorSliderStateChanged private void duplicarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_duplicarActionPerformed // TODO add your handling code here: BufferedImage image = null; try { VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame(); image = vi.getLienzo().getImage(); } catch (Exception e) { System.err.println("Error al duplicar la imagen"); } if (image != null) { try { VentanaInterna vi = new VentanaInterna(); vi.getLienzo().setImage(image); this.escritorio.add(vi); vi.setVisible(true); } catch (Exception ex) { System.err.println("Error al duplicar la imagen"); } } }//GEN-LAST:event_duplicarActionPerformed private void NegativoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NegativoActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi != null) { vi.getLienzo().getImage().getType(); if (vi.getLienzo().getImage().getType() != BufferedImage.TYPE_INT_RGB) { BufferedImage img; img = new BufferedImage(vi.getLienzo().getImage().getWidth(), vi.getLienzo().getImage().getHeight(), BufferedImage.TYPE_INT_RGB); Graphics2D g2d = img.createGraphics(); g2d.drawImage(vi.getLienzo().getImage(), 0, 0, null); vi.getLienzo().setImage(img); } if (vi.getLienzo().getImage() != null) { LookupTable lk = LookupTableProducer.createLookupTable(LookupTableProducer.TYPE_NEGATIVE); try { LookupOp l = new LookupOp(lk, null); BufferedImage imgdest = l.filter(vi.getLienzo().getImage(), null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (Exception e) { System.err.println(e); } } } }//GEN-LAST:event_NegativoActionPerformed private void EscalaGrisesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EscalaGrisesActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) escritorio.getSelectedFrame(); if (vi != null) { vi.getLienzo().setImage(vi.getLienzo().getImage()); if (vi.getLienzo().getImage() != null) { ICC_Profile icc = ICC_Profile.getInstance(ColorSpace.CS_GRAY); ColorSpace cs = new ICC_ColorSpace(icc); ColorConvertOp conver = new ColorConvertOp(cs, null); BufferedImage imgdest = conver.filter(vi.getLienzo().getImage(), null); vi.getLienzo().setImage(imgdest); } } repaint(); }//GEN-LAST:event_EscalaGrisesActionPerformed private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed // TODO add your handling code here: VentanaInterna vi = (VentanaInterna) (escritorio.getSelectedFrame()); if (vi != null) { BufferedImage imgSource = vi.getLienzo().getImage(); if (imgSource != null) { try { SobelOp so = new SobelOp(); BufferedImage imgdest = so.filter(imgSource, null); vi.getLienzo().setImage(imgdest); vi.getLienzo().repaint(); } catch (IllegalArgumentException e) { System.err.println(e.getLocalizedMessage()); } } } }//GEN-LAST:event_jMenuItem3ActionPerformed public BufferedImage getFrame(Player player) { FrameGrabbingControl fgc; String claseCtr = "javax.media.control.FrameGrabbingControl "; fgc = (FrameGrabbingControl) player.getControl(claseCtr); Buffer bufferFrame = fgc.grabFrame(); BufferToImage bti; bti = new BufferToImage((VideoFormat) bufferFrame.getFormat()); Image img2 = bti.createImage(bufferFrame); return (BufferedImage) img2; } /** Metodo sobreescrito para cambiar el icono de la imagen de la aplicacion. * * * @return Devuelve el icono a cambiar en la aplicacion */ public Image getIconImage() { //metodo para cambiar el icono de la imagen del programa Image ret = Toolkit.getDefaultToolkit() .getImage(ClassLoader.getSystemResource("iconos/PlayPressed_48x48.png")); return ret; } /** * @param args the command line arguments */ public static void main(String args[]) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(VentanaPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new VentanaPrincipal().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JMenuItem EscalaGrises; private javax.swing.JMenuItem Negativo; private javax.swing.JSlider UmbralColorSlider; private javax.swing.JSlider UmbralGrisSlider; private javax.swing.ButtonGroup buttonGroup1; private javax.swing.ButtonGroup buttonGroupDiscontinuidad; private javax.swing.ButtonGroup buttonGroupRelleno; private javax.swing.JMenuItem duplicar; private javax.swing.JDesktopPane escritorio; private javax.swing.JButton jButton180grados; private javax.swing.JButton jButton270grados; private javax.swing.JButton jButton4; private javax.swing.JButton jButton5; private javax.swing.JButton jButton6; private javax.swing.JButton jButton90grados; private javax.swing.JButton jButtonAchicar; private javax.swing.JButton jButtonAgrandar; private javax.swing.JButton jButtonAmarillo; private javax.swing.JButton jButtonAzul; private javax.swing.JButton jButtonBlanco; private javax.swing.JButton jButtonColorDiferente; private javax.swing.JButton jButtonDegradado1; private javax.swing.JButton jButtonDegradado2; private javax.swing.JButton jButtonNegro; private javax.swing.JButton jButtonRojo; private javax.swing.JButton jButtonVerde; private javax.swing.JCheckBox jCheckBoxEditar; private javax.swing.JCheckBoxMenuItem jCheckBoxMenuItemOcultaBarraEstado; private javax.swing.JComboBox jComboBox2; private javax.swing.JLabel jLabelBarraEstado; private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenu jMenu3; private javax.swing.JMenu jMenu4; private javax.swing.JMenu jMenu5; private javax.swing.JMenu jMenuArchivo; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenu jMenuEdicion; private javax.swing.JMenu jMenuImagen; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JMenuItem jMenuItem2; private javax.swing.JMenuItem jMenuItem3; private javax.swing.JMenuItem jMenuItemAbrir; private javax.swing.JMenuItem jMenuItemAbrirWebCam; private javax.swing.JMenuItem jMenuItemAcerca; private javax.swing.JMenuItem jMenuItemCapturarVideo; private javax.swing.JMenuItem jMenuItemCapturarWebCam; private javax.swing.JMenuItem jMenuItemGrabar_Sonido; private javax.swing.JMenuItem jMenuItemGuardarImagen; private javax.swing.JMenuItem jMenuItemNuevoImagen; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanelAbajo; private javax.swing.JPanel jPanelBrilloFiltro; private javax.swing.JPanel jPanelColor; private javax.swing.JPanel jPanelContraste; private javax.swing.JPanel jPanelEscala; private javax.swing.JPanel jPanelGrosor; private javax.swing.JPanel jPanelRellenoEditar; private javax.swing.JPanel jPanelRotacion; private javax.swing.JRadioButton jRadioButtonConRelleno; private javax.swing.JRadioButton jRadioButtonContinua; private javax.swing.JRadioButton jRadioButtonDegradadoHorizontal; private javax.swing.JRadioButton jRadioButtonDegradadoVertical; private javax.swing.JRadioButton jRadioButtonDiscontinua; private javax.swing.JRadioButton jRadioButtonSinRelleno; private javax.swing.JPopupMenu.Separator jSeparator1; private javax.swing.JSlider jSliderBrillo; private javax.swing.JSlider jSliderRotacion; private javax.swing.JSpinner jSpinner1; private javax.swing.JToggleButton jToggleButtonCUrva; private javax.swing.JToggleButton jToggleButtonElipse; private javax.swing.JToggleButton jToggleButtonLinea; private javax.swing.JToggleButton jToggleButtonPunto; private javax.swing.JToggleButton jToggleButtonRectangulo; private javax.swing.JToggleButton jToggleButtonTrazoLibre; private javax.swing.JToolBar jToolBarPintar; // End of variables declaration//GEN-END:variables }