57 |
57 |
import javax.swing.JOptionPane;
|
58 |
58 |
import javax.swing.JPanel;
|
59 |
59 |
import javax.swing.filechooser.FileFilter;
|
60 |
|
import javax.swing.table.JTableHeader;
|
61 |
60 |
|
62 |
61 |
import org.cresques.cts.IProjection;
|
63 |
62 |
import org.cresques.io.GeoRasterFile;
|
|
63 |
import org.cresques.io.raster.RasterFilter;
|
64 |
64 |
import org.cresques.io.raster.RasterFilterStackManager;
|
65 |
65 |
import org.cresques.px.Extent;
|
66 |
66 |
import org.cresques.ui.raster.BandSetupPanel;
|
... | ... | |
172 |
172 |
* @param status Estado
|
173 |
173 |
*/
|
174 |
174 |
public void restoreStatus(PropertiesRasterDialog props){
|
175 |
|
//Devolvemos la pila de filtros al estado inicial
|
176 |
|
//if(stackManager != null)
|
177 |
|
// stackManager.deleteTempFilters();
|
178 |
|
|
179 |
175 |
//Devolvemos el alpha al estado inicial
|
180 |
176 |
int opac = Integer.parseInt(status.inicAlpha);
|
181 |
177 |
opac = (int)((opac*255)/100);
|
... | ... | |
193 |
189 |
rasterStatus.bandG = status.bandG;
|
194 |
190 |
rasterStatus.bandB = status.bandB;
|
195 |
191 |
}
|
196 |
|
|
197 |
|
BandSetupPanel bandSetup = ((FilterRasterDialogPanel)props.getContentPane()).getBandSetup();
|
198 |
|
|
|
192 |
|
199 |
193 |
//Los que han sido a?adidos los quitamos
|
200 |
194 |
for(int i=0;i<filesAdd.size();i++)
|
201 |
195 |
fLayer.delFile((String)this.filesAdd.get(i));
|
... | ... | |
206 |
200 |
|
207 |
201 |
//Restauramos los filtros
|
208 |
202 |
if(filters!=null)
|
209 |
|
stackManager.createStackFromStrings(filters);
|
|
203 |
stackManager.createStackFromStrings(filters, ((FLyrRaster)fLayer).getSource().getFiles());
|
210 |
204 |
|
211 |
205 |
fLayer.getFMap().invalidate();
|
212 |
|
//this.show();
|
213 |
206 |
}
|
214 |
207 |
|
215 |
208 |
public void show(){
|
... | ... | |
311 |
304 |
this.getAcceptButton().setText(PluginServices.getText(this,"Aceptar"));
|
312 |
305 |
this.getApplyButton().setText(PluginServices.getText(this,"Aplicar"));
|
313 |
306 |
this.getCancelButton().setText(PluginServices.getText(this,"Cancelar"));
|
|
307 |
|
|
308 |
this.getSharpeningPanel().getCbActiveSharpening().setText(PluginServices.getText(this,"onSharpening"));
|
|
309 |
this.getSharpeningPanel().getPSharpNorth().setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this,"selectBandaRefinado"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
|
314 |
310 |
}
|
315 |
311 |
|
316 |
312 |
/**
|
... | ... | |
524 |
520 |
* @return true si estaba seleccionado el panel de bandas y se ha procesado la
|
525 |
521 |
* acci?n y false si no lo estaba.
|
526 |
522 |
*/
|
527 |
|
public boolean processBandPanel(){
|
|
523 |
public void processBandPanel(){
|
528 |
524 |
//if(this.getTab().getSelectedComponent() == this.getBandSetup()){
|
529 |
525 |
fLayer.getSource().setBand(GeoRasterFile.RED_BAND,
|
530 |
526 |
getAssignedBand(GeoRasterFile.RED_BAND));
|
... | ... | |
549 |
545 |
stackManager.addRemoveBands(sb.toString());
|
550 |
546 |
else
|
551 |
547 |
stackManager.removeFilter(stackManager.getTypeFilter("removebands"));
|
|
548 |
|
|
549 |
//Al reasignar las bandas tenemos que tenerlo en cuenta en el sharpening
|
|
550 |
RasterFilter sharp = stackManager.getFilter("sharpening");
|
|
551 |
if(sharp != null){
|
|
552 |
int[] order = {getAssignedBand(GeoRasterFile.RED_BAND),getAssignedBand(GeoRasterFile.GREEN_BAND),getAssignedBand(GeoRasterFile.BLUE_BAND)};
|
|
553 |
sharp.removeParam("order");
|
|
554 |
sharp.addParam("order", order);
|
|
555 |
}
|
552 |
556 |
fLayer.getFMap().invalidate();
|
553 |
|
return true;
|
554 |
557 |
}
|
555 |
558 |
|
556 |
559 |
/**
|
... | ... | |
559 |
562 |
* @return true si estaba seleccionado el panel de transparencias y se ha procesado la
|
560 |
563 |
* acci?n y false si no lo estaba.
|
561 |
564 |
*/
|
562 |
|
public boolean processTransparencyPanel(){
|
|
565 |
public void processTransparencyPanel(){
|
563 |
566 |
//OPACIDAD
|
564 |
567 |
String sOpac = this.getTransparencyPanel().getOpacityText().getText();
|
565 |
568 |
if(!sOpac.equals("") && this.getTransparencyPanel().getOpacityCheck().isSelected()){
|
... | ... | |
587 |
590 |
}else{
|
588 |
591 |
fLayer.getSource().getFilterStack().removeFilter(stackManager.getTypeFilter("transparency"));
|
589 |
592 |
}
|
590 |
|
|
591 |
|
return true;
|
|
593 |
|
592 |
594 |
}
|
593 |
595 |
|
594 |
596 |
/**
|
... | ... | |
597 |
599 |
* @return true si estaba seleccionado el panel de realce y se ha procesado la
|
598 |
600 |
* acci?n y false si no lo estaba.
|
599 |
601 |
*/
|
600 |
|
public boolean processEnhancedPanel(){
|
|
602 |
public void processEnhancedPanel(){
|
601 |
603 |
//Filtro lineal seleccionado
|
602 |
604 |
if( this.getEnhancedPanel().getLinealDirectoRadioButton().isSelected()){
|
603 |
605 |
if( this.getEnhancedPanel().getRemoveCheck().isSelected() &&
|
... | ... | |
627 |
629 |
stackManager.removeFilter(stackManager.getTypeFilter("enhanced"));
|
628 |
630 |
}
|
629 |
631 |
fLayer.getFMap().invalidate();
|
|
632 |
}
|
|
633 |
|
|
634 |
/**
|
|
635 |
* Pulsar aceptar hace que se procesen los valores introducidos en el panel de
|
|
636 |
* sharpening.
|
|
637 |
* @return true
|
|
638 |
*/
|
|
639 |
public void processSharpeningPanel(){
|
|
640 |
if(this.getSharpeningPanel().getCbActiveSharpening().isSelected()){
|
|
641 |
String pancr = null;
|
630 |
642 |
|
631 |
|
return true;
|
|
643 |
//Obtenemos el nombre de la banda seleccionada
|
|
644 |
for(int i=0;i<(getSharpeningPanel().getRGBTable()).getRowCount();i++){
|
|
645 |
if(((Boolean) (getSharpeningPanel().getRGBTable()).getValueAt(i, 0)).booleanValue())
|
|
646 |
pancr = ((String) (getSharpeningPanel().getRGBTable()).getValueAt(i, 1));
|
|
647 |
}
|
|
648 |
|
|
649 |
//Buscamos el GeoRasterFile que corresponde a la capa y a?adimos el filtro con el
|
|
650 |
if(pancr!=null){
|
|
651 |
pancr = pancr.substring(pancr.lastIndexOf("] ") + 2, pancr.length());
|
|
652 |
for(int i=0; i<fLayer.getSource().getFiles().length;i++){
|
|
653 |
if(fLayer.getSource().getFiles()[i].getName().endsWith(File.separator+pancr)){
|
|
654 |
int[] order = {getAssignedBand(GeoRasterFile.RED_BAND),getAssignedBand(GeoRasterFile.GREEN_BAND),getAssignedBand(GeoRasterFile.BLUE_BAND)};
|
|
655 |
|
|
656 |
int opac = Integer.parseInt(this.getTransparencyPanel().getOpacityText().getText());
|
|
657 |
opac = (int)((opac*255)/100);
|
|
658 |
|
|
659 |
String method = "brovey";
|
|
660 |
if(getSharpeningPanel().getRbHSL().isSelected())
|
|
661 |
method = "hsl";
|
|
662 |
|
|
663 |
double coef = 0D;
|
|
664 |
if(getSharpeningPanel().getRbHSL().isSelected())
|
|
665 |
coef = Double.parseDouble(pSharp.getJTextField().getText());
|
|
666 |
|
|
667 |
int coefBrovey = 0;
|
|
668 |
if(getSharpeningPanel().getRbBrovey().isSelected())
|
|
669 |
coefBrovey = Integer.parseInt(pSharp.getJTextField1().getText());
|
|
670 |
|
|
671 |
stackManager.addSharpeningFilter(fLayer.getSource().getFiles(), i, order, opac, method, coef, coefBrovey);
|
|
672 |
}
|
|
673 |
}
|
|
674 |
|
|
675 |
}
|
|
676 |
}else{
|
|
677 |
stackManager.removeFilter(stackManager.getTypeFilter("sharpening"));
|
|
678 |
}
|
|
679 |
fLayer.getFMap().invalidate();
|
632 |
680 |
}
|
633 |
681 |
|
634 |
682 |
/**
|
... | ... | |
639 |
687 |
private void acceptButtonActionPerformed(ActionEvent e) {
|
640 |
688 |
this.processBandPanel();
|
641 |
689 |
this.processTransparencyPanel();
|
642 |
|
this.processEnhancedPanel();
|
|
690 |
this.processEnhancedPanel();
|
|
691 |
this.processSharpeningPanel();
|
643 |
692 |
}
|
644 |
693 |
|
645 |
694 |
/**
|
... | ... | |
750 |
799 |
v.add(fLayer.getSource().getFiles()[i]);
|
751 |
800 |
}
|
752 |
801 |
|
753 |
|
GeoRasterFile[] grf = new GeoRasterFile[v.size()];
|
|
802 |
grf = new GeoRasterFile[v.size()];
|
754 |
803 |
for(int i=0;i<grf.length;i++){
|
755 |
804 |
grf[i] = (GeoRasterFile)v.get(i);
|
756 |
805 |
}
|
757 |
|
bandSetup.addFiles(grf);
|
|
806 |
this.addFiles(grf);
|
758 |
807 |
}
|
759 |
808 |
}
|
760 |
809 |
|
761 |
810 |
/**
|
|
811 |
* Asigna la lista de GeoRasterFile
|
|
812 |
* @return
|
|
813 |
*/
|
|
814 |
public void setGeoRasterFile(GeoRasterFile[] grf){
|
|
815 |
this.grf = grf;
|
|
816 |
}
|
|
817 |
|
|
818 |
/**
|
762 |
819 |
* Elimina una banda del raster. Si queda solo un fichero o no se ha
|
763 |
820 |
* seleccionado ninguna banda no hace nada.
|
764 |
821 |
* @param e
|
... | ... | |
774 |
831 |
fLayer.delFile(pathName);
|
775 |
832 |
String file = pathName.substring(pathName.lastIndexOf("/")+1);
|
776 |
833 |
file = file.substring(file.lastIndexOf("\\")+1);
|
777 |
|
bandSetup.removeFile(file);
|
|
834 |
this.removeFile(file);
|
778 |
835 |
|
779 |
836 |
//Mantiene la lista de ficheros eliminados por si se cancela
|
780 |
837 |
status.removeFile(pathName);
|