Statistics
| Revision:

root / trunk / extensions / extGeoreferencing / src / org / gvsig / georeferencing / ui / options / CellSizeOptionsPanel.java @ 19621

History | View | Annotate | Download (3.7 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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.georeferencing.ui.options;
20

    
21
import java.awt.GridBagConstraints;
22
import java.awt.GridBagLayout;
23
import java.awt.Insets;
24

    
25
import javax.swing.JPanel;
26

    
27
import org.gvsig.gui.beans.datainput.DataInputContainer;
28
import org.gvsig.raster.util.RasterToolsUtil;
29

    
30
/**
31
 * Panel de selecci?n del tama?o de pixel en X e Y
32
 * 
33
 * 10/01/2008
34
 * @author Nacho Brodin nachobrodin@gmail.com
35
 */
36
public class CellSizeOptionsPanel extends JPanel {
37
        private static final long     serialVersionUID    = 1L;
38
        
39
        private DataInputContainer    xCellSize           = null;
40
        private DataInputContainer    yCellSize           = null;
41
                
42
        /**
43
         * Constructor. Asigna la lista de nombres de vistas para el selector. 
44
         * @param viewList
45
         */
46
        public CellSizeOptionsPanel() {
47
                init();
48
        }
49
        
50
        /**
51
         * Acciones de inicializaci?n del panel
52
         */
53
        public void init() {            
54
                GridBagLayout gl = new GridBagLayout();
55
                setLayout(gl);
56
                setBorder(javax.swing.BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "cellsize"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
57
                
58
                GridBagConstraints gbc = new GridBagConstraints();
59
                gbc.anchor = GridBagConstraints.WEST;
60
                gbc.insets = new Insets(0, 5, 5, 0);
61
                gbc.weightx = 1.0;
62
                gbc.fill = GridBagConstraints.HORIZONTAL;
63
                
64
                add(getXCellSizeTextField(), gbc);
65

    
66
                gbc.gridy = 1;
67
                add(getYCellSizeTextField(), gbc);
68
        }
69
        
70
        /**
71
         * Obtiene el control para selecci?n de tama?o de pixel en X
72
         * @return DataInputContainer
73
         */
74
        public DataInputContainer getXCellSizeTextField() {
75
                if(xCellSize == null) {
76
                        xCellSize = new DataInputContainer();
77
                        xCellSize.setLabelText("X ");
78
                }
79
                return xCellSize;
80
        }
81
        
82
        /**
83
         * Obtiene el control para selecci?n de tama?o de pixel en Y
84
         * @return DataInputContainer
85
         */
86
        public DataInputContainer getYCellSizeTextField() {
87
                if(yCellSize == null) {
88
                        yCellSize = new DataInputContainer();
89
                        yCellSize.setLabelText("Y ");
90
                }
91
                return yCellSize;
92
        }
93
        
94
        /**
95
         * Obtiene el control para selecci?n de tama?o de pixel en X
96
         * @return DataInputContainer
97
         */
98
        public double getXCellSizeValue() {
99
                try {
100
                        return Double.valueOf(xCellSize.getValue()).doubleValue();
101
                } catch(NumberFormatException ex) {
102
                        return -1;
103
                }
104
        }
105
        
106
        /**
107
         * Obtiene el control para selecci?n de tama?o de pixel en Y
108
         * @return DataInputContainer
109
         */
110
        public double getYCellSizeValue() {
111
                try {
112
                        return Double.valueOf(yCellSize.getValue()).doubleValue();
113
                } catch(NumberFormatException ex) {
114
                        return -1;
115
                }
116
        }
117
        
118
        /**
119
         * Asigna el tama?o de pixel en X
120
         * @param dataCellSize
121
         */
122
        public void setXCellSize(double dataCellSize) {
123
                if(xCellSize != null) 
124
                        xCellSize.setValue(dataCellSize + "");
125
        }
126
        
127
        /**
128
         * Asigna el tama?o de pixel en Y
129
         * @param dataCellSize
130
         */
131
        public void setYCellSize(double dataCellSize) {
132
                if(yCellSize != null) 
133
                        yCellSize.setValue(dataCellSize + "");
134
        }
135
                
136
}
137