svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / georeferencing / ui / launcher / TypeSelectionPanel.java @ 18289
History | View | Annotate | Download (4.59 KB)
1 | 17909 | nbrodin | /* 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.launcher; |
||
20 | |||
21 | import java.awt.GridBagConstraints; |
||
22 | import java.awt.GridBagLayout; |
||
23 | import java.awt.Insets; |
||
24 | import java.awt.event.ActionEvent; |
||
25 | import java.awt.event.ActionListener; |
||
26 | |||
27 | import javax.swing.ButtonGroup; |
||
28 | import javax.swing.JPanel; |
||
29 | import javax.swing.JRadioButton; |
||
30 | |||
31 | import org.gvsig.raster.util.RasterToolsUtil; |
||
32 | import org.gvsig.rastertools.georeferencing.Georeferencing; |
||
33 | |||
34 | import com.iver.utiles.swing.JComboBox; |
||
35 | |||
36 | /**
|
||
37 | * Panel de selecci?n de tipo de georreferenciaci?n.
|
||
38 | *
|
||
39 | * 10/01/2008
|
||
40 | * @author Nacho Brodin nachobrodin@gmail.com
|
||
41 | */
|
||
42 | public class TypeSelectionPanel extends JPanel implements ActionListener { |
||
43 | 18289 | nbrodin | private static final long serialVersionUID = 1L; |
44 | 17909 | nbrodin | private String[] viewNameList = null; |
45 | |||
46 | private JRadioButton withoutMap = null; |
||
47 | private JRadioButton withMap = null; |
||
48 | private JComboBox viewList = null; |
||
49 | |||
50 | /**
|
||
51 | * Constructor. Asigna la lista de nombres de vistas para el selector.
|
||
52 | * @param viewList
|
||
53 | */
|
||
54 | public TypeSelectionPanel(String[] viewList) { |
||
55 | this.viewNameList = viewList;
|
||
56 | init(); |
||
57 | } |
||
58 | |||
59 | /**
|
||
60 | * Acciones de inicializaci?n del panel
|
||
61 | */
|
||
62 | public void init() { |
||
63 | ButtonGroup group = new ButtonGroup(); |
||
64 | group.add(getWithoutMap()); |
||
65 | group.add(getWithMap()); |
||
66 | getWithoutMap().addActionListener(this);
|
||
67 | getWithMap().addActionListener(this);
|
||
68 | |||
69 | GridBagLayout gl = new GridBagLayout(); |
||
70 | setLayout(gl); |
||
71 | setBorder(javax.swing.BorderFactory.createTitledBorder(null, RasterToolsUtil.getText(this, "georef_type"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
72 | |||
73 | GridBagConstraints gbc = new GridBagConstraints(); |
||
74 | gbc.weightx = 1.0;
|
||
75 | gbc.fill = GridBagConstraints.HORIZONTAL;
|
||
76 | gbc.anchor = GridBagConstraints.WEST;
|
||
77 | gbc.insets = new Insets(0, 5, 8, 0); |
||
78 | add(getWithoutMap(), gbc); |
||
79 | |||
80 | gbc.gridy = 1;
|
||
81 | gbc.insets = new Insets(0, 5, 8, 0); |
||
82 | add(getWithMap(), gbc); |
||
83 | |||
84 | gbc.gridy = 2;
|
||
85 | gbc.insets = new Insets(0, 35, 8, 0); |
||
86 | add(getView(), gbc); |
||
87 | } |
||
88 | |||
89 | /**
|
||
90 | * Obtiene el radio but?n de la selecci?n sin cartograf?a de referencia
|
||
91 | * @return JRadioButton
|
||
92 | */
|
||
93 | public JRadioButton getWithoutMap() { |
||
94 | if(withoutMap == null) |
||
95 | withoutMap = new JRadioButton(RasterToolsUtil.getText(this, "without_map")); |
||
96 | return withoutMap;
|
||
97 | } |
||
98 | |||
99 | /**
|
||
100 | * Obtiene el radio but?n de la selecci?n con cartograf?a de referencia
|
||
101 | * @return JRadioButton
|
||
102 | */
|
||
103 | public JRadioButton getWithMap() { |
||
104 | if(withMap == null) { |
||
105 | withMap = new JRadioButton(RasterToolsUtil.getText(this, "with_map")); |
||
106 | withMap.setSelected(true);
|
||
107 | } |
||
108 | return withMap;
|
||
109 | } |
||
110 | |||
111 | /**
|
||
112 | * Obtiene el combo con la lista de vistas para la selecci?n de la que contiene
|
||
113 | * la cartograf?a de referencia.
|
||
114 | * @return JComboBox
|
||
115 | */
|
||
116 | public JComboBox getView() { |
||
117 | if(viewList == null) { |
||
118 | viewList = new JComboBox(); |
||
119 | for (int i = 0; i < viewNameList.length; i++) |
||
120 | viewList.addItem(viewNameList[i]); |
||
121 | } |
||
122 | return viewList;
|
||
123 | } |
||
124 | |||
125 | /**
|
||
126 | * Eventos de selecci?n en los RadioButton de selecci?n de Tipo
|
||
127 | */
|
||
128 | public void actionPerformed(ActionEvent e) { |
||
129 | getView().setEnabled(getWithMap().isSelected()); |
||
130 | } |
||
131 | |||
132 | //-------Consulta de propiedades seleccionadas---------
|
||
133 | |||
134 | /**
|
||
135 | * Obtiene el grado seleccionado
|
||
136 | * @return valor del grado seleccionado
|
||
137 | */
|
||
138 | public String getSelectedView() { |
||
139 | if(viewList != null && getWithMap().isSelected()) |
||
140 | return (String)viewList.getSelectedItem(); |
||
141 | return null; |
||
142 | } |
||
143 | |||
144 | /**
|
||
145 | * Obtiene el tipo de georreferenciaci?n seleccionada
|
||
146 | * @return constante definida en Georeferencing con el tipo de georreferenciaci?n seleccionada.
|
||
147 | */
|
||
148 | public int getType() { |
||
149 | if(getWithoutMap().isSelected())
|
||
150 | return Georeferencing.WITHOUT_MAP;
|
||
151 | if(getWithMap().isSelected())
|
||
152 | return Georeferencing.WITH_MAP;
|
||
153 | return Georeferencing.UNDEFINED;
|
||
154 | } |
||
155 | } |