/* * (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(); }
/** Acciones de inicialización del componente */ private void initActions() { getPreviewRender(); if (lyr.getBandCount() == 1) data.setBands(new String[] {PluginServices.getText(null, "gray")}); data.setPosterizationActive(true); panel.getPosterizationPanel().setComponentEnabled(true); data.updateObservers(); }
/* * (non-Javadoc) * * @see * org.gvsig.gui.beans.slidertext.listeners.SliderListener#actionValueChanged * (org.gvsig.gui.beans.slidertext.listeners.SliderEvent) */ public void actionValueChanged(SliderEvent e) { if (!panel.isEnableValueChangedEvent()) return; // Evento de movimiento del slider de cambio de umbral de posterización if (e.getSource() == panel.getPosterizationPanel().getThreshold()) data.setPosterizationThreshold((int) panel.getPosterizationPanel().getThreshold().getValue()); // Evento de movimiento del slider de cambio de umbral de reducción de // ruido if (e.getSource() == panel.getNoisePanel().getThreshold()) data.setNoiseThreshold((int) panel.getNoisePanel().getThreshold().getValue()); // Evento de movimiento del slider de cambio de umbral de moda if (e.getSource() == panel.getModePanel().getThreshold()) data.setModeThreshold((int) panel.getModePanel().getThreshold().getValue()); 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); }
/** Captura los eventos de las cajas de texto */ public void actionValueChanged(EventObject e) { if (!panel.isEnableValueChangedEvent()) return; // Niveles de la posterización if (e.getSource() == panel.getPosterizationPanel().getLevels().getDataInputField()) { String value = panel.getPosterizationPanel().getLevels().getValue(); try { double doubleValue = Double.valueOf(value); if (doubleValue < 2) throw new NumberFormatException(); } catch (NumberFormatException ex) { panel.setEnableValueChangedEvent(false); value = 2 + ""; panel.getPosterizationPanel().getLevels().setValue(value); panel.setEnableValueChangedEvent(true); } data.setPosterizationLevels((int) Double.parseDouble(value)); if ((int) Double.parseDouble(value) == 2) panel.getPosterizationPanel().getThreshold().setControlEnabled(true); else panel.getPosterizationPanel().getThreshold().setControlEnabled(false); refreshPreview(); } }