Revision 1756 branches/CqCMSDvp/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/FilterRasterDialogPanel.java

View differences:

FilterRasterDialogPanel.java
7 7
import java.awt.event.ActionListener;
8 8
import java.awt.event.FocusEvent;
9 9
import java.awt.event.FocusListener;
10
import java.awt.event.KeyEvent;
11
import java.awt.event.KeyListener;
12
import java.awt.event.MouseEvent;
13
import java.awt.event.MouseListener;
10
import java.io.IOException;
14 11

  
15
import javax.swing.JPanel;
16 12
import javax.swing.event.ChangeEvent;
17 13
import javax.swing.event.ChangeListener;
18 14

  
19
import org.cresques.io.GeoRasterFile;
20
import org.cresques.ui.DefaultDialogPanel;
21 15
import org.cresques.ui.DefaultTabPanel;
22 16

  
23 17
/**
......
29 23
public class FilterRasterDialogPanel extends DefaultTabPanel implements ActionListener, ChangeListener, FocusListener{
30 24
	
31 25
	//Tama?o de panel interior. El tab de dentro es proporcional
32
	protected int								sizePanelX = 350;
33
	protected int 								sizePanelY = 210;
26
	protected int						sizePanelX = 350;
27
	protected int 						sizePanelY = 210;
34 28
	private RasterTransparencyPanel 	pTrans = null;
35
	private  BandSetupPanel 				pSetup = null;
29
	private BandSetupPanel 				pSetup = null;
36 30
	
37 31
	public FilterRasterDialogPanel() {
38 32
		
......
71 65
        
72 66
	}
73 67
	
68
	/**
69
	 * 
70
	 * @return
71
	 */
72
	public BandSetupPanel getBandSetup(){
73
		return this.pSetup;
74
	}
75
	
76
	/**
77
	 * 
78
	 * @return
79
	 */
80
	public RasterTransparencyPanel getTransparencyPanel(){
81
		return this.pTrans;
82
	}
83
	
74 84
	public void actionPerformed(ActionEvent e){
75 85
		
76 86
		//Evento sobre el checkbox de opacidad
......
108 118
			checkOpacity();
109 119
		}
110 120
		
111
		//
112
		if(	e.getSource().equals(pTrans.getTRojo())){
113
			getTransparencyValues(pTrans.getTRojo().getText());
114
		}
115 121
		
116
		if(	e.getSource().equals(pTrans.getTVerde())){
117
			getTransparencyValues(pTrans.getTVerde().getText());
118
		}
119 122
		
120
		if(	e.getSource().equals(pTrans.getTAzul())){
121
			getTransparencyValues(pTrans.getTAzul().getText());
122
		}
123
			//
124
			if(	e.getSource().equals(pTrans.getTRojo())){
125
				try{
126
					getTransparencyValues(pTrans.getTRojo().getText());
127
				}catch(IOException exc){
128
					pTrans.getTRojo().setText("");
129
				}
130
			}
131
			
132
			if(	e.getSource().equals(pTrans.getTVerde())){
133
				try{
134
					getTransparencyValues(pTrans.getTVerde().getText());
135
				}catch(IOException exc){
136
					pTrans.getTVerde().setText("");
137
				}
138
			}
139
			
140
			if(	e.getSource().equals(pTrans.getTAzul())){
141
				try{
142
					getTransparencyValues(pTrans.getTAzul().getText());
143
				}catch(IOException exc){
144
					pTrans.getTAzul().setText("");
145
				}
146
			}
147
		
148
		
123 149
	}
124 150
	
125 151
	/**
......
127 153
	 * texto introducida por el usuario.
128 154
	 * @param values
129 155
	 */
130
	private void getTransparencyValues(String values){
156
	private void getTransparencyValues(String values)throws IOException{
131 157
		
158
		for(int i=0;i<values.length();i++){
159
			char c = values.charAt(i);
160
			if(	c!='0' && c!='1' && c!='2' && c!='3' && c!='4' && 
161
				c!='5' && c!='6' && c!='7' && c!='8' && c!='9' && 
162
				c!='.' && c!=':' && c!=','){
163
				System.err.println("Caracteres incorrectos en la cadena.");
164
				throw new IOException("Caracteres incorrectos en la cadena.");
165
			}
166
			
167
			if(	values.startsWith(".") || values.startsWith(",") || values.startsWith(":") ||
168
				values.endsWith(".") || values.endsWith(",") || values.endsWith(":")){
169
				System.err.println("La cadena empieza o acaba con simbolos incorrectos");
170
				throw new IOException();
171
			}
172
			if(i<values.length()-1){
173
				char cmas = values.charAt(i+1);
174
				if((c==',' || c=='.' || c==':') && (cmas==',' || cmas=='.' || cmas==':')){
175
					System.err.println("Signos de puntuaci?n consecutivos");
176
					throw new IOException();
177
				}
178
				   
179
			}
180
			
181
		}
182
		
183
		/*String [] temp = null;
184
	    temp = values.split("\\,");
185
	    for(int i=0;i<temp.length;i++){
186
	    	if(temp[i].indexOf(":")==-1){
187
	    		
188
	    	}
189
	    }*/
132 190
	}
133 191
	/** 
134 192
	 * Controla que si el formato introducido en el textfield

Also available in: Unified diff