Revision 4377

View differences:

trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/Panels/PropertiesRasterDialog.java
258 258
	 * Constructor de la ventana de dialogo.
259 259
	 * @param app
260 260
	 */
261
	public PropertiesRasterDialog(FLyrRaster layer, int[][] rangeR, int[][] rangeG, int[][] rangeB){
261
	public PropertiesRasterDialog(FLyrRaster layer, ArrayList ranges){
262 262
		super();
263 263
		fLayer = layer;
264 264
		if(fLayer.getStatus()==null){
......
267 267
		}else
268 268
			rasterStatus = (StatusLayerRaster)fLayer.getStatus();
269 269
		initialize();			
270
		this.setRanges(rangeR, rangeG, rangeB);
270
		this.setRanges(ranges);
271 271
		setTranslation();
272 272
	}
273 273
	
......
281 281
			
282 282
		RasterTransparencyPanel tpan = this.getTransparencyPanel();
283 283
		
284
		tpan.lGreenValue.setText(PluginServices.getText(this,"Valor_verde")+":");
285
		tpan.lRedValue.setText(PluginServices.getText(this,"Valor_rojo")+":");
286
		tpan.lBlueValue.setText(PluginServices.getText(this,"Valor_azul")+":");
284
		
287 285
		tpan.getTransparencyCheck().setText(PluginServices.getText(this,"transparencia"));
288 286
		tpan.getOpacityCheck().setText(PluginServices.getText(this,"opacidad"));
289
		tpan.lRange.setText(PluginServices.getText(this,"usar_rango")+": 1,3,5:8");
290
		tpan.lPixelValue.setText(PluginServices.getText(this,"valor_pixel")+": 0 a 255");
291
				
287
					
292 288
		EnhancedPanel ep = this.getEnhancedPanel();
293 289
		ep.lLineal.setText(PluginServices.getText(this,"lineal_directo"));
294 290
		ep.lQueue.setText(PluginServices.getText(this,"recorte_colas"));
......
331 327
		initialize();
332 328
	}
333 329
		
334
	
335
	
336 330
	/**
337 331
	 * Carga los datos del panel info.
338 332
	 */
......
385 379
	 */
386 380
	public void addNumBands(int numBands){
387 381
		nbands += numBands;
388
		if(this.getTransparencyPanel() != null && this.getTransparencyPanel().getTRojo().isEnabled())
389
			this.getTransparencyPanel().setActiveTransparencyControl(true); 
382
		/*if(this.getTransparencyPanel() != null && this.getTransparencyPanel().getTRojo().isEnabled())
383
			this.getTransparencyPanel().setActiveTransparencyControl(true); */
390 384
	}
391 385
	
392 386
	/**
......
488 482
		this.currentProjection = prj;
489 483
	}
490 484
	
491
	
492
	
493 485
	public void closeJDialog() {
494 486
		PluginServices.getMDIManager().closeView(PropertiesRasterDialog.this);
495 487
	}
......
585 577
		}
586 578
				
587 579
		//TRANSPARENCIA
588
		if(	this.getTransparencyPanel().getTransparencyCheck().isSelected()){
589
			this.checkTransparencyValues();
590
			stackManager.addTransparencyFilter(	this.getRangeRed(),
591
												this.getRangeGreen(),
592
												this.getRangeBlue(),
580
		if(	this.getTransparencyPanel().getTransparencyCheck().isSelected()){			
581
			stackManager.addTransparencyFilter(	getTransparencyPanel().getPTranspByPixel().getEntries(),
593 582
												0x10,	//Transparencia
594 583
												0xff,	//Color Transparencia R
595 584
												0xff,	//Color Transparencia G
......
854 843
		this.status.restoreStatus(this);
855 844
		fLayer.getFMap().invalidate();
856 845
	}
857
	
858 846
		
859 847
	/**
860 848
	 * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
......
864 852
    		m_viewinfo.setTitle(PluginServices.getText(this, "propiedades_raster"));
865 853
		return m_viewinfo;
866 854
	}
867
	
868
	
869 855
}  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toc/FPopupMenu.java
363 363
       		RasterFilterStackManager 	stackManager = null;
364 364
       
365 365
       		stackManager = new RasterFilterStackManager(((FLyrRaster)lyr).getSource().getFilterStack());
366
       		       		
367
       		int[][] rangeR = stackManager.getTransparecyR();
368
       		int[][] rangeG = stackManager.getTransparecyG();
369
       		int[][] rangeB = stackManager.getTransparecyB();
370
       		
371
       		propsDialog = new PropertiesRasterDialog(((FLyrRaster)lyr), rangeR, rangeG, rangeB);
366
       		       		       		
367
       		propsDialog = new PropertiesRasterDialog(((FLyrRaster)lyr), stackManager.getTransparencyRGB());
372 368
       	       			
373 369
			int alpha = 255-((FLyrRaster)lyr).getSource().getTransparency();
374 370
			
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toolListeners/SaveRasterListener.java
40 40
 */
41 41
package com.iver.cit.gvsig.gui.toolListeners;
42 42

  
43
import java.awt.geom.Point2D;
44

  
43 45
import org.cresques.ui.raster.DataInputSaveRaster;
44 46
import org.cresques.ui.raster.SaveRasterDialogPanel;
45 47
import org.cresques.ui.raster.SaveSetupPanel;
46 48

  
47 49
import com.iver.andami.PluginServices;
48

  
49 50
import com.iver.cit.gvsig.fmap.MapControl;
50 51
import com.iver.cit.gvsig.fmap.ViewPort;
51 52
import com.iver.cit.gvsig.fmap.layers.FLayers;
52 53
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
53
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent;
54 54
import com.iver.cit.gvsig.fmap.tools.SaveRasterListenerImpl;
55
import com.iver.cit.gvsig.fmap.tools.ZoomInListenerImpl;
56

  
55
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent;
57 56
import com.iver.cit.gvsig.gui.View;
58 57
import com.iver.cit.gvsig.gui.Panels.SaveRasterDialog;
59 58

  
......
89 88
		FLayers layers = mapCtrl.getMapContext().getLayers();
90 89
		
91 90
		SaveRasterDialog saveRaster = new SaveRasterDialog(layers, mapCtrl);
92
		if(Math.abs(rect.getMaxY()-rect.getMinY())>10 && Math.abs(rect.getMaxX()-rect.getMinX())>10){
91
		ViewPort vp = mapCtrl.getViewPort();
92
		Point2D ini = vp.fromMapPoint(rect.getMinX(), rect.getMinY());
93
		Point2D fin = vp.fromMapPoint(rect.getMaxX(), rect.getMaxY());
94
		if(Math.abs(fin.getY()-ini.getY())>10 && Math.abs(fin.getX()-ini.getX())>10){
93 95
			saveRaster.setProjection(((View) PluginServices.getMDIManager().getActiveView()).getProjection());
94 96
			//saveRaster.setLayerList(this.layerList);
95 97
			DataInputSaveRaster dialog = ((SaveSetupPanel)(((SaveRasterDialogPanel)saveRaster.getContentPane()).getContentPanel())).getSaveParameters();
......
102 104
			dialog.getTsup_izqX().setText(String.valueOf(rect.getMinX()).substring(0,indexPoint+2));
103 105
			indexPoint = String.valueOf(rect.getMinY()).indexOf('.');
104 106
			dialog.getTsup_izqY().setText(String.valueOf(rect.getMaxY()).substring(0,indexPoint+2));
105
			
106
			/*dialog.getTinf_derX().setText(String.valueOf(rect.getMaxX()));
107
			dialog.getTinf_derY().setText(String.valueOf(rect.getMaxY()));
108
			dialog.getTsup_izqX().setText(String.valueOf(rect.getMinX()));
109
			dialog.getTsup_izqY().setText(String.valueOf(rect.getMinY()));*/
110
			
107
						
111 108
			PluginServices.getMDIManager().addView(saveRaster);
112 109
		}
113 110
	}
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/RasterVectorialControls.java
108 108
		BandSetupPanel 				bandSetup = null;
109 109
   
110 110
		stackManager = new RasterFilterStackManager(((FLyrRaster)lyr).getSource().getFilterStack());
111
	       		       		
112
	    int[][] rangeR = stackManager.getTransparecyR();
113
	    int[][] rangeG = stackManager.getTransparecyG();
114
	    int[][] rangeB = stackManager.getTransparecyB();
115
	       		
116
	    propsDialog = new PropertiesRasterDialog(((FLyrRaster)lyr), rangeR, rangeG, rangeB);
117
	       	       			
111
	       		       			    
112
	    propsDialog = new PropertiesRasterDialog(((FLyrRaster)lyr), stackManager.getTransparencyRGB());
113
	    
118 114
	    int alpha = 255-((FLyrRaster)lyr).getSource().getTransparency();
119 115
				
120 116
		bandSetup = ((FilterRasterDialogPanel)propsDialog.getContentPane()).getBandSetup();
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/TransparencyFilter.java
23 23
 */
24 24
package org.cresques.io.raster;
25 25

  
26
import java.io.IOException;
27
import java.util.ArrayList;
26 28

  
29

  
27 30
/**
28 31
 * Clase base para los filtros de transparencia en sus diferentes tipos
29 32
 * de datos.
......
32 35
 */
33 36
public abstract class TransparencyFilter extends RasterFilter {
34 37
    //Par?metros del filtro
35
    protected int[][] rangesR;
36
    protected int[][] rangesG;
37
    protected int[][] rangesB;
38

  
38
	/**
39
	 * Lista de TransparencyRange
40
	 */
41
	protected ArrayList	rangesList = null;
42
	
39 43
    /**
40 44
     * Valor de transparencia
41 45
     */
......
63 67
    public TransparencyFilter() {
64 68
        super();
65 69
    }
66

  
70
    
67 71
    /**
68 72
     * Obtiene par?metros del filtro desde la tabla Hash
69 73
     */
70 74
    public void pre() {
71 75
        //Obtenci?n de par?metros comunes a todos
72
        this.rangesR = (int[][]) params.get("red");
73
        this.rangesG = (int[][]) params.get("green");
74
        this.rangesB = (int[][]) params.get("blue");
75
        this.alpha = ((Integer) params.get("alpha")).intValue();
76
        this.transparencyColorRed = ((Integer) params.get("transparencyRed")).intValue();
77
        this.transparencyColorGreen = ((Integer) params.get("transparencyGreen")).intValue();
78
        this.transparencyColorBlue = ((Integer) params.get("transparencyBlue")).intValue();
76
    	rangesList = (ArrayList)params.get("rangesList");
77
    	/*for(int i=0;i<rangesList.size();i++)
78
    		((TransparencyRange)rangesList.get(i)).show();*/
79
        alpha = ((Integer) params.get("alpha")).intValue();
80
        transparencyColorRed = ((Integer) params.get("transparencyRed")).intValue();
81
        transparencyColorGreen = ((Integer) params.get("transparencyGreen")).intValue();
82
        transparencyColorBlue = ((Integer) params.get("transparencyBlue")).intValue();
79 83
    }
80

  
81
    /**
82
     * Para dos intervalos dados, devuelve true si el intervalo B est? dentro del A y
83
     * false si no lo est?
84
     * @param intervalA intervalo A
85
     * @param intervalB intervalo B
86
     * @return true si el intervalo B est? dentro del A y false si no lo est?
87
     */
88
    private boolean compareIntervals(int[][] intervalA, int[][] intervalB) {
89
        if ((intervalA != null) && (intervalB != null)) {
90
            boolean equalInterval = false;
91

  
92
            for (int i = 0; i < intervalB.length; i++) {
93
                for (int j = 0; j < intervalA.length; j++) {
94
                    if ((intervalB[i][0] >= intervalA[i][0]) &&
95
                            (intervalB[i][1] <= intervalA[i][1])) {
96
                        equalInterval = true;
97

  
98
                        break;
99
                    }
100
                }
101

  
102
                if (!equalInterval) {
103
                    return false;
104
                }
105
            }
106

  
107
            return true;
108
        }
109

  
110
        if ((intervalA == null) && (intervalB == null)) {
111
            return true;
112
        }
113

  
114
        return false;
115
    }
116

  
117
    /**
118
     * Devuelve true si el filtro pasado por par?metro es equivalente a este
119
     * y false si no lo es.
120
     * @param filter        Filtro a comparar
121
     * @return        true si son equivalentes y false si no lo son
122
     */
123
    public boolean isEquivalent(TransparencyFilter filter) {
124
        if ((alpha != filter.alpha) ||
125
                (transparencyColorRed != filter.transparencyColorRed) ||
126
                (transparencyColorGreen != filter.transparencyColorGreen) ||
127
                (transparencyColorBlue != filter.transparencyColorBlue)) {
128
            return false;
129
        }
130

  
131
        boolean equalRange = false;
132
        equalRange = compareIntervals((int[][]) params.get("red"),
133
                                      (int[][]) filter.params.get("red"));
134

  
135
        if (!equalRange) {
136
            return false;
137
        }
138

  
139
        equalRange = false;
140
        equalRange = compareIntervals((int[][]) params.get("green"),
141
                                      (int[][]) filter.params.get("green"));
142

  
143
        if (!equalRange) {
144
            return false;
145
        }
146

  
147
        equalRange = false;
148
        equalRange = compareIntervals((int[][]) params.get("blue"),
149
                                      (int[][]) filter.params.get("blue"));
150

  
151
        if (!equalRange) {
152
            return false;
153
        }
154

  
155
        return true;
156
    }
157

  
158
    /**
159
     * Obtiene los rangos de transparencia en la banda  del rojo
160
     * @return rangos de transparencia en la banda del rojo
161
     */
162
    public int[][] getRangeR() {
163
        return this.rangesR;
164
    }
165

  
166
    /**
167
     * Obtiene los rangos de transparencia en la banda  del verde
168
     * @return rangos de transparencia en la banda del verde
169
     */
170
    public int[][] getRangeG() {
171
        return this.rangesG;
172
    }
173

  
174
    /**
175
     * Obtiene los rangos de transparencia en la banda  del azul
176
     * @return rangos de transparencia en la banda del azul
177
     */
178
    public int[][] getRangeB() {
179
        return this.rangesB;
180
    }
181 84
}
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/TransparencyImageFilter.java
53 53
    }
54 54

  
55 55
    /**
56
     * Dado un pixel y un rango, asigna ese pixel al color de transparencia por
57
     * defecto si el pixel en una banda determinada est? en el rango definido.
58
     * @param range        rango
56
     * Asigna al pixel pasado como par?metro como transparente con 
57
     * el color de transparencia que est? seleccionado
58
     * @param px Pixel a asignarle transparencia
59
     */
60
    private void setPixelTransparent(int[] px){
61
		px[0] = this.alpha;
62
        px[1] = this.transparencyColorRed;
63
        px[2] = this.transparencyColorGreen;
64
        px[3] = this.transparencyColorBlue;	
65
    }
66
    
67
    /**     
68
     * @param range rango
59 69
     * @param banda banda
60
     * @param px        pixel
70
     * @param px    pixel
61 71
     */
62
    private void processRange(int[][] range, int banda, int[] px) {
63
        for (int i = 0; i < range.length; i++) {
64
            if (((px[banda] >= range[i][0]) && (px[banda] <= range[i][1]))) {
65
                px[0] = this.alpha;
66
                px[1] = this.transparencyColorRed;
67
                px[2] = this.transparencyColorGreen;
68
                px[3] = this.transparencyColorBlue;
69
            }
70
        }
72
    private void processRange(int[] px) {
73
    	for (int i = 0; i < rangesList.size(); i++) {
74
    		TransparencyRange tr = ((TransparencyRange)rangesList.get(i));
75

  
76
    		if(tr.isAnd()){
77
    			if(tr.getRed() != null)
78
    				if (px[1] < tr.getRed()[0] || px[1] > tr.getRed()[1])
79
    					continue;
80
    			if(tr.getGreen() != null)
81
    				if (px[2] < tr.getGreen()[0] || px[2] > tr.getGreen()[1])
82
    					continue;
83
    			if(tr.getBlue() != null)
84
    				if (px[3] < tr.getBlue()[0] || px[3] > tr.getBlue()[1])
85
    					continue;
86
    			if(tr.getRed() != null || tr.getGreen() != null || tr.getBlue() != null)
87
    				setPixelTransparent(px);
88
    			
89
    		}else{
90
    			if(tr.getRed() != null){
91
    				if (px[1] >= tr.getRed()[0] && px[1] <= tr.getRed()[1]){
92
    					setPixelTransparent(px);
93
    					continue;
94
    				}
95
    			}
96
    			if(tr.getGreen() != null){
97
    				if (px[2] >= tr.getGreen()[0] && px[2] <= tr.getGreen()[1]){
98
    					setPixelTransparent(px);
99
    					continue;
100
    				}
101
    			}
102
    			if(tr.getBlue() != null){
103
    				if (px[3] >= tr.getBlue()[0] && px[3] <= tr.getBlue()[1]){
104
    					setPixelTransparent(px);
105
    					continue;
106
    				}
107
    			}
108
    		}
109
    	}
110
    	
71 111
    }
72

  
112
    
73 113
    /* (non-Javadoc)
74 114
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
75 115
     */
......
80 120
                        (pt & 0x00ff00) >> 8, (pt & 0x0000ff)
81 121
                    };
82 122

  
83
        if (rangesR != null) {
84
            processRange(rangesR, 1, px4);
85
        }
86

  
87
        if (rangesG != null) {
88
            processRange(rangesG, 2, px4);
89
        }
90

  
91
        if (rangesB != null) {
92
            processRange(rangesB, 3, px4);
93
        }
94

  
123
        processRange(px4);
124
       
95 125
        ((BufferedImage) image).setRGB(x, y,
96 126
                                       (((px4[0] << 24) & 0xff000000) |
97 127
                                       ((px4[1] << 16) & 0x00ff0000) |
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/TransparencyRange.java
1
/*
2
 * Cresques Mapping Suite. Graphic Library for constructing mapping applications.
3
 *
4
 * Copyright (C) 2004-5.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
19
 *
20
 * For more information, contact:
21
 *
22
 * cresques@gmail.com
23
 */
24
package org.cresques.io.raster;
25

  
26
import java.io.IOException;
27

  
28
	/**
29
	 * Clase que representa a un conjunto de pixeles con
30
	 * transparencia. Incluye los rangos de transparencia para cada banda, 
31
	 * la cadena que va en la lista y la operaci?n que se realiza entre 
32
	 * ellos. Un And significa que ser?n transparentes todos los pixeles
33
	 * que cumplan con R con G y con B. Un Or significar? que tendr?n transparencia
34
	 * todos los pixeles que cumplan con R con G o con B.  
35
	 * @author Nacho Brodin (brodin_ign@gva.es)
36
	 *
37
	 */
38
	public class TransparencyRange{
39
		private String 	strEntry = null;
40
		private int[]	red = null;
41
		private int[]	green = null;
42
		private int[]	blue = null;
43
		private boolean	and = true;
44
		
45
		/**
46
		 * Obtiene la operaci?n  utilizada
47
		 * @param and Si es true significa que se usa un AND y false implica
48
		 * que se usa un OR
49
		 */
50
		public boolean isAnd() {
51
			return and;
52
		}
53
		
54
		/**
55
		 * Asigna la operaci?n AND como la utilizada
56
		 * @param and booleano que si est? a true significa que el la operaci?n
57
		 * AND es la utilizada como operaci?n.
58
		 */
59
		public void setAnd(boolean and) {
60
			this.and = and;
61
		}
62
		
63
		/**
64
		 * Obtiene el intervalo de valores correspondiente a la banda del azul
65
		 * @return Array bidimensional de enteros correspondiente a la banda del azul
66
		 */
67
		public int[] getBlue() {
68
			return blue;
69
		}
70
		
71
		/**
72
		 * Asigna el intervalo de valores correspondiente a la banda del azul
73
		 * @param blue Array bidimensional de enteros correspondiente a la banda del azul
74
		 */
75
		public void setBlue(int[] blue) {
76
			this.blue = blue;
77
		}
78
		
79
		/**
80
		 * Obtiene el intervalo de valores correspondiente a la banda del verde
81
		 * @return Array bidimensional de enteros correspondiente a la banda del verde
82
		 */
83
		public int[] getGreen() {
84
			return green;
85
		}
86
		
87
		/**
88
		 * Asigna el intervalo de valores correspondiente a la banda del verde
89
		 * @param green Array bidimensional de enteros correspondiente a la banda del verde
90
		 */
91
		public void setGreen(int[] green) {
92
			this.green = green;
93
		}
94
		
95
		/**
96
		 * Obtiene el intervalo de valores correspondiente a la banda del rojo
97
		 * @return Array bidimensional de enteros correspondiente a la banda del rojo
98
		 */
99
		public int[] getRed() {
100
			return red;
101
		}
102
		
103
		/**
104
		 * Asigna el intervalo de valores correspondiente a la banda del rojo
105
		 * @param red Array bidimensional de enteros correspondiente a la banda del rojo
106
		 */
107
		public void setRed(int[] red) {
108
			this.red = red;
109
		}
110
		
111
		/**
112
		 * Obtiene la cadena que representa una entrada en la tabla.
113
		 * @return Cadena que representa una entrada en la tabla
114
		 */
115
		public String getStrEntry() {
116
			return strEntry;
117
		}
118
		
119
		/**
120
		 * Asigna la cadena que representa una entrada en la tabla.
121
		 * @param strEntry Cadena que representa una entrada en la tabla.
122
		 */
123
		public void setStrEntry(String strEntry) {
124
			this.strEntry = strEntry;
125
		}
126
		
127
		
128
		/**
129
		 * Esta funci?n valida la cadena de entrada por medio de una m?quina de estados. Valida las
130
		 * siguientes posibilidades en la cadena de entrada:
131
		 * <LI>
132
		 * <UL>(valor_rojo) & (Valor_verde) & (Valor_azul)</UL>
133
		 * <UL>(valor_rojo) | (Valor_verde) | (Valor_azul)</UL>
134
		 * </LI>
135
		 * Despues de la validaci?n parsea el contenido y carga los par?metros r,g,b con los
136
		 * intervalos de valores. Estos par?metros deben ser pasados como arrays de enteros de 
137
		 * dos elementos.  
138
	     * @param values
139
	     * @param r	Intervalo de rojo
140
	     * @param g Intervalo de verde
141
	     * @param b Intervalo de azul
142
	     * @return Devuelve true si la operaci?n usada en los intervalos es un AND y false si es un OR
143
	     */
144
		public static boolean stringToInterval(String values, int[] r, int[] g, int[] b) throws IOException {
145
			int status = 0;
146
		    int countAnd = 0, countOr = 0;
147
		    boolean and = true;
148
		    for(int i=0;i<values.length();i++){
149
		      char c = values.charAt(i);
150
		      switch(status){
151
		       case 0: 	if(c == '(') status = 2;
152
		       			else if(c == ' ') status = 0;
153
						else status = 1;
154
		       			break;
155
		       case 1: 	throw new IOException("Error en la cadena de entrada "+status);
156
		       case 2: 	if (c >= 48 && c <= 57) status = 3;
157
						else if(c == ')') status = 6;
158
		       			else status = 1;
159
		       			break;
160
		       case 3: 	if (c >= 48 && c <= 57) status = 3;
161
		   				else if(c == ')') status = 6;
162
						else if(c == ':') status = 4;
163
		   				else status = 1;
164
		   				break;	
165
			   case 4:	if (c >= 48 && c <= 57) status = 5;
166
						else status = 1;
167
						break;
168
			   case 5:	if (c >= 48 && c <= 57) status = 5;
169
						else if(c == ')') status = 6;
170
						else status = 1;
171
						break;
172
			   case 6:	if(c == '&'){
173
							status = 0;
174
							countAnd++;
175
		    	   		}else if(c == '|'){
176
							status = 0;
177
							countOr++;
178
		    	   		}else if(c == ' ')
179
		    	   			status = 6;
180
						else
181
		    	   			status = 1;
182
		      }
183
				
184
		    }
185
		    	
186
		    //Si el analisis es correcto parseamos
187
		    if(status == 6 && ((countAnd == 2 && countOr == 0)  || 
188
		    					(countAnd == 0 && countOr == 2)) ){
189
		    	  String[] s = values.split(" & ");
190
				  if(s.length < 3){
191
					  s = values.split(" \\| ");
192
					  and = false;
193
				  }
194
				  
195
				String inter = s[0].substring(1, s[0].length() - 1);
196
				String[] val = inter.split(":");
197
				try{
198
					r[0] = Integer.parseInt(val[0]);
199
				 	if(val.length == 2)
200
				 		r[1] = Integer.parseInt(val[1]);
201
				 	else
202
						r[1] = Integer.parseInt(val[0]);
203
				}catch(NumberFormatException e){
204
					r [0] = -1;r [1] = -1;
205
				}
206
				  
207
				  
208
				
209
				inter = s[1].substring(1, s[1].length() - 1);
210
				val = inter.split(":");
211
				try{
212
				  	g[0] = Integer.parseInt(val[0]);
213
					if(val.length == 2)
214
						g[1] = Integer.parseInt(val[1]);
215
					else
216
						g[1] = Integer.parseInt(val[0]);
217
				}catch(NumberFormatException e){
218
					g[0] = -1;g[1] = -1;
219
				}
220
				  
221
				 
222
				inter = s[2].substring(1, s[2].length() - 1);
223
				val = inter.split(":");
224
				try{
225
					b[0] = Integer.parseInt(val[0]);
226
					if(val.length == 2)
227
						b[1] = Integer.parseInt(val[1]);
228
					else
229
						b[1] = Integer.parseInt(val[0]);  
230
				}catch(NumberFormatException e){
231
					b [0] = -1;b [1] = -1;
232
				}
233
		  }else
234
			 throw new IOException("Error en la cadena de entrada ");
235
		      
236
		  return and;
237
		}
238
	    
239
		public void show(){
240
			if(getRed() != null)
241
				System.out.println(getRed()[0]+" "+getRed()[1]);
242
			if(getGreen() != null)
243
				System.out.println(getGreen()[0]+" "+getGreen()[1]);
244
			if(getBlue() != null)
245
				System.out.println(getBlue()[0]+" "+getBlue()[1]);
246
			System.out.println(isAnd());
247
			System.out.println(getStrEntry());
248
			System.out.println("--------------------");
249
		}
250
	}
0 251

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/RasterFilterStackManager.java
23 23
 */
24 24
package org.cresques.io.raster;
25 25

  
26
import java.io.IOException;
26 27
import java.lang.reflect.Constructor;
27 28
import java.util.ArrayList;
28 29
import java.util.Hashtable;
......
128 129
     * @param transparencyGreen        Color en la banda del verde de la transparencia
129 130
     * @param transparencyBlue        Color en la banda del azul de la transparencia
130 131
     */
131
    public void addTransparencyFilter(int[][] red, int[][] green, int[][] blue,
132
    public void addTransparencyFilter(ArrayList rangesList,
132 133
                                      int alpha, int transparencyRed,
133 134
                                      int transparencyGreen,
134 135
                                      int transparencyBlue) {
......
146 147
        }
147 148

  
148 149
        if(filtro != null){
149
	        if (red != null) {
150
	            filtro.addParam("red", red);
151
	        }
152
	
153
	        if (green != null) {
154
	            filtro.addParam("green", green);
155
	        }
156
	
157
	        if (blue != null) {
158
	            filtro.addParam("blue", blue);
159
	        }
160
	
150
	        filtro.addParam("rangesList", rangesList);	
161 151
	        filtro.addParam("alpha", new Integer(alpha));
162 152
	        filtro.addParam("transparencyRed", new Integer(transparencyRed));
163 153
	        filtro.addParam("transparencyGreen", new Integer(transparencyGreen));
......
198 188
    }
199 189

  
200 190
    /**
201
     * Obtiene el rango de rojo del filtro de transparencia de la pila
202
     * @return rango de rojo
191
     * Obtiene la lista de rangos del filtro de transparencia de la pila
192
     * @return ArrayList con la lista de rangos. Cada elemento es un objeto TransparencyRange 
203 193
     */
204
    public int[][] getTransparecyR() {
205
        for (int i = 0; i < filterStack.lenght(); i++) {
194
    public ArrayList getTransparencyRGB(){
195
    	for (int i = 0; i < filterStack.lenght(); i++) {
206 196
            if (filterStack.get(i) instanceof TransparencyImageFilter ||
207 197
                    filterStack.get(i) instanceof TransparencyShortFilter) {
208
                return ((TransparencyFilter) filterStack.get(i)).rangesR;
198
                return ((TransparencyFilter) filterStack.get(i)).rangesList;
209 199
            }
210 200
        }
211

  
212 201
        return null;
213 202
    }
214

  
203
   
215 204
    /**
216
     * Obtiene el rango de verde del filtro de transparencia de la pila
217
     * @return rango de verde
218
     */
219
    public int[][] getTransparecyG() {
220
        for (int i = 0; i < filterStack.lenght(); i++) {
221
            if (filterStack.get(i) instanceof TransparencyImageFilter ||
222
                    filterStack.get(i) instanceof TransparencyShortFilter) {
223
                return ((TransparencyFilter) filterStack.get(i)).rangesG;
224
            }
225
        }
226

  
227
        return null;
228
    }
229

  
230
    /**
231
     * Obtiene el rango de azul del filtro de transparencia de la pila
232
     * @return rango de azul
233
     */
234
    public int[][] getTransparecyB() {
235
        for (int i = 0; i < filterStack.lenght(); i++) {
236
            if (filterStack.get(i) instanceof TransparencyImageFilter ||
237
                    filterStack.get(i) instanceof TransparencyShortFilter) {
238
                return ((TransparencyFilter) filterStack.get(i)).rangesB;
239
            }
240
        }
241

  
242
        return null;
243
    }
244

  
245
    /**
246 205
     * A?ade un filtro de eliminado de bandas. Las pone a 0
247 206
     * @param bands
248 207
     */
......
605 564

  
606 565
            if (rf instanceof TransparencyFilter) {
607 566
                filterList.add("filter.transparency.active=true");
608
                filterList.add("filter.transparency.rangeR=" +
609
                               rangeToString(((TransparencyFilter) rf).getRangeR()));
610
                filterList.add("filter.transparency.rangeG=" +
611
                               rangeToString(((TransparencyFilter) rf).getRangeG()));
612
                filterList.add("filter.transparency.rangeB=" +
613
                               rangeToString(((TransparencyFilter) rf).getRangeB()));
567
                for(int j=0;j<((TransparencyFilter) rf).rangesList.size();j++)
568
                	filterList.add("filter.transparency.transparencyRange"+j+"="+
569
                			((TransparencyRange)((TransparencyFilter) rf).rangesList.get(j)).getStrEntry());
614 570
            } else if (rf instanceof LinearEnhancementFilter) {
615 571
                filterList.add("filter.enhanced.active=true");
616 572
                filterList.add("filter.enhanced.remove=" +
......
688 644
                int[][] r = null;
689 645
                int[][] g = null;
690 646
                int[][] b = null;
691

  
647
                
648
                ArrayList list = new ArrayList();
692 649
                for (int propFilter = 0;propFilter < filters.size();propFilter++) {
693 650
                    String elem = (String) filters.get(propFilter);
694 651

  
695
                    if (elem.startsWith("filter.transparency.rangeR")) {
652
                    //TODO: Para compatibilidad con versiones anteriores hay que hacer que a partir de esto se cree un filtro
653
                    /*if (elem.startsWith("filter.transparency.rangeR")) {
696 654
                        r = stringToRange(getValue(elem));
697 655
                        filters.remove(propFilter);
698 656
                        propFilter--;
......
708 666
                        b = stringToRange(getValue(elem));
709 667
                        filters.remove(propFilter);
710 668
                        propFilter--;
669
                    }*/
670
                    if (elem.startsWith("filter.transparency.transparencyRange")) {
671
                    	TransparencyRange tr = new TransparencyRange();
672
                    	String value = getValue(elem);
673
                    	tr.setStrEntry(value);
674
                    	int[] red = new int[2];
675
                		int[] green = new int[2];
676
                		int[] blue = new int[2];
677
                		boolean and = true;
678
                		try{
679
                			and = TransparencyRange.stringToInterval(value, red, green, blue);
680
                			if(red[0] == -1)
681
                				red = null;
682
                			if(green[0] == -1)
683
                				green = null;
684
                			if(blue[0] == -1)
685
                				blue = null;
686
                		}catch(IOException e){
687
                			e.printStackTrace();
688
                		}
689
                		tr.setAnd(and);
690
                		tr.setRed(red);
691
                		tr.setGreen(green);
692
                		tr.setBlue(blue);
693
                		list.add(tr);
694
                        filters.remove(propFilter);
695
                        propFilter--;
711 696
                    }
712 697
                }
713 698

  
714
                this.addTransparencyFilter(r, g, b, 0x10, 0xff, 0xff, 0xff);
699
                this.addTransparencyFilter(list, 0x10, 0xff, 0xff, 0xff);
700
                                   
715 701
                filteri = -1;
716 702
            }
717 703

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/io/raster/TransparencyShortFilter.java
50 50
    }
51 51

  
52 52
    /**
53
     * Para un vector de rangos de una banda concreta, si el punto pasado como par?metro
54
     * en la banda concreta est? en el rango especificado se asigna al valor de transparencia
55
     * por defecto.
56
     * @param range
57
     * @param banda
58
     * @param px
53
     * Asigna al pixel pasado como par?metro como transparente con 
54
     * el color de transparencia que est? seleccionado
55
     * @param px Pixel a asignarle transparencia
59 56
     */
60
    private void processRange(int[][] range, int banda, int[] px) {
61
        for (int i = 0; i < range.length; i++) {
62
            if (((px[banda] >= range[i][0]) && (px[banda] <= range[i][1]))) {
63
                px[3] = this.alpha;
64
                px[0] = this.transparencyColorRed;
65
                px[1] = this.transparencyColorGreen;
66
                px[2] = this.transparencyColorBlue;
67
            }
68
        }
57
    private void setPixelTransparent(int[] px){
58
		px[3] = this.alpha;
59
        px[0] = this.transparencyColorRed;
60
        px[1] = this.transparencyColorGreen;
61
        px[2] = this.transparencyColorBlue;	
69 62
    }
63
    
64
    /**     
65
     * @param range rango
66
     * @param banda banda
67
     * @param px    pixel
68
     */
69
    private void processRange(int[] px) {
70
    	for (int i = 0; i < rangesList.size(); i++) {
71
    		TransparencyRange tr = ((TransparencyRange)rangesList.get(i));
70 72

  
73
    		if(tr.isAnd()){
74
    			if(tr.getRed() != null)
75
    				if (px[0] < tr.getRed()[0] || px[0] > tr.getRed()[1])
76
    					continue;
77
    			if(tr.getGreen() != null)
78
    				if (px[1] < tr.getGreen()[0] || px[1] > tr.getGreen()[1])
79
    					continue;
80
    			if(tr.getBlue() != null)
81
    				if (px[2] < tr.getBlue()[0] || px[2] > tr.getBlue()[1])
82
    					continue;
83
    			if(tr.getRed() != null || tr.getGreen() != null || tr.getBlue() != null)
84
    				setPixelTransparent(px);
85
    			
86
    		}else{
87
    			if(tr.getRed() != null){
88
    				if (px[0] >= tr.getRed()[0] && px[0] <= tr.getRed()[1]){
89
    					setPixelTransparent(px);
90
    					continue;
91
    				}
92
    			}
93
    			if(tr.getGreen() != null){
94
    				if (px[1] >= tr.getGreen()[0] && px[1] <= tr.getGreen()[1]){
95
    					setPixelTransparent(px);
96
    					continue;
97
    				}
98
    			}
99
    			if(tr.getBlue() != null){
100
    				if (px[2] >= tr.getBlue()[0] && px[2] <= tr.getBlue()[1]){
101
    					setPixelTransparent(px);
102
    					continue;
103
    				}
104
    			}
105
    		}
106
    	}
107
    	
108
    }
109

  
71 110
    /* (non-Javadoc)
72 111
     * @see org.cresques.io.raster.IRasterFilter#process(int, int)
73 112
     */
74 113
    public void process(int x, int y) {
75 114
        raster.getElemInt(x, y, px);
76

  
77
        if (rangesR != null) {
78
            processRange(rangesR, 0, px);
79
        }
80

  
81
        if (rangesG != null) {
82
            processRange(rangesG, 1, px);
83
        }
84

  
85
        if (rangesB != null) {
86
            processRange(rangesB, 2, px);
87
        }
88

  
115
        processRange(px);
89 116
        raster.setElemInt(x, y, px);
90 117
    }
91 118

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/AddRemoveButtonsPanel.java
1
package org.cresques.ui.raster;
2

  
3
import javax.swing.JPanel;
4
import javax.swing.JButton;
5

  
6
import java.awt.Color;
7
import java.awt.GridBagLayout;
8
import java.awt.GridBagConstraints;
9
import java.awt.FlowLayout;
10
import javax.swing.ImageIcon;
11

  
12
public class AddRemoveButtonsPanel extends JPanel {
13

  
14
	private JPanel pBorder = null;
15
	private JButton bAdd = null;
16
	private JButton bRemove = null;
17

  
18
	/**
19
	 * This is the default constructor
20
	 */
21
	public AddRemoveButtonsPanel() {
22
		super();
23
		initialize();
24
	}
25

  
26
	/**
27
	 * This method initializes this
28
	 * 
29
	 * @return void
30
	 */
31
	private void initialize() {
32
		FlowLayout flowLayout = new FlowLayout();
33
		flowLayout.setHgap(0);
34
		flowLayout.setVgap(0);
35
		this.setLayout(flowLayout);
36
		this.setSize(26, 52);
37
		this.add(getJPanel(), null);
38
	}
39

  
40
	/**
41
	 * This method initializes jPanel	
42
	 * 	
43
	 * @return javax.swing.JPanel	
44
	 */
45
	private JPanel getJPanel() {
46
		if (pBorder == null) {
47
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
48
			gridBagConstraints1.insets = new java.awt.Insets(3,3,3,3);
49
			gridBagConstraints1.gridy = 1;
50
			gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;
51
			gridBagConstraints1.gridx = 0;
52
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
53
			gridBagConstraints.insets = new java.awt.Insets(3,3,3,3);
54
			gridBagConstraints.gridy = 0;
55
			gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
56
			gridBagConstraints.gridx = 0;
57
			pBorder = new JPanel();
58
			pBorder.setLayout(new GridBagLayout());
59
			pBorder.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0));
60
			pBorder.add(getBAdd(), gridBagConstraints);
61
			pBorder.add(getBRemove(), gridBagConstraints1);
62
		}
63
		return pBorder;
64
	}
65

  
66
	/**
67
	 * This method initializes jButton	
68
	 * 	
69
	 * @return javax.swing.JButton	
70
	 */
71
	public JButton getBAdd() {
72
		if (bAdd == null) {
73
			bAdd = new JButton();
74
			bAdd.setPreferredSize(new java.awt.Dimension(20,20));
75
			bAdd.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/forward.png"));
76
		}
77
		return bAdd;
78
	}
79

  
80
	/**
81
	 * This method initializes jButton1	
82
	 * 	
83
	 * @return javax.swing.JButton	
84
	 */
85
	public JButton getBRemove() {
86
		if (bRemove == null) {
87
			bRemove = new JButton();
88
			bRemove.setPreferredSize(new java.awt.Dimension(20,20));
89
			bRemove.setIcon(new ImageIcon("./gvSIG/extensiones/com.iver.cit.gvsig/images/backward.png"));
90
		}
91
		return bRemove;
92
	}
93
	
94
	/**
95
	 * Activa o desactiva el control
96
	 * @param enable True activa el control y false lo desactiva
97
	 */
98
	public void setControlEnabled(boolean enabled){
99
		this.getBAdd().setEnabled(enabled);
100
		this.getBRemove().setEnabled(enabled);
101
	}
102

  
103
}
0 104

  
trunk/libraries/libCq CMS for java.old/src/org/cresques/ui/raster/FilterRasterDialogPanel.java
32 32
import java.awt.event.MouseEvent;
33 33
import java.awt.event.MouseListener;
34 34
import java.io.IOException;
35
import java.util.ArrayList;
35 36
import java.util.TreeMap;
36 37

  
38
import javax.swing.JList;
37 39
import javax.swing.JPanel;
38 40
import javax.swing.event.ChangeEvent;
39 41
import javax.swing.event.ChangeListener;
40 42

  
41 43
import org.cresques.io.GeoRasterFile;
44
import org.cresques.io.raster.TransparencyRange;
42 45
import org.cresques.ui.DefaultTabPanel;
43 46

  
44 47

  
......
83 86
     * Variable que contiene el panel de informaci?n de raster. 
84 87
     */
85 88
    protected InfoPanel pInfo = null;
86
    private int[][] rangeRed = null;
87
    private int[][] rangeGreen = null;
88
    private int[][] rangeBlue = null;
89

  
89
   
90 90
    /**
91 91
     * Propiedades guardadas en una matriz Nx2 con la forma propiedad/valor.
92 92
     */
......
152 152

  
153 153
        pTrans.getOpacityCheck().addActionListener(this);
154 154
        pTrans.getTransparencyCheck().addActionListener(this);
155
        pTrans.getTRojo().addActionListener(this);
156
        pTrans.getTVerde().addActionListener(this);
157
        pTrans.getTAzul().addActionListener(this);
158 155
        pTrans.getOpacitySlider().addChangeListener(this);
159 156
        pTrans.getOpacityText().addActionListener(this);
160 157
        pTrans.getOpacityText().addFocusListener(this);
161
        pTrans.getTRojo().addFocusListener(this);
162
        pTrans.getTVerde().addFocusListener(this);
163
        pTrans.getTAzul().addFocusListener(this);
164
        pTrans.getTRojo().addMouseListener(this);
165
        pTrans.getTVerde().addMouseListener(this);
166
        pTrans.getTAzul().addMouseListener(this);
167 158
        pTrans.addFocusListener(this);
168 159
        this.getTab().addFocusListener(this);
169 160

  
......
266 257
        if (e.getSource().equals(pTrans.getTransparencyCheck())) {
267 258
            //Check de opacidad activado -> Activar controles de opacidad
268 259
            if (pTrans.getTransparencyCheck().isSelected()) {
269
                if (nbands == 1) {
270
                    pTrans.getTRojo().setEnabled(true);
271
                    pTrans.getTVerde().setEnabled(false);
272
                    pTrans.getTAzul().setEnabled(false);
273
                }
274

  
275
                if (nbands == 2) {
276
                    pTrans.getTRojo().setEnabled(true);
277
                    pTrans.getTVerde().setEnabled(true);
278
                    pTrans.getTAzul().setEnabled(false);
279
                }
280

  
281
                if (nbands >= 3) {
282
                    pTrans.getTRojo().setEnabled(true);
283
                    pTrans.getTVerde().setEnabled(true);
284
                    pTrans.getTAzul().setEnabled(true);
285
                }
286
            } else {
287
                pTrans.getTRojo().setEnabled(false);
288
                pTrans.getTVerde().setEnabled(false);
289
                pTrans.getTAzul().setEnabled(false);
290
            }
260
            	pTrans.getPTranspByPixel().setControlEnabled(true);
261
            	pTrans.getPTranspByPixel().getPRGBInput().setActiveBands(nbands);
262
            }else
263
            	pTrans.getPTranspByPixel().setControlEnabled(false);
291 264
        }
292 265

  
293 266
        //Evento sobre el textfield de opacidad
......
295 268
            checkOpacityText();
296 269
        }
297 270

  
298
        //Evento sobre el textfield de valor para el Rojo
299
        if (e.getSource().equals(pTrans.getTRojo())) {
300
            try {
301
                rangeRed = getTransparencyValues(pTrans.getTRojo().getText());
302
            } catch (IOException exc) {
303
                pTrans.getTRojo().setText("");
304
            }
305
        }
306

  
307
        //Evento sobre el textfield de valor para el Verde
308
        if (e.getSource().equals(pTrans.getTVerde())) {
309
            try {
310
                rangeGreen = getTransparencyValues(pTrans.getTVerde().getText());
311
            } catch (IOException exc) {
312
                pTrans.getTVerde().setText("");
313
            }
314
        }
315

  
316
        //Evento sobre el textfield de valor para el Azul
317
        if (e.getSource().equals(pTrans.getTAzul())) {
318
            try {
319
                rangeBlue = getTransparencyValues(pTrans.getTAzul().getText());
320
            } catch (IOException exc) {
321
                pTrans.getTAzul().setText("");
322
            }
323
        }
324

  
325 271
        //Evento sobre el checkbox de Recorte de colas
326 272
        if (e.getSource().equals(pEnhan.getTailCheck())) {
327 273
            if (pEnhan.getTailCheck().isSelected()) {
......
335 281
        if (e.getSource().equals(pEnhan.getTailText())) {
336 282
            checkTailText();
337 283
        }
338
    }
284
    } 
339 285

  
340 286
    /**
341
     * Obtiene el rango de valores a partir de la cadena de
342
     * texto introducida por el usuario.
343
     * @param values
287
     * Asigna valores para los rangos.
288
     * @param ranges
344 289
     */
345
    private int[][] getTransparencyValues(String values)
346
                                   throws IOException {
347
        int[][] rangeTransparency = null;
348

  
349
        for (int i = 0; i < values.length(); i++) {
350
            char c = values.charAt(i);
351

  
352
            //Control de caracter valido
353
            if ((c != ':') && (c != ',')) {
354
                try {
355
                    Integer.parseInt(String.valueOf(c));
356
                } catch (Exception exp) {
357
                    System.err.println("Caracteres incorrectos en la cadena:" +
358
                                       c);
359
                    throw new IOException("Caracteres incorrectos en la cadena.");
360
                }
361
            }
362

  
363
            //Control de comienzo por un simbolo
364
            if (values.startsWith(",") || values.startsWith(":") ||
365
                    values.endsWith(",") || values.endsWith(":")) {
366
                System.err.println("La cadena empieza o acaba con simbolos incorrectos");
367
                throw new IOException();
368
            }
369

  
370
            //Control de signos consecutivos
371
            if (i < (values.length() - 1)) {
372
                char cmas = values.charAt(i + 1);
373

  
374
                if (((c == ',') || (c == ':')) &&
375
                        ((cmas == ',') || (cmas == ':'))) {
376
                    System.err.println("Signos consecutivos");
377
                    throw new IOException();
378
                }
379
            }
380

  
381
            //Control de dos : seguidos con un n?mero en el medio
382
            if ((i < (values.length() - 3)) && (c == ':')) {
383
                int n = i + 1;
384

  
385
                while ((n < (values.length() - 1)) &&
386
                           (values.charAt(n) != ',') &&
387
                           (values.charAt(n) != ':'))
388
                    n++;
389

  
390
                char signoSgte = values.charAt(n);
391

  
392
                if (signoSgte == ':') {
393
                    System.err.println("Dos separadores de rango consecutivos");
394
                    throw new IOException();
395
                }
396
            }
397
        }
398

  
399
        //Obtenemos los valores de los intervalos
400
        if (!values.equals("")) {
401
            String[] t1 = null;
402
            t1 = values.split("\\,");
403
            rangeTransparency = new int[t1.length][2];
404

  
405
            for (int i = 0; i < t1.length; i++) {
406
                if (t1[i].indexOf(":") == -1) {
407
                    rangeTransparency[i][0] = rangeTransparency[i][1] = Integer.parseInt(t1[i]);
408
                } else {
409
                    String[] t2 = null;
410
                    t2 = t1[i].split("\\:");
411

  
412
                    if (Integer.parseInt(t2[1]) > Integer.parseInt(t2[0])) {
413
                        rangeTransparency[i][0] = Integer.parseInt(t2[0]);
414
                        rangeTransparency[i][1] = Integer.parseInt(t2[1]);
415
                    } else {
416
                        rangeTransparency[i][0] = Integer.parseInt(t2[1]);
417
                        rangeTransparency[i][1] = Integer.parseInt(t2[0]);
418
                    }
419
                }
420

  
421
                if ((rangeTransparency[i][0] < 0) ||
422
                        (rangeTransparency[i][0] > 255) ||
423
                        (rangeTransparency[i][1] < 0) ||
424
                        (rangeTransparency[i][1] > 255)) {
425
                    System.err.println("Valores fuera de rango (0-255)");
426
                    throw new IOException();
427
                }
428
            }
429

  
430
            return rangeTransparency;
431

  
432
            //for(int i=0;i<rangeTransparency.length;i++)
433
            //	System.out.println("("+rangeTransparency[i][0]+":"+rangeTransparency[i][1]+")");
434
        }
435

  
436
        return null;
290
    public void setRanges(ArrayList ranges) {      
291
      if(ranges != null){    	  
292
    	  TransparencyByPixelPanel panel = (TransparencyByPixelPanel)pTrans.getPTranspByPixel();
293
    	  pTrans.getTransparencyCheck().setSelected(true);
294
    	  panel.setControlEnabled(true);
295
    	  panel.setEntries(ranges);
296
	      for(int i=0;i<ranges.size();i++)
297
	    	  panel.getListModel().addElement( ((TransparencyRange)ranges.get(i)).getStrEntry() );
298
      }
437 299
    }
438 300

  
439 301
    /**
440
     * Devuelve el rango de valores para poner transparencia en el Rojo
441
     * @return
442
     */
443
    public int[][] getRangeRed() {
444
        return rangeRed;
445
    }
446

  
447
    /**
448
     * Devuelve el rango de valores para poner transparencia en el Verde
449
     * @return
450
     */
451
    public int[][] getRangeGreen() {
452
        return rangeGreen;
453
    }
454

  
455
    /**
456
     * Devuelve el rango de valores para poner transparencia en el Azul
457
     * @return
458
     */
459
    public int[][] getRangeBlue() {
460
        return rangeBlue;
461
    }
462

  
463
    /**
464
     * Asigna valore para los rangos
465
     * @param red
466
     * @param green
467
     * @param blue
468
     */
469
    public void setRanges(int[][] red, int[][] green, int[][] blue) {
470
        rangeRed = red;
471
        rangeGreen = green;
472
        rangeBlue = blue;
473

  
474
        if (pTrans != null) {
475
            StringBuffer rango = new StringBuffer();
476

  
477
            if (red != null) {
478
                for (int i = 0; i < red.length; i++) {
479
                    if (red[i][0] == red[i][1]) {
480
                        rango.append(String.valueOf(red[i][0]) + ",");
481
                    } else {
482
                        rango.append(String.valueOf(red[i][0]) + ":" +
483
                                     String.valueOf(red[i][1]) + ",");
484
                    }
485
                }
486

  
487
                String t = rango.toString();
488

  
489
                if (t.endsWith(",")) {
490
                    t = t.substring(0, t.length() - 1);
491
                }
492

  
493
                pTrans.getTRojo().setText(t);
494
                pTrans.setActiveTransparencyControl(true);
495
            }
496

  
497
            if (green != null) {
498
                rango = new StringBuffer();
499

  
500
                for (int i = 0; i < green.length; i++) {
501
                    if (green[i][0] == green[i][1]) {
502
                        rango.append(String.valueOf(green[i][0]) + ",");
503
                    } else {
504
                        rango.append(String.valueOf(green[i][0]) + ":" +
505
                                     String.valueOf(green[i][1]) + ",");
506
                    }
507
                }
508

  
509
                String t = rango.toString();
510

  
511
                if (t.endsWith(",")) {
512
                    t = t.substring(0, t.length() - 1);
513
                }
514

  
515
                pTrans.getTVerde().setText(t);
516
                pTrans.setActiveTransparencyControl(true);
517
            }
518

  
519
            if (blue != null) {
520
                rango = new StringBuffer();
521

  
522
                for (int i = 0; i < blue.length; i++) {
523
                    if (blue[i][0] == blue[i][1]) {
524
                        rango.append(String.valueOf(blue[i][0]) + ",");
525
                    } else {
526
                        rango.append(String.valueOf(blue[i][0]) + ":" +
527
                                     String.valueOf(blue[i][1]) + ",");
528
                    }
529
                }
530

  
531
                String t = rango.toString();
532

  
533
                if (t.endsWith(",")) {
534
                    t = t.substring(0, t.length() - 1);
535
                }
536

  
537
                pTrans.setActiveTransparencyControl(true);
538
                pTrans.getTAzul().setText(t);
539
            }
540
        }
541
    }
542

  
543
    /**
544 302
     * A?ade las bandas de los georrasterfile a los paneles 
545 303
     * que lo necesitan
546 304
     * @param files
......
608 366
        }
609 367
    }
610 368

  
611
    /**
612
     * Llama a las funciones que obtienen los valores de los pixels a los que se
613
     * quiere aplicar transparencia desde las cajas de texto.
614
     */
615
    public void checkTransparencyValues() {
616
        if (!pTrans.getTRojo().getText().equals("")) {
617
            try {
618
                rangeRed = getTransparencyValues(pTrans.getTRojo().getText());
619
            } catch (IOException exc) {
620
                pTrans.getTRojo().setText("");
621
            }
622
        }
623

  
624
        if (!pTrans.getTVerde().getText().equals("")) {
625
            try {
626
                rangeGreen = getTransparencyValues(pTrans.getTVerde().getText());
627
            } catch (IOException exc) {
628
                pTrans.getTVerde().setText("");
629
            }
630
        }
631

  
632
        if (!pTrans.getTAzul().getText().equals("")) {
633
            try {
634
                rangeBlue = getTransparencyValues(pTrans.getTAzul().getText());
635
            } catch (IOException exc) {
636
                pTrans.getTAzul().setText("");
637
            }
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff