Revision 11004

View differences:

trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/ui/HistogramPanel.java
77 77
	 * bandas no son de visualizaci?n (bandas de la imagen en disco) tendr? un elemento
78 78
	 * por cada una. 
79 79
	 */
80
	public boolean[]					showBands = {true, true, true};
80
//	public boolean[]					showBands = {true, true, true};
81 81
	
82 82
	/**
83 83
	 * Tipo de histograma 
......
131 131
	 */
132 132
	public GraphicContainer getGraphicContainer() {
133 133
		if (graphicContainer == null) {
134
			graphicContainer = new GraphicContainer( false);
134
			graphicContainer = new GraphicContainer(true);
135 135
		}
136 136
		return graphicContainer;
137 137
	}
......
339 339
		getHistogramPanelListener().comboEventEnable = false;
340 340
		getJComboBands().removeAllItems();
341 341
		getJComboBands().addItem(Messages.getText("todas"));
342
		showBands = new boolean[bands];
342
//		showBands = new boolean[bands];
343 343
		for(int i = 0; i < bands; i++){
344 344
			getJComboBands().addItem("Band "+String.valueOf(i));
345
			showBands[i] = true;
345
//			showBands[i] = true;
346 346
		}
347 347
		getHistogramPanelListener().comboEventEnable = panelInizialited;
348 348
	}
......
380 380
	 */
381 381
	public void setRGBInBandList(){
382 382
		getHistogramPanelListener().comboEventEnable = false;
383
		boolean[] list = {true, true, true};
384
		showBands = list;
383
//		boolean[] list = {true, true, true};
384
//		showBands = list;
385 385
		getJComboBands().removeAllItems();
386 386
		getJComboBands().addItem(Messages.getText("todas"));
387 387
		getJComboBands().addItem("R");
......
391 391
	}
392 392
	
393 393
	/**
394
	 * A?ade o elimina una banda de la visualizaci?n. Si la banda se est? visualizando
395
	 * se elimina y si no entonces se muestra
396
	 * @param band banda a visualizar o borrar del gr?fico
397
	 */
398
	public void addOrRemoveGraphicBand(int band){
399
		if (band > showBands.length)
400
			return;
401
		showBands[band] = !showBands[band];
402
	}
403
	
404
	/**
405
	 * Limpia la gr?fica
406
	 */
407
	public void cleanChart(){
408
		GraphicChartPanel gcp = graphicContainer.getPGraphic();
409
		gcp.cleanChart();
410
		for(int i = 0; i < showBands.length; i++)
411
			showBands[i] = false;
412
	}
413
	
414
	/**
415 394
	 * Obtiene el tipo de datos de la fuente de la imagen
416 395
	 * @return tipo de datos de la fuente de la imagen
417 396
	 */
......
428 407
	}
429 408

  
430 409
	/**
431
	 * Obtiene la lista de bandas que se muestran en el histograma
432
	 * @return Lista de bandas donde cada elemento es un booleano. True si la banda
433
	 * se muestra y false si no se muestra.
410
	 * Limpia la gr?fica
434 411
	 */
435
	public boolean[] getBandListShowInChart(){
436
		return showBands;
412
	public void cleanChart(){
413
		GraphicChartPanel gcp = graphicContainer.getPGraphic();
414
		gcp.cleanChart();
437 415
	}
438 416

  
439 417
	/**
440
	 * Asigna la lista de bandas que se muestran en el histograma
441
	 * @param Lista de bandas donde cada elemento es un booleano. True si la banda
442
	 * se muestra y false si no se muestra.
443
	 */
444
	public void setBandListShowInChart(boolean[] showBands) {
445
		this.showBands = showBands;
446
	}
447
	
448
	/**
449 418
	 * Obtiene el tipo de histograma a mostrar
450 419
	 * @return acumulado/no acumulado
451 420
	 */
......
469 438
	 */
470 439
	public double[] getBoxesValues(){
471 440
		double[] v = new double[2];
472
		double[] currentValues = getGraphicContainer().getBoxesValues();
441
		double[] currentValues = new double[2];
442
		currentValues[0] = getGraphicContainer().getX2();
443
		currentValues[1] = getGraphicContainer().getX1();
473 444
		switch (requestDataType){
474 445
			case RasterBuf.TYPE_BYTE: 	v[0] = (currentValues[0] * RasterUtilities.MAX_BYTE_BIT_VALUE) / 100; 
475 446
				v[1] = (currentValues[1] * RasterUtilities.MAX_BYTE_BIT_VALUE) / 100;
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/histogram/HistogramPanelListener.java
21 21
import java.awt.event.ActionEvent;
22 22
import java.awt.event.ActionListener;
23 23
import java.awt.event.KeyEvent;
24
import java.awt.event.KeyListener;
25 24
import java.util.ArrayList;
26 25

  
27 26
import javax.swing.JButton;
28 27
import javax.swing.JComboBox;
29 28

  
29
import org.gvsig.gui.beans.graphic.GraphicEvent;
30
import org.gvsig.gui.beans.graphic.GraphicListener;
30 31
import org.gvsig.gui.beans.incrementabletask.IncrementableEvent;
31 32
import org.gvsig.gui.beans.incrementabletask.IncrementableListener;
32 33
import org.gvsig.gui.beans.incrementabletask.IncrementableTask;
33 34
import org.gvsig.raster.util.Histogram;
34 35
import org.gvsig.raster.util.IHistogramable;
35 36
import org.gvsig.rastertools.histogram.ui.HistogramPanel;
36

  
37
import com.iver.utiles.swing.threads.Cancellable;
38 37
/**
39 38
 * Listener para eventos del panel de histograma
40 39
 *
......
42 41
 * @author Nacho Brodin (brodin_ign@gva.es)
43 42
 * @author Borja Sanchez Zamorano (borja.sanchez@iver.es)
44 43
 */
45
public class HistogramPanelListener implements ActionListener, KeyListener, IncrementableListener {
44
public class HistogramPanelListener implements IncrementableListener, GraphicListener, ActionListener {
46 45
	private HistogramPanel		histogramPanel = null;
47 46
	private IncrementableTask	incrementableTask = null;
48 47
	private HistogramProcess	histogramProcess = null;
......
50 49
	private int								bandCount = 0;
51 50

  
52 51
	public boolean						comboEventEnable = false;
52
	
53
	private boolean[]					showBands = {true, true, true};
54

  
53 55
		
54 56
	public HistogramPanelListener(HistogramPanel p){
55 57
		histogramPanel = p;
56 58
	}
57 59
	
58 60
	public void setControlListeners(){
59
		histogramPanel.getGraphicContainer().getPlusButtonControlLeft().addActionListener(this);
60
		histogramPanel.getGraphicContainer().getPlusButtonControlRight().addActionListener(this);
61
		histogramPanel.getGraphicContainer().getLessButtonControlLeft().addActionListener(this);
62
		histogramPanel.getGraphicContainer().getLessButtonControlRight().addActionListener(this);
63
		histogramPanel.getGraphicContainer().getTextControlRight().addKeyListener(this);
64
		histogramPanel.getGraphicContainer().getTextControlLeft().addKeyListener(this);
61
		histogramPanel.getGraphicContainer().addValueChangedListener(this);
65 62
	}
66 63

  
67 64
	
68
	public void keyPressed(KeyEvent e) {
69
		if (e.getKeyCode() == 10) {
70
			updateStatistic();
71
			updateGraphic();
72
		}
73
	}
74

  
75 65
	private void updateStatistic() {
76 66
//		TODO Actualizar tabla de los histogramas.
77 67
//		histogramPanel.setStatistic(DatasetStatistics.getBasicStatsFromHistogram(getLastHistogram(), (int)panel.getBoxesValues()[1], (int)panel.getBoxesValues()[0], panel.showBands));
78 68
	}
79 69

  
80

  
81 70
	public void actionPerformed(ActionEvent e) {
82
		//Botones de m?s y menos
83
		if (e.getSource() == histogramPanel.getGraphicContainer().getPlusButtonControlLeft()  ||
84
				e.getSource() == histogramPanel.getGraphicContainer().getLessButtonControlLeft()  ||
85
				e.getSource() == histogramPanel.getGraphicContainer().getPlusButtonControlRight() ||
86
				e.getSource() == histogramPanel.getGraphicContainer().getLessButtonControlRight() ) {
87
			updateStatistic();
88
			updateGraphic();
89
			return;
90
		}
91
		
92 71
		//--------------------------------------
93 72
		//Cambiar las bandas en el combo
94 73
		JComboBox cbb = histogramPanel.getJComboBands();
95 74
		if (comboEventEnable && (e.getSource() == cbb)) {
96 75
			if (cbb.getSelectedItem() == null) return;
97
			updateGraphic();
98
/*			
99
			if(cbb.getSelectedIndex() == 0) {
100
				boolean[] list = histogramPanel.getBandListShowInChart();
101
				for (int i = 0; i < list.length; i++)
102
					list[i] = true;
103
				histogramPanel.setBandListShowInChart(list);
104
				return;
105
			}
106
			if (cbb.getSelectedItem().equals("R")) {
107
				histogramPanel.addOrRemoveGraphicBand(0);
108
				return;
109
			}
110
			if(cbb.getSelectedItem().equals("G")) {
111
				histogramPanel.addOrRemoveGraphicBand(1);
112
				return;
113
			}
114
			if(cbb.getSelectedItem().equals("B")) {
115
				histogramPanel.addOrRemoveGraphicBand(2);
116
				return;
117
			}
118
			for (int i = 0; i < HistogramPanel.MAXBANDS; i++) {
76
			
77
			if (cbb.getSelectedIndex() == 0)
78
				for (int i = 0; i < showBands.length; i++)
79
					showBands[i] = true;
80
			if (cbb.getSelectedItem().equals("R")) addOrRemoveGraphicBand(0);
81
			if (cbb.getSelectedItem().equals("G")) addOrRemoveGraphicBand(1);
82
			if (cbb.getSelectedItem().equals("B")) addOrRemoveGraphicBand(2);
83
			for (int i = 0; i < HistogramPanel.MAXBANDS; i++)
119 84
				if (cbb.getSelectedItem().equals("Band "+i))
120
					histogramPanel.addOrRemoveGraphicBand(i);
121
			}
122
*/
85
					addOrRemoveGraphicBand(i);
86

  
87
			updateStatistic();
88
			updateGraphic();
123 89
			return;
124 90
		}
125 91
		
......
142 108
			
143 109
			//En caso de que el histograma se monte a partir de los datos reales ponemos el n?mero de bandas en el combo
144 110
			if (cbo.getSelectedIndex() == 1 || cbo.getSelectedIndex() == 2) {
111
				// TODO: Rellenar BandCount con el valor que toca
145 112
				histogramPanel.setBands(bandCount);
113
				showBands = new boolean[bandCount];
114
				for (int i = 0; i < showBands.length; i++)
115
					showBands[i] = true;
146 116
			}
147 117
			showHistogram();
148 118
			return;
......
170 140
	}
171 141
	
172 142
	/**
143
	 * A?ade o elimina una banda de la visualizaci?n. Si la banda se est? visualizando
144
	 * se elimina y si no entonces se muestra
145
	 * @param band banda a visualizar o borrar del gr?fico
146
	 */
147
	public void addOrRemoveGraphicBand(int band){
148
		if (band > showBands.length)
149
			return;
150
		showBands[band] = !showBands[band];
151
	}
152

  
153
	/**
173 154
	 * Limpia la gr?fica
174 155
	 */
175 156
	public void cleanChart(){
176 157
		histogramPanel.cleanChart();
177
		for(int i = 0; i < histogramPanel.showBands.length; i++)
178
			histogramPanel.showBands[i] = false;
158
		for(int i = 0; i < showBands.length; i++)
159
			showBands[i] = false;
179 160
	}
180 161

  
181
	public void keyReleased(KeyEvent e) {
182
	}
183

  
184
	public void keyTyped(KeyEvent e) {
185
	}
186

  
187 162
	private void updateGraphic() {
188 163
		long[][] auxHistogram = lastHistogram.getHistogramByType(Histogram.getType(histogramPanel.getJComboBoxTipo().getSelectedIndex()));
189 164
		if (auxHistogram == null) return;
......
191 166
		int first = 0;
192 167
		int end = auxHistogram[0].length;
193 168

  
194
		first = (int) ((histogramPanel.getGraphicContainer().getBoxesValues()[1]*auxHistogram[0].length)/100);
195
		end = (int) ((histogramPanel.getGraphicContainer().getBoxesValues()[0]*auxHistogram[0].length)/100);
169
		first = (int) ((histogramPanel.getGraphicContainer().getX1()*auxHistogram[0].length)/100);
170
		end = (int) ((histogramPanel.getGraphicContainer().getX2()*auxHistogram[0].length)/100);
196 171

  
197
		int bands = (histogramPanel.getJComboBands().getSelectedIndex()==0?auxHistogram.length:1);
172
		int bandCount = 0;
173
		for (int i = 0; i < showBands.length; i++) {
174
			if (showBands[i]) bandCount++;
175
		}
198 176

  
199
		int[][] newHistogram = new int[bands][end - first];
200
		String[] bandNames = new String[bands];
177
		int[][] newHistogram = new int[bandCount][end - first];
178
		String[] bandNames = new String[bandCount];
201 179
		
202 180
		bandCount = auxHistogram.length;
203 181

  
204
		for (int iBand=0; iBand<bands; iBand++) {
182
		int numBand = 0;
183
		for (int iBand = 0; iBand < showBands.length; iBand++) {
184
			if (!showBands[iBand]) continue;
185
			
205 186
			for (int j=first; j<end; j++)
206
				newHistogram[iBand][j-first] = (int) auxHistogram[(bands>1?iBand:histogramPanel.getJComboBands().getSelectedIndex()-1)][j];
207
			bandNames[iBand] = iBand + "";
187
				newHistogram[numBand][j-first] = (int) auxHistogram[iBand][j];
188
			bandNames[numBand] = iBand + "";
189

  
190
			numBand++;
208 191
		}
209 192

  
210 193
		histogramPanel.getGraphicContainer().getPGraphic().cleanChart();
......
237 220
		if (histogramProcess == null) return;
238 221
		histogramProcess.suspend();
239 222
	}
223

  
224
	public void actionValueChanged(GraphicEvent e) {
225
		updateStatistic();
226
		updateGraphic();
227
	}
240 228
}
trunk/libraries/libUIComponent/src-test/org/gvsig/gui/beans/doubleslider/TestDoubleSlider.java
1
package org.gvsig.gui.beans.doubleslider;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Dimension;
5

  
6
import javax.swing.JButton;
7
import javax.swing.JFrame;
8
import javax.swing.JPanel;
9

  
10
import org.gvsig.gui.beans.doubleslider.DoubleSlider;
11

  
12
public class TestDoubleSlider {
13
	
14
	private JFrame jFrame = new JFrame();
15
	private DoubleSlider doubleSlider = null;
16
	private JPanel jPanel = null;
17

  
18
	public TestDoubleSlider() {
19
		jFrame = new JFrame();
20
		jFrame.getContentPane().setLayout(new BorderLayout());
21
		jFrame.setSize(new Dimension(498, 267));
22
		jFrame.setContentPane(getJPanel());
23
		jFrame.show();
24
	}
25

  
26
	/**
27
	 * This method initializes multiSlider	
28
	 * 	
29
	 * @return borsanza.src.multislider.MultiSlider	
30
	 */
31
	private DoubleSlider getMultiSlider() {
32
		if (doubleSlider == null) {
33
			doubleSlider = new DoubleSlider();
34
			doubleSlider.setMinimum(0);
35
			doubleSlider.setMaximum(255);
36
		}
37
		return doubleSlider;
38
	}
39

  
40
	/**
41
	 * This method initializes jPanel	
42
	 * 	
43
	 * @return javax.swing.JPanel	
44
	 */
45
	private JPanel getJPanel() {
46
		if (jPanel == null) {
47
			jPanel = new JPanel();
48
			jPanel.setLayout(new BorderLayout());
49
			jPanel.add(getMultiSlider(), BorderLayout.CENTER);
50
		}
51
		return jPanel;
52
	}
53

  
54
	public static void main(String[] args) {
55
		new TestDoubleSlider();
56
	}
57
}
58

  
0 59

  
trunk/libraries/libUIComponent/src-test/org/gvsig/gui/beans/graphic/TestGraphic.java
4 4

  
5 5
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
6 6

  
7
public class TestGraphic {
7
public class TestGraphic implements GraphicListener {
8 8
	private JFrame 				frame=new JFrame();
9 9
	private GraphicContainer	graphic = null;
10 10
	
11 11
	public TestGraphic() throws NotInitializeException{
12 12
		graphic = new GraphicContainer(true);
13
		graphic.addValueChangedListener(this);
13 14
		frame.getContentPane().add(graphic);
14 15
		frame.setSize(500, 300);
15 16
		frame.show();
......
22 23
			System.out.println("Tabla no inicializada");
23 24
		}
24 25
	}
26

  
27
	public void actionValueChanged(GraphicEvent e) {
28
		System.out.println(graphic.getX1() + ":" + graphic.getX2());
29
	}
25 30
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/doubleslider/DoubleSliderEvent.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.gui.beans.doubleslider;
20

  
21
import java.util.EventObject;
22

  
23
public class DoubleSliderEvent extends EventObject {
24
	private static final long serialVersionUID = -684281519921935004L;
25

  
26
	public DoubleSliderEvent(Object source) {
27
		super(source);
28
	}
29
}
0 30

  
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/doubleslider/DoubleSliderListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.gui.beans.doubleslider;
20

  
21
import java.util.EventListener;
22

  
23
public interface DoubleSliderListener extends EventListener {
24
  public void actionValueChanged(DoubleSliderEvent e);
25
}
0 26

  
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/doubleslider/DoubleSlider.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.doubleslider;
20

  
21
import java.awt.Color;
22
import java.awt.Dimension;
23
import java.awt.Graphics;
24
import java.awt.Image;
25
import java.awt.event.MouseEvent;
26
import java.awt.event.MouseListener;
27
import java.awt.event.MouseMotionListener;
28
import java.util.ArrayList;
29
import java.util.Iterator;
30

  
31
import javax.swing.JComponent;
32

  
33
public class DoubleSlider extends JComponent implements MouseMotionListener, MouseListener {
34
	private static final long serialVersionUID = 663355422780987493L;
35

  
36
	Image bufferImage = null;
37
	int width, height = 0;
38
	Graphics bufferGraphics;
39
	int x1 = 0;
40
	int x2 = 100;
41

  
42
	int minimum = 0;
43
	int maximum = 100;
44

  
45
	private ArrayList actionCommandListeners = new ArrayList();
46
	private boolean bDoCallListeners = true;
47
	static private int eventId = Integer.MIN_VALUE;
48
	
49
	public DoubleSlider() {
50
		this.setPreferredSize(new Dimension(100, 21));
51
	}
52

  
53
	public void setMaximum(int value) {
54
		maximum = value;
55
		validateValues();
56
		refreshImage();
57
	}
58

  
59
	public void setMinimum(int value) {
60
		minimum = value;
61
		validateValues();
62
		refreshImage();
63
	}
64

  
65
	public void addNotify() {
66
		super.addNotify();
67

  
68
		addMouseMotionListener(this);
69
		addMouseListener(this);
70
		
71
		refreshImage();
72
	}	
73
	
74
	private Graphics getBufferGraphics() {
75
		int width2=getBounds().width;
76
		int height2=getBounds().height;
77
		if (width2<=0) width2=1;
78
		if (height2<=0) height2=1;
79

  
80
		if ((width!=width2) || (height!=height2)) { 
81
			bufferImage = createImage(width2, height2);
82
			if (bufferImage == null) return null;
83
			bufferGraphics = bufferImage.getGraphics();
84
		}
85

  
86
		width = width2;
87
		height = height2;
88
		
89
		return bufferGraphics;
90
	}
91

  
92
	public void redrawBuffer() {
93
		if (getBufferGraphics() == null) return;
94
		getBufferGraphics().setColor(this.getBackground());
95
		
96
		getBufferGraphics().fillRect(0,0,width,height);
97

  
98
		int color = 0;
99
		for (int i=1; i<=(width-1); i++) {
100
			color = (i*255)/width;
101
			getBufferGraphics().setColor(new Color(color,color,color));
102
			getBufferGraphics().drawLine(i,1,i,12);
103
		}
104

  
105
		drawTriangle(valuetopixel(x1), Color.BLACK);
106
		drawTriangle(valuetopixel(x2), Color.WHITE);
107
	}
108

  
109
	private void drawTriangle(int x, Color color) {
110
		getBufferGraphics().setColor(color);
111
		getBufferGraphics().drawLine(x, 14, x, 18);
112
		getBufferGraphics().drawLine(x-1, 16, x-1, 18);
113
		getBufferGraphics().drawLine(x+1, 16, x+1, 18);
114
		getBufferGraphics().drawLine(x-2, 18, x-2, 18);
115
		getBufferGraphics().drawLine(x+2, 18, x+2, 18);
116

  
117
		getBufferGraphics().setColor(Color.BLACK);
118
		getBufferGraphics().drawLine(x, 12, x-3, 19);
119
		getBufferGraphics().drawLine(x, 12, x+3, 19);
120
		getBufferGraphics().drawLine(x-3, 19, x+3, 19);
121
	}
122
	
123
	public void refreshImage() {
124
		redrawBuffer();
125
		if (bufferImage != null)
126
			getGraphics().drawImage(bufferImage, 0, 0, this);
127
		super.paint(getGraphics());
128
	}
129

  
130
	private int valuetopixel(int value) {
131
		return ((value-minimum)*(width-3)/(maximum-minimum)) + 1;
132
	}
133
	
134
	private int pixeltovalue(int value) {
135
		return (((value-1)*(maximum-minimum))/(width-3))+minimum;
136
	}
137
	
138
	public void paint(Graphics g) {
139
		redrawBuffer();
140
		g.drawImage(bufferImage, 0, 0, this);
141
		super.paint(g);
142
	}
143

  
144
	int valuePressed = 0;
145

  
146
	public void mousePressed(MouseEvent e) {
147
		if (e.getButton() != MouseEvent.BUTTON1) return;
148

  
149
		int aux = pixeltovalue(e.getX()+1);
150
		int aux2 = aux - x1;
151
		int aux3 = x2 - aux;
152
		if (aux3 < aux2)
153
			valuePressed = 2;
154
		else
155
			valuePressed = 1;
156

  
157
		changeValue(e.getX());
158
	}
159

  
160
	public void mouseReleased(MouseEvent e) {
161
		valuePressed = 0;
162
	}
163

  
164
	private void validateValues() {
165
		if (x1 < minimum) x1 = minimum;
166
		if (x1 > maximum) x1 = maximum;
167
		if (x2 < minimum) x2 = minimum;
168
		if (x2 > maximum) x2 = maximum;
169
	}
170

  
171
	public void setX1(int value) {
172
		x1 = value;
173
		if (x1 > x2) x2 = x1;
174
		validateValues();
175
		refreshImage();
176
	}
177
	
178
	public void setX2(int value) {
179
		x2 = value;
180
		if (x2 < x1) x1 = x2;
181
		validateValues();
182
		refreshImage();
183
	}
184
	
185
	public int getX1() {
186
		return x1;
187
	}
188
	
189
	public int getX2() {
190
		return x2;
191
	}
192
	
193
	private void changeValue(int pos) {
194
		if (valuePressed == 0) return;
195
		
196
		int aux = pixeltovalue(pos + 1);
197
		
198
		if (valuePressed == 1) setX1(aux);
199
		if (valuePressed == 2) setX2(aux);
200
		callValueChangedListeners();
201
//		System.out.println(x1 + ":" + x2);
202
	}
203

  
204
	public void mouseDragged(MouseEvent arg0) {
205
		changeValue(arg0.getX());
206
	}
207

  
208
	public void mouseMoved(MouseEvent e) {
209
	}
210
	public void mouseClicked(MouseEvent e) {
211
	}
212
	public void mouseEntered(MouseEvent e) {
213
	}
214
	public void mouseExited(MouseEvent e) {
215
	}
216
	
217
	public void addValueChangedListener(DoubleSliderListener listener) {
218
		if (!actionCommandListeners.contains(listener))
219
			actionCommandListeners.add(listener);
220
	}
221

  
222
	public void removeValueChangedListener(DoubleSliderListener listener) {
223
		actionCommandListeners.remove(listener);
224
	}
225
	
226
	private void callValueChangedListeners() {
227
		if (!bDoCallListeners)
228
			return;
229
		Iterator acIterator = actionCommandListeners.iterator();
230
		while (acIterator.hasNext()) {
231
			DoubleSliderListener listener = (DoubleSliderListener) acIterator.next();
232
			listener.actionValueChanged(new DoubleSliderEvent(this));
233
		}
234
		eventId++;
235
	}	
236
	
237
}
0 238

  
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/DoubleSliderControlPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package org.gvsig.gui.beans.graphic;
20

  
21
import java.awt.Color;
22
import java.awt.FlowLayout;
23

  
24
import javax.swing.JLabel;
25
import javax.swing.JPanel;
26

  
27
import org.gvsig.gui.beans.graphic.listeners.GraphicListener;
28

  
29
/**
30
 * 
31
 * Nacho Brodin (brodin_ign@gva.es)
32
 */
33

  
34
public class DoubleSliderControlPanel extends JPanel {
35
	private static final long serialVersionUID = -6123036808118349791L;
36
	private int 				width = 300, height = 25;
37
	private JLabel 				lLeft = null;
38
	private JLabel 				lRight = null;
39
	private GraphicListener 	graphicListener = null;
40
	private JPanel pRight = null;
41
	private JPanel pLeft = null;
42
	
43
	public DoubleSliderControlPanel(int width, int height, GraphicListener 	graphicListener) {
44
		super();
45
		this.width = width;
46
		this.height = height;
47
		this.graphicListener = graphicListener;
48
		initialize();
49
	}
50

  
51
	/**
52
	 * This method initializes this
53
	 * 
54
	 */
55
	private void initialize() {
56
        FlowLayout flowLayout = new FlowLayout();
57
        flowLayout.setHgap(0);
58
        flowLayout.setAlignment(java.awt.FlowLayout.LEFT);
59
        flowLayout.setVgap(0);
60
        
61
        /*lRight = new JLabel();
62
        lRight.setForeground(Color.RED);
63
        lRight.setText("T");
64
        lRight.setPreferredSize(new java.awt.Dimension(15,25));
65
        
66
        lLeft = new JLabel();
67
        lLeft.setForeground(Color.BLUE);
68
        lLeft.setText("T");
69
        lLeft.setPreferredSize(new java.awt.Dimension(15,25));
70
        this.setLayout(flowLayout);
71
        
72
        lRight.addMouseListener(graphicListener);
73
        lRight.addMouseMotionListener(graphicListener);
74
        lLeft.addMouseListener(graphicListener);
75
        lLeft.addMouseMotionListener(graphicListener);
76
        graphicListener.setLabels(lLeft, lRight);*/
77
       
78
        this.setLayout(flowLayout);
79
        this.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
80
        this.setSize(new java.awt.Dimension(width, height));
81
        this.setPreferredSize(new java.awt.Dimension(width, height));
82
  
83
        this.add(getPLeft(), null);
84
        this.add(getPRight(), null);
85
        graphicListener.setLabels(lLeft, lRight);
86
        
87
        //lLeft.setLocation(28, 4);
88
        //lRight.setLocation(470, 4);
89
        
90
	}
91

  
92
	/**
93
	 * This method initializes jPanel	
94
	 * 	
95
	 * @return javax.swing.JPanel	
96
	 */
97
	private JPanel getPRight() {
98
		if (pRight == null) {
99
			FlowLayout flowLayout1 = new FlowLayout();
100
			flowLayout1.setHgap(0);
101
			flowLayout1.setAlignment(java.awt.FlowLayout.RIGHT);
102
			flowLayout1.setVgap(0);
103
			lRight = new JLabel();
104
			lRight.setText("T");
105
			lRight.setForeground(Color.RED);
106
			lRight.setPreferredSize(new java.awt.Dimension(15,22));
107
			pRight = new JPanel();
108
			pRight.setLayout(flowLayout1);
109
			pRight.setPreferredSize(new java.awt.Dimension((width >> 1) - 2,20));
110
			pRight.setSize(width >> 1,20);
111
			pRight.add(lRight, null);
112
	        lRight.addMouseListener(graphicListener);
113
	        lRight.addMouseMotionListener(graphicListener);
114
		}
115
		return pRight;
116
	}
117

  
118
	/**
119
	 * This method initializes jPanel1	
120
	 * 	
121
	 * @return javax.swing.JPanel	
122
	 */
123
	private JPanel getPLeft() {
124
		if (pLeft == null) {
125
			FlowLayout flowLayout1 = new FlowLayout();
126
			flowLayout1.setHgap(28);
127
			flowLayout1.setAlignment(java.awt.FlowLayout.LEFT);
128
			flowLayout1.setVgap(0);
129
			lLeft = new JLabel();
130
			lLeft.setText("T");
131
			lLeft.setForeground(Color.BLUE);
132
			lLeft.setPreferredSize(new java.awt.Dimension(15,22));
133
			pLeft = new JPanel();
134
			pLeft.setLayout(flowLayout1);
135
			pLeft.setPreferredSize(new java.awt.Dimension((width >> 1) - 2,20));
136
			pLeft.setSize(width >> 1,20);
137
			pLeft.add(lLeft, null);
138
			lLeft.addMouseListener(graphicListener);
139
	        lLeft.addMouseMotionListener(graphicListener);
140
		}
141
		return pLeft;
142
	}
143

  
144
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/GraphicChartPanel.java
19 19
package org.gvsig.gui.beans.graphic;
20 20

  
21 21
import java.awt.BasicStroke;
22
import java.awt.BorderLayout;
22 23
import java.awt.Color;
23
import java.awt.FlowLayout;
24 24

  
25 25
import javax.swing.JPanel;
26 26

  
......
40 40

  
41 41
public class GraphicChartPanel extends JPanel {
42 42
	private static final long serialVersionUID = 7328137487119964665L;
43
	private static final int	HEIGHT_MARGIN = 5;
44
	private static final int	WIDTH_MARGIN = 4;
45 43
	private JFreeChart 			chart;
46 44
	private ChartPanel 			jPanelChart = null;
47 45
	private XYSeries 			series[] = null;
48 46
	private XYSeriesCollection 	dataset = null;
49
	private int 				width = 300, height = 150;
50 47

  
51
	
52
	public GraphicChartPanel(int width, int height) {
53
		this.width = width;
54
		this.height = height;
55

  
48
	public GraphicChartPanel() {
56 49
		int nSeries = 3;
57 50
		
58 51
		series = new XYSeries[nSeries];
......
79 72
	 * 
80 73
	 */
81 74
	private void initialize() {
82
        FlowLayout flowLayout = new FlowLayout();
83
        flowLayout.setVgap(0);
84
        flowLayout.setHgap(0);
85
        this.setLayout(flowLayout);
86
        this.setSize(new java.awt.Dimension(width, height));
87
		this.setPreferredSize(new java.awt.Dimension(width, height));
88
		this.add(getChart(), null);	
75
		this.setLayout(new BorderLayout());
76
		this.add(getChart(), BorderLayout.CENTER);	
89 77
	}
90 78

  
91 79
	/**
......
95 83
	public ChartPanel getChart(){
96 84
		if(jPanelChart == null){
97 85
			jPanelChart = new ChartPanel(chart);
98
			jPanelChart.setSize(new java.awt.Dimension(width - WIDTH_MARGIN, height - HEIGHT_MARGIN));
99
			jPanelChart.setPreferredSize(new java.awt.Dimension(width - WIDTH_MARGIN, height - HEIGHT_MARGIN));
100 86
			jPanelChart.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,1));
101 87
		}
102 88
		return 	jPanelChart;
......
171 157
    	dataset.removeAllSeries();
172 158
    	jPanelChart.repaint();
173 159
    }
174
    
175
	/**
176
	 * Asigna el tama?o del componente
177
	 * @param w Nuevo ancho del componente padre
178
	 * @param h Nuevo alto del componente padre
179
	 */
180
	public void setComponentSize(int w, int h){
181
		width = w;
182
		height = h;
183
		this.setSize(new java.awt.Dimension(w, h));
184
		this.setPreferredSize(new java.awt.Dimension(w, h));
185
		jPanelChart.setSize(new java.awt.Dimension(w - WIDTH_MARGIN, h - HEIGHT_MARGIN));
186
		jPanelChart.setPreferredSize(new java.awt.Dimension(w - WIDTH_MARGIN, h - HEIGHT_MARGIN));
187
	}
188
}
160
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/GraphicEvent.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.gui.beans.graphic;
20

  
21
import java.util.EventObject;
22

  
23
public class GraphicEvent extends EventObject {
24
	private static final long serialVersionUID = -684281519921935004L;
25

  
26
	public GraphicEvent(Object source) {
27
		super(source);
28
	}
29
}
0 30

  
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/BoxesPanel.java
18 18
 */
19 19
package org.gvsig.gui.beans.graphic;
20 20

  
21
import java.awt.BorderLayout;
21 22
import java.awt.FlowLayout;
22 23

  
23 24
import javax.swing.JPanel;
......
31 32

  
32 33
public class BoxesPanel extends JPanel {
33 34
	private static final long serialVersionUID = -4117483555280497312L;
34
	private int 				width = 300, height = 30;
35 35
	private JPanel pLeft = null;
36 36
	private JPanel pRight = null;
37 37
	private TextIncreaserContainer controlLeft = null;
38 38
	private TextIncreaserContainer controlRight = null;
39
	public BoxesPanel(int width, int height) {
39
	public BoxesPanel() {
40 40
		super();
41
		this.width = width;
42
		this.height = height;
43 41
		initialize(); 
44 42
	}
45 43

  
......
48 46
	 * 
49 47
	 */
50 48
	private void initialize() {
51
        FlowLayout flowLayout = new FlowLayout();
52
        flowLayout.setHgap(0);
53
        flowLayout.setVgap(0);
54
        this.setLayout(flowLayout);
55
        this.setSize(new java.awt.Dimension(width, height));
56
        this.setPreferredSize(new java.awt.Dimension(width, height));
57
        this.add(getPLeft(), null);
58
        this.add(getPRight(), null);
59
			
49
		this.setLayout(new BorderLayout());
50
		this.add(getPLeft(), BorderLayout.WEST);
51
		this.add(getPRight(), BorderLayout.EAST);
60 52
	}
61 53

  
62 54
	/**
......
73 65
			pLeft = new JPanel();
74 66
			pLeft.setLayout(flowLayout1);
75 67
			pLeft.add(getControlLeft(), null);
76
			pLeft.setSize(new java.awt.Dimension(width >> 1, height));
77
	        pLeft.setPreferredSize(new java.awt.Dimension(width >> 1, height));
68
			pLeft.setPreferredSize(new java.awt.Dimension(100, 30));
78 69
		}
79 70
		return pLeft;
80 71
	}
......
93 84
			pRight = new JPanel();
94 85
			pRight.setLayout(flowLayout2);
95 86
			pRight.add(getControlRight(), null);
96
			pRight.setSize(new java.awt.Dimension(width >> 1, height));
97
			pRight.setPreferredSize(new java.awt.Dimension(width >> 1, height));
87
			pRight.setPreferredSize(new java.awt.Dimension(100, 30));
98 88
		}
99 89
		return pRight;
100 90
	}
......
122 112
		}
123 113
		return controlRight;
124 114
	}
125
	
126
	/**
127
	 * Asigna el tama?o del componente
128
	 * @param w Nuevo ancho del componente padre
129
	 * @param h Nuevo alto del componente padre
130
	 */
131
	public void setComponentSize(int w, int h){
132
		this.width = w;
133
		this.height = h;
134
		setSize(w, h);
135
		setPreferredSize(new java.awt.Dimension(w, h));
136
		getPRight().setSize(w >> 1, h);
137
		getPRight().setPreferredSize(new java.awt.Dimension(w >> 1, h));
138
		getPLeft().setSize(w >> 1, h);
139
		getPLeft().setPreferredSize(new java.awt.Dimension(w >> 1, h));
140
		
141
	}
142
	
115

  
143 116
	//****************************************************
144 117
	//M?TODOS DEL CONTROL
145 118
	
......
154 127
		v[1] = getControlLeft().getValue();
155 128
		return v;
156 129
	}
157
}
130
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/GraphicContainer.java
18 18
 */
19 19
package org.gvsig.gui.beans.graphic;
20 20

  
21
import java.awt.FlowLayout;
21
import java.awt.BorderLayout;
22 22
import java.awt.GridBagConstraints;
23
import java.awt.GridBagLayout;
24
import java.awt.event.ComponentEvent;
25
import java.awt.event.ComponentListener;
23
import java.util.ArrayList;
24
import java.util.Iterator;
26 25

  
27
import javax.swing.JButton;
26
import javax.swing.JComponent;
28 27
import javax.swing.JPanel;
29
import javax.swing.JTextField;
30 28

  
31
import org.gvsig.gui.beans.graphic.listeners.GraphicListener;
29
import org.gvsig.gui.beans.doubleslider.DoubleSlider;
30
import org.gvsig.gui.beans.doubleslider.DoubleSliderEvent;
31
import org.gvsig.gui.beans.doubleslider.DoubleSliderListener;
32
import org.gvsig.gui.beans.textincreaser.TextIncreaserEvent;
33
import org.gvsig.gui.beans.textincreaser.TextIncreaserListener;
32 34

  
33 35
/**
34 36
 * Control para el manejo de un gr?fico.
......
36 38
 * @author Nacho Brodin (brodin_ign@gva.es)
37 39
 *
38 40
 */
39
public class GraphicContainer extends JPanel implements  ComponentListener {
41
public class GraphicContainer extends JPanel implements DoubleSliderListener, TextIncreaserListener {
40 42
	private static final long serialVersionUID = -6230083498345786500L;
41
	private static final int		INTERNAL_MARGIN = 4;
42
	private int						HEIGHT_DOUBLESLIDER = 25;
43
	private static final int		HEIGHT_BOXES = 30;
44 43
	
45 44
	private JPanel 					pGeneral = null;
46 45
	private GraphicChartPanel 		pGraphic = null;
47
	private JPanel 					pDoubleSlider = null;
46
	private JPanel 					panelSlider = null;
48 47
	private BoxesPanel 				pBoxes = null;
49
	private GraphicListener 		graphicListener = null;
50
	/**
51
	 * Variable que estar? a true si se desea que se muestre el control de barra deslizadora
52
	 */
53
	private	boolean 				showSlider = true;
48
	private DoubleSlider multiSlider;
49
	
50
	private ArrayList actionCommandListeners = new ArrayList();
51
	private boolean bDoCallListeners = true;
52
	static private int eventId = Integer.MIN_VALUE;
54 53

  
55 54
	public GraphicContainer() {
56
		graphicListener = new GraphicListener(this);
57 55
		initialize();
58 56
	}
59 57
	
60 58
	public GraphicContainer(boolean showSlider) {
61
		this.showSlider = showSlider;
62
		if (!showSlider)
63
			HEIGHT_DOUBLESLIDER = 0;
64
		graphicListener = new GraphicListener(this);
59
		getPDoubleSlider().setVisible(showSlider);
65 60
		initialize();
66 61
	}
67 62
	
68 63

  
69 64
	private void initialize() {
70
		FlowLayout layout = new FlowLayout();
71
		layout.setHgap(0);
72
		layout.setVgap(0);
73
		this.setLayout(layout);
74
		this.add(getPGeneral(), null);
75
		this.addComponentListener(this);
65
		this.setLayout(new BorderLayout(0, 4));
66
		this.add(getPGraphic(), BorderLayout.CENTER);
67
		this.add(getPGeneral(), BorderLayout.SOUTH);
76 68
	}
77 69
	
78 70
	/**
......
95 87
			gridBagConstraints.insets = new java.awt.Insets(0,0,0,0);
96 88
			gridBagConstraints.gridx = 0;
97 89
			pGeneral = new JPanel();
98
			pGeneral.setLayout(new GridBagLayout());
99
			pGeneral.add(getPGraphic(), gridBagConstraints);
100
			if(showSlider)
101
				pGeneral.add(getPDoubleSlider(), gridBagConstraints3);
102
			pGeneral.add(getPBoxes(), gridBagConstraints4);
90
			pGeneral.setLayout(new BorderLayout(0, 2));
91
			pGeneral.add(getPDoubleSlider(), BorderLayout.NORTH);
92
			pGeneral.add(getPBoxes(), BorderLayout.SOUTH);
103 93
		}
104 94
		return pGeneral;
105 95
	}
......
111 101
	 */
112 102
	public GraphicChartPanel getPGraphic() {
113 103
		if (pGraphic == null) {
114
			pGraphic = new GraphicChartPanel(this.getWidth() - INTERNAL_MARGIN, this.getHeight() - HEIGHT_BOXES - HEIGHT_DOUBLESLIDER);
104
			pGraphic = new GraphicChartPanel();
115 105
		}
116 106
		return pGraphic;
117 107
	}
......
121 111
	 * 	
122 112
	 * @return javax.swing.JPanel	
123 113
	 */
124
	private JPanel getPDoubleSlider() {
125
		if (pDoubleSlider == null) {
126
			pDoubleSlider = new DoubleSliderControlPanel(this.getWidth() - INTERNAL_MARGIN, HEIGHT_DOUBLESLIDER, graphicListener);
114
	private JComponent getPDoubleSlider() {
115
		if (panelSlider == null) {
116
			panelSlider = new JPanel();
117
			multiSlider = new DoubleSlider();
118
			multiSlider.addValueChangedListener(this);
119
			panelSlider.setLayout(new BorderLayout());
120
			panelSlider.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
121
//			panelSlider.setBorder(javax.swing.BorderFactory.createEtchedBorder());
122
			panelSlider.add(multiSlider, BorderLayout.CENTER);
127 123
		}
128
		return pDoubleSlider;
124
		return panelSlider;
129 125
	}
130 126

  
131 127
	/**
......
135 131
	 */
136 132
	private BoxesPanel getPBoxes() {
137 133
		if (pBoxes == null) {
138
			pBoxes = new BoxesPanel(this.getWidth() - INTERNAL_MARGIN, HEIGHT_BOXES);
134
			pBoxes = new BoxesPanel();
135
			pBoxes.getControlLeft().addValueChangedListener(this);
136
			pBoxes.getControlRight().addValueChangedListener(this);
139 137
		}
140 138
		return pBoxes;
141 139
	}
142 140
	
143
	/**
144
	 * Asigna el tama?o del componente
145
	 * @param w Nuevo ancho del componente padre
146
	 * @param h Nuevo alto del componente padre
147
	 */
148
	public void setComponentSize(int w, int h){
149
    setPreferredSize(new java.awt.Dimension(w, h));
150
		getPGraphic().setComponentSize(w - INTERNAL_MARGIN, h - HEIGHT_BOXES - HEIGHT_DOUBLESLIDER);
151
		if(this.showSlider){
152
			getPDoubleSlider().setPreferredSize(new java.awt.Dimension(w - INTERNAL_MARGIN, HEIGHT_DOUBLESLIDER));
153
		}
154
		((BoxesPanel)getPBoxes()).setComponentSize(w - INTERNAL_MARGIN, HEIGHT_BOXES);
155
		this.updateUI();
156
	}
157
	
158 141
	//****************************************************
159 142
	//M?TODOS DEL CONTROL
160 143

  
161
	/**
162
	 * Obtiene el valor de los controles. 
163
	 * @return Array con los valores de ambos controles. El primer valor del array es el control de la derecha
164
	 * y el segundo el de la izquierda.  
165
	 */
166
	public double[] getBoxesValues(){
167
		return getPBoxes().getBoxesValues();
144
	public double getX1() {
145
		return getPBoxes().getControlLeft().getValue();
168 146
	}
169
	
170
	/**
171
	 * Obtiene el bot?n de incremento del control izquierdo
172
	 * @return JButton. Bot?n de incremento del control izquierdo
173
	 */
174
	public JButton getPlusButtonControlLeft(){
175
		return this.getPBoxes().getControlLeft().getBmas();
176
	}
177
	
178
	/**
179
	 * Obtiene el bot?n de decremento del control izquierdo
180
	 * @return JButton. Bot?n de decremento del control izquierdo
181
	 */
182
	public JButton getLessButtonControlLeft(){
183
		return this.getPBoxes().getControlLeft().getBmenos();
184
	}
185
	
186
	/**
187
	 * Obtiene el bot?n de incremento del control derecho
188
	 * @return JButton. Bot?n de incremento del control derecho
189
	 */
190
	public JButton getPlusButtonControlRight(){
191
		return this.getPBoxes().getControlRight().getBmas();
192
	}
193
	
194
	/**
195
	 * Obtiene el bot?n de decremento del control derecho
196
	 * @return JButton. Bot?n de decremento del control derecho
197
	 */
198
	public JButton getLessButtonControlRight(){
199
		return this.getPBoxes().getControlRight().getBmenos();
200
	}
201
	
202
	/**
203
	 * Obtiene el JTextField de control derecho
204
	 * @return JTextField de control derecho
205
	 */
206
	public JTextField getTextControlRight(){
207
		return this.getPBoxes().getControlRight().getTText();
208
	}
209
	
210
	/**
211
	 * Obtiene el JTextField de control izquierdo
212
	 * @return JTextField de control izquierdo
213
	 */
214
	public JTextField getTextControlLeft(){
215
		return this.getPBoxes().getControlLeft().getTText();
216
	}
217 147

  
218
	public void componentResized(ComponentEvent e) {
219
		this.setComponentSize(this.getWidth(), this.getHeight());
148
	public double getX2() {
149
		return getPBoxes().getControlRight().getValue();
220 150
	}
221 151

  
222
	public void componentHidden(ComponentEvent e) {
223
		// TODO Auto-generated method stub
152
	public void actionValueChanged(DoubleSliderEvent e) {
153
		getPBoxes().getControlLeft().setValue(((DoubleSlider) e.getSource()).getX1());
154
		getPBoxes().getControlRight().setValue(((DoubleSlider) e.getSource()).getX2());
155
		callValueChangedListeners();
224 156
	}
225 157

  
226
	public void componentMoved(ComponentEvent e) {
227
		// TODO Auto-generated method stub	
158
	public void actionValueChanged(TextIncreaserEvent e) {
159
		if (e.getSource() == getPBoxes().getControlLeft()) {
160
			if (getPBoxes().getControlLeft().getValue() > getPBoxes().getControlRight().getValue())
161
				getPBoxes().getControlRight().setValue(getPBoxes().getControlLeft().getValue());
162
		}
163
		if (e.getSource() == getPBoxes().getControlRight()) {
164
			if (getPBoxes().getControlRight().getValue() < getPBoxes().getControlLeft().getValue())
165
				getPBoxes().getControlLeft().setValue(getPBoxes().getControlRight().getValue());
166
		}
167
		multiSlider.setX1((int) getPBoxes().getControlLeft().getValue());
168
		multiSlider.setX2((int) getPBoxes().getControlRight().getValue());
169
		callValueChangedListeners();
228 170
	}
171
	
172
	public void addValueChangedListener(GraphicListener listener) {
173
		if (!actionCommandListeners.contains(listener))
174
			actionCommandListeners.add(listener);
175
	}
229 176

  
230
	public void componentShown(ComponentEvent e) {
231
		// TODO Auto-generated method stub
177
	public void removeValueChangedListener(GraphicListener listener) {
178
		actionCommandListeners.remove(listener);
232 179
	}
180
	
181
	private void callValueChangedListeners() {
182
		if (!bDoCallListeners)
183
			return;
184
		Iterator acIterator = actionCommandListeners.iterator();
185
		while (acIterator.hasNext()) {
186
			GraphicListener listener = (GraphicListener) acIterator.next();
187
			listener.actionValueChanged(new GraphicEvent(this));
188
		}
189
		eventId++;
190
	}
191
	
233 192
}
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/GraphicListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
19
package org.gvsig.gui.beans.graphic;
20

  
21
import java.util.EventListener;
22

  
23
public interface GraphicListener extends EventListener {
24
  public void actionValueChanged(GraphicEvent e);
25
}
0 26

  
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/graphic/listeners/GraphicListener.java
34 34
 *
35 35
 */
36 36
public class GraphicListener implements MouseListener, ActionListener, MouseMotionListener{
37

  
38
	private GraphicContainer		graphicContainer = null;
39 37
	private boolean					move = false;
40 38
	private JLabel					left = null;
41 39
	private JLabel					right = null;
42 40
	
43
	public GraphicListener(GraphicContainer graphicContainer){
44
		this.graphicContainer = graphicContainer;
41
	public GraphicListener() {
45 42
	}
46 43
	
47 44
	public void mouseDragged(MouseEvent e) {
trunk/libraries/libUIComponent/src/org/gvsig/gui/beans/textincreaser/TextIncreaserListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*/
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff