gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / clip / ui / panel / ClippingCoordinatesPanel.java @ 875
History | View | Annotate | Download (5.98 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.tools.app.basic.tool.clip.ui.panel; |
23 |
|
24 |
import java.awt.Color; |
25 |
import java.awt.GridBagConstraints; |
26 |
import java.awt.GridBagLayout; |
27 |
import java.awt.Insets; |
28 |
|
29 |
import javax.swing.BorderFactory; |
30 |
import javax.swing.JPanel; |
31 |
|
32 |
import org.gvsig.andami.PluginServices; |
33 |
import org.gvsig.gui.beans.coordinatespanel.CoordinatesPanel; |
34 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
35 |
import org.gvsig.raster.tools.app.basic.raster.bean.buttonbar.ButtonBarContainer; |
36 |
import org.gvsig.raster.tools.app.basic.tool.clip.ui.listener.ClippingPanelListener; |
37 |
|
38 |
/**
|
39 |
* Panel for selecting coordinates. The user will introduce real or pixel
|
40 |
* coordinates in this panel to choose the clip area.
|
41 |
*
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
43 |
*/
|
44 |
public class ClippingCoordinatesPanel extends JPanel { |
45 |
private static final long serialVersionUID = -410791369185749893L; |
46 |
private CoordinatesPanel coordinatesPixel = null; |
47 |
private CoordinatesPanel coordinatesReales = null; |
48 |
private ButtonBarContainer buttonBarContainer = null; |
49 |
|
50 |
public ClippingCoordinatesPanel() {
|
51 |
initialize(); |
52 |
} |
53 |
|
54 |
/**
|
55 |
* A?ade los listener a los controles
|
56 |
* que lo necesiten
|
57 |
* @param list
|
58 |
*/
|
59 |
public void setClippingListener(ClippingPanelListener clippingPanelListener) { |
60 |
getPixelCoordinates().addValueChangedListener(clippingPanelListener); |
61 |
getRealCoordinates().addValueChangedListener(clippingPanelListener); |
62 |
getButtonBarContainer().getButton(0).addActionListener(clippingPanelListener);
|
63 |
getButtonBarContainer().getButton(1).addActionListener(clippingPanelListener);
|
64 |
getButtonBarContainer().getButton(2).addActionListener(clippingPanelListener);
|
65 |
getButtonBarContainer().getButton(3).addActionListener(clippingPanelListener);
|
66 |
getButtonBarContainer().getButton(4).addActionListener(clippingPanelListener);
|
67 |
getButtonBarContainer().getButton(5).addActionListener(clippingPanelListener);
|
68 |
} |
69 |
|
70 |
/**
|
71 |
* Inicializa los componentes gr?ficos
|
72 |
*/
|
73 |
private void initialize() { |
74 |
setLayout(new GridBagLayout()); |
75 |
|
76 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
77 |
gridBagConstraints.gridx = 0;
|
78 |
gridBagConstraints.gridy = 0;
|
79 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
80 |
gridBagConstraints.weightx = 1.0;
|
81 |
gridBagConstraints.insets = new Insets(5, 5, 2, 5); |
82 |
add(getPixelCoordinates(), gridBagConstraints); |
83 |
|
84 |
gridBagConstraints = new GridBagConstraints(); |
85 |
gridBagConstraints.gridx = 0;
|
86 |
gridBagConstraints.gridy = 1;
|
87 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
88 |
gridBagConstraints.weightx = 1.0;
|
89 |
gridBagConstraints.insets = new Insets(2, 5, 2, 5); |
90 |
add(getRealCoordinates(), gridBagConstraints); |
91 |
|
92 |
gridBagConstraints = new GridBagConstraints(); |
93 |
gridBagConstraints.gridx = 0;
|
94 |
gridBagConstraints.gridy = 2;
|
95 |
gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
|
96 |
gridBagConstraints.anchor = GridBagConstraints.CENTER;
|
97 |
gridBagConstraints.insets = new Insets(2, 5, 5, 5); |
98 |
add(getButtonBarContainer(), gridBagConstraints); |
99 |
} |
100 |
|
101 |
|
102 |
/**
|
103 |
* This method initializes jPanel
|
104 |
* @return javax.swing.JPanel
|
105 |
*/
|
106 |
public CoordinatesPanel getPixelCoordinates() {
|
107 |
if (coordinatesPixel == null) { |
108 |
coordinatesPixel = new CoordinatesPanel();
|
109 |
coordinatesPixel.setTitlePanel(PluginServices.getText(this, "coordenadas_pixel") |
110 |
); |
111 |
} |
112 |
return coordinatesPixel;
|
113 |
} |
114 |
|
115 |
/**
|
116 |
* This method initializes jPanel1
|
117 |
* @return javax.swing.JPanel
|
118 |
*/
|
119 |
public CoordinatesPanel getRealCoordinates() {
|
120 |
if (coordinatesReales == null) { |
121 |
coordinatesReales = new CoordinatesPanel();
|
122 |
coordinatesReales.setTitlePanel(PluginServices.getText(this, "coordenadas_reales") |
123 |
); |
124 |
} |
125 |
return coordinatesReales;
|
126 |
} |
127 |
|
128 |
/**
|
129 |
* This method initializes jButton
|
130 |
* @return javax.swing.JButton
|
131 |
*/
|
132 |
public ButtonBarContainer getButtonBarContainer() {
|
133 |
if (buttonBarContainer == null) { |
134 |
buttonBarContainer = new ButtonBarContainer();
|
135 |
buttonBarContainer.addButton("export-icon", RasterToolsUtil.getText(this, "load_parameters"), 0); |
136 |
buttonBarContainer.addButton("import-icon", RasterToolsUtil.getText(this, "save_parameters"), 1); |
137 |
buttonBarContainer.addButton("round-icon", RasterToolsUtil.getText(this, "round_pixels"), 2); |
138 |
buttonBarContainer.addButton("rois-icon", RasterToolsUtil.getText(this, "adjust_to_rois"), 3); |
139 |
buttonBarContainer.addButton("fullextent-icon", RasterToolsUtil.getText(this, "fullExtent"), 4); |
140 |
buttonBarContainer.addButton("selecttool-icon", RasterToolsUtil.getText(this, "select_tool"), 5); |
141 |
buttonBarContainer.setButtonAlignment("right");
|
142 |
buttonBarContainer.setComponentBorder(false);
|
143 |
buttonBarContainer.setBorder(BorderFactory.createLineBorder(new Color(189, 190, 176))); |
144 |
} |
145 |
return buttonBarContainer;
|
146 |
} |
147 |
|
148 |
/**
|
149 |
* Asigna los valores de las coordenadas reales.
|
150 |
* @param values
|
151 |
*/
|
152 |
public void setCoordReal(String[] values) { |
153 |
getRealCoordinates().setValues(values); |
154 |
} |
155 |
|
156 |
/**
|
157 |
* Asigna los valores de las coordenadas p?xel.
|
158 |
* @return
|
159 |
*/
|
160 |
public void setCoordPixel(String[] values) { |
161 |
getPixelCoordinates().setValues(values); |
162 |
} |
163 |
} |