Statistics
| Revision:

root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / ui / table / GCPTablePanel.java @ 17727

History | View | Annotate | Download (6.51 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.rastertools.georeferencing.ui.table;
20

    
21
import java.awt.BorderLayout;
22
import java.awt.Dimension;
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25

    
26
import javax.swing.JButton;
27
import javax.swing.JPanel;
28

    
29
import org.gvsig.gui.beans.table.TableContainer;
30
import org.gvsig.gui.beans.table.exceptions.NotInitializeException;
31
import org.gvsig.raster.util.RasterToolsUtil;
32

    
33
import com.iver.andami.PluginServices;
34
import com.iver.andami.ui.mdiManager.IWindow;
35
import com.iver.andami.ui.mdiManager.WindowInfo;
36

    
37
/**
38
 * Panel que contiene la tabla de puntos de control
39
 * 
40
 * 22/12/2007
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class GCPTablePanel extends JPanel implements IWindow {
44
        private static final long         serialVersionUID = 1L;
45
        private String[]                  columnNames = {"-", "N?", "X", "Y", "X'", "Y'", "Error X", "Error Y", "RMS"};
46
        private int[]                     columnWidths = {25, 25, 90, 90, 90, 90, 50, 50, 50};
47
        private TableContainer            table = null;
48
        
49
        private JPanel                    buttonsPanel = null;
50
        private JButton                   saveToXml = null;
51
        private JButton                   loadFromXml = null;
52
        private JButton                   saveToAscii = null;
53
        private JButton                   loadFromAscii = null;
54
        private JButton                   viewTable = null;
55
        private JButton                   process = null;
56
        
57
        private int                       w = 640;
58
        private int                       h = 100;
59
        private int                       posX = 0;
60
        private int                       posY = 0;
61
        
62
        /**
63
         * Constructor.
64
         * Crea la composici?n de controles de zoom.
65
         */
66
        public GCPTablePanel(int posX, int posY, int w, int h) {
67
                setPosition(posX, posY);
68
                setWindowsSize(w, h);
69
                try {
70
                        init();
71
                } catch (NotInitializeException e) {
72
                        RasterToolsUtil.messageBoxError(RasterToolsUtil.getText(this, "table_not_initialize"), this);
73
                }
74
        }
75
        
76
        /**
77
         * Asigna la posici?n de la ventana
78
         * @param posX Posici?n en X
79
         * @param posY Posici?n en Y
80
         */
81
        public void setPosition(int posX, int posY) {
82
                this.posX = posX;
83
                this.posY = posY;
84
        }
85
        
86
        /**
87
         * Asigna la posici?n de la ventana
88
         * @param posX Posici?n en X
89
         * @param posY Posici?n en Y
90
         */
91
        public void setWindowsSize(int w, int h) {
92
                this.w = w;
93
                this.h = h;
94
        }
95
        
96
        /**
97
         * Inicializaci?n de los componentes gr?ficos
98
         */
99
        private void init() throws NotInitializeException  {
100
                setLayout(new BorderLayout());
101
                setSize(new java.awt.Dimension(w, h)); 
102
                
103
                GridBagConstraints gb = new GridBagConstraints();
104
                gb.insets = new java.awt.Insets(0, 0, 0, 0);
105
                gb.gridy = 0;
106
                gb.gridx = 0;
107
                gb.weightx = 1D; //El espacio sobrante se distribuye horizontalmente
108
                gb.weighty = 1D; //El espacio sobrante se distribuye verticalmente
109
                gb.fill = GridBagConstraints.BOTH; //El componente se hace tan ancho como espacio disponible tiene
110
                gb.anchor = GridBagConstraints.NORTH; //Alineamos las cajas arriba
111
                add(getTable(), BorderLayout.CENTER);
112
                
113
                gb.gridx = 1;
114
                add(getButtonsPanel(), BorderLayout.EAST);
115
        }
116
        
117
        /**
118
         * Obtiene la tabla de puntos de control
119
         * @return TableContainer
120
         */
121
        public TableContainer getTable() throws NotInitializeException {
122
                if(table == null) {
123
                        table = new TableContainer(columnNames, columnWidths);
124
                        table.setModel("GCPModel");
125
                        table.initialize();
126
                        table.setControlVisible(true);
127
                        table.setMoveRowsButtonsVisible(true);
128
                        table.setEditable(true);
129
                }
130
                return table;
131
        }
132
        
133
        /**
134
         * Obtiene el panel de botones
135
         * @return JPanel
136
         */
137
        public JPanel getButtonsPanel() {
138
                if(buttonsPanel == null) {
139
                        buttonsPanel = new JPanel();
140
                        buttonsPanel.setLayout(new GridBagLayout());
141
                        
142
                        GridBagConstraints gb = new GridBagConstraints();
143
                        gb.insets = new java.awt.Insets(0, 0, 1, 1);
144
                        gb.gridy = 0;
145
                        gb.gridx = 0;
146
                        
147
                        saveToXml = new JButton();
148
                        saveToXml.setPreferredSize(new Dimension(22, 19));
149
                        saveToXml.setToolTipText(RasterToolsUtil.getText(this, "save_to_xml"));
150
                        buttonsPanel.add(saveToXml, gb);
151

    
152
                        gb.gridy = 0;
153
                        gb.gridx = 1;
154
                        loadFromXml = new JButton();
155
                        loadFromXml.setPreferredSize(new Dimension(22, 19));
156
                        loadFromXml.setToolTipText(RasterToolsUtil.getText(this, "load_from_xml"));
157
                        buttonsPanel.add(loadFromXml, gb);
158
                        
159
                        gb.gridy = 0;
160
                        gb.gridx = 2;
161
                        saveToAscii = new JButton();
162
                        saveToAscii.setPreferredSize(new Dimension(22, 19));
163
                        saveToAscii.setToolTipText(RasterToolsUtil.getText(this, "save_to_ascii"));
164
                        buttonsPanel.add(saveToAscii, gb);
165
                        
166
                        gb.gridy = 0;
167
                        gb.gridx = 3;
168
                        loadFromAscii = new JButton();
169
                        loadFromAscii.setPreferredSize(new Dimension(22, 19));
170
                        loadFromAscii.setToolTipText(RasterToolsUtil.getText(this, "load_from_ascii"));
171
                        buttonsPanel.add(loadFromAscii, gb);
172
                        
173
                        gb.gridy = 1;
174
                        gb.gridx = 0;
175
                        viewTable = new JButton();
176
                        viewTable.setPreferredSize(new Dimension(22, 19));
177
                        viewTable.setToolTipText(RasterToolsUtil.getText(this, "view_table"));
178
                        buttonsPanel.add(viewTable, gb);
179
                        
180
                        gb.gridy = 1;
181
                        gb.gridx = 1;
182
                        process = new JButton();
183
                        process.setPreferredSize(new Dimension(22, 19));
184
                        process.setToolTipText(RasterToolsUtil.getText(this, "process"));
185
                        buttonsPanel.add(process, gb);
186
                }
187
                return buttonsPanel;
188
        }
189
        
190
        /*
191
         * (non-Javadoc)
192
         * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
193
         */
194
        public WindowInfo getWindowInfo() {
195
                WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE);
196
                //if (getClippingPanel().getFLayer() != null)
197
                        //m_viewinfo.setAdditionalInfo(getClippingPanel().getFLayer().getName());
198
                m_viewinfo.setTitle(PluginServices.getText(this, "points_panel"));
199
                m_viewinfo.setX(posX);
200
                m_viewinfo.setY(posY);
201
                m_viewinfo.setHeight(h);
202
                m_viewinfo.setWidth(w);
203
                return m_viewinfo;
204
        }
205
}
206