/*
   * (non-Javadoc)
   *
   * @see
   * java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
   */
  public void actionPerformed(ActionEvent e) {
    if (!panel.isEnableValueChangedEvent()) return;

    // Cambio combo de bandas seleccionadas para la conversión a B/W
    if (e.getSource() == panel.getComboBands()) {
      String value = (String) panel.getComboBands().getSelectedItem();
      if (value.compareTo("R") == 0) data.setBandType(GrayScaleFilter.R);
      if (value.compareTo("G") == 0) data.setBandType(GrayScaleFilter.G);
      if (value.compareTo("B") == 0) data.setBandType(GrayScaleFilter.B);
      if (value.compareTo("RGB") == 0) data.setBandType(GrayScaleFilter.RGB);
      if (value.compareTo(PluginServices.getText(null, "gray")) == 0)
        data.setBandType(GrayScaleFilter.GRAY);
    }

    // Check de activar/desactivar posterización
    if (e.getSource() == panel.getPosterizationPanel().getActive()) {
      data.setPosterizationActive(panel.getPosterizationPanel().getActive().isSelected());
    }

    // Slider para el umbral de posterización
    if (e.getSource() == panel.getPosterizationPanel().getThreshold().getSlider()) {
      data.setPosterizationThreshold((int) panel.getPosterizationPanel().getThreshold().getValue());
    }

    // Check de activar/desactivar ruido
    if (e.getSource() == panel.getNoisePanel().getActive()) {
      data.setNoiseActive(panel.getNoisePanel().getActive().isSelected());
    }

    // Slider para el umbral de ruido
    if (e.getSource() == panel.getNoisePanel().getThreshold().getSlider()) {
      data.setNoiseThreshold((int) panel.getNoisePanel().getThreshold().getValue());
    }

    // Check de activar/desactivar moda
    if (e.getSource() == panel.getModePanel().getActive()) {
      data.setModeActive(panel.getModePanel().getActive().isSelected());
    }

    // Slider para el umbral de moda
    if (e.getSource() == panel.getModePanel().getThreshold().getSlider()) {
      data.setModeThreshold((int) panel.getModePanel().getThreshold().getValue());
    }

    // Check de activar/desactivar el paso alto
    /*
     * if(e.getSource() == panel.getHighPassPanel().getActive()) {
     * data.setHighPassActive
     * (panel.getHighPassPanel().getActive().isSelected()); }
     */

    refreshPreview();
  }
  /**
   * Asigna la vista de datos. En este caso es el panel de preprocesado de la vectorización
   *
   * @param prepPanel
   */
  public void setDataView(GrayConversionPanel prepPanel) {
    this.panel = prepPanel;
    process = new GrayConversionProcess(null);
    process.setSourceLayer(lyr);

    panel.getComboBands().addActionListener(this);
    panel.getPosterizationPanel().getActive().addActionListener(this);
    panel.getPosterizationPanel().getLevels().addValueChangedListener(this);
    panel.getPosterizationPanel().getThreshold().addValueChangedListener(this);
    panel.getPosterizationPanel().getActive().setSelected(true);

    panel.getNoisePanel().getActive().addActionListener(this);
    panel.getNoisePanel().getThreshold().addValueChangedListener(this);

    panel.getModePanel().getActive().addActionListener(this);
    panel.getModePanel().getThreshold().addValueChangedListener(this);

    // panel.getHighPassPanel().getActive().addActionListener(this);
    // panel.getHighPassPanel().getRadio().addValueChangedListener(this);
  }