Statistics
| Revision:

gvsig-raster / org.gvsig.raster / trunk / org.gvsig.raster / org.gvsig.raster.swing / org.gvsig.raster.swing.impl / src / main / java / org / gvsig / raster / swing / impl / infobypoint / MainInfoByPointPanelImpl.java @ 1194

History | View | Annotate | Download (4.99 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.swing.impl.infobypoint;
23

    
24
import java.awt.Component;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.event.ActionListener;
28
import java.util.HashMap;
29
import java.util.Observable;
30

    
31
import javax.swing.ImageIcon;
32
import javax.swing.JPanel;
33

    
34
import org.gvsig.raster.swing.infobypoint.InfoByPointDataModel;
35
import org.gvsig.raster.swing.infobypoint.MainInfoByPointPanel;
36
import org.gvsig.raster.swing.pixelinspector.PixelInspector;
37

    
38
/**
39
 * @author Nacho Brodin (nachobrodin@gmail.com)
40
 */
41
public class MainInfoByPointPanelImpl extends JPanel implements MainInfoByPointPanel {
42
        private static final long           serialVersionUID        = 1L;
43
        private HashMap<String, String>     tr                      = null;
44
        private HashMap<String, ImageIcon>  icons                   = null;
45
        private DefaultInfoByPointDataModel dataModel               = null;
46
        private PixelInspectorPanel         pixelInspectorPanel     = null;
47
        private InfoByPointPanel            infoByPointPanel        = null;
48
        private ButtonsPanel                buttonsPanel            = null;
49
        private JPanel                      extended                = null;
50
        
51
        public MainInfoByPointPanelImpl(
52
                        HashMap<String, String> translations, 
53
                        HashMap<String, ImageIcon> icons,
54
                        JPanel extended) {
55
                tr = translations;
56
                if(tr == null || tr.get("layer_list") == null) {
57
                        tr = new HashMap<String, String>();
58
                        tr.put("layer_list", "layer_list");
59
                        tr.put("band_values", "band_values");
60
                        tr.put("pixel_point", "pixel_point");
61
                        tr.put("view_point", "view_point");
62
                        tr.put("world_point", "world_point");
63
                        tr.put("bands", "bands");
64
                        tr.put("colors", "colors");
65
                        tr.put("coords", "coords");
66
                        tr.put("lat", "lat");
67
                        tr.put("long", "long");
68
                }
69
                this.icons = icons;
70
                if(this.icons == null) {
71
                        this.icons = new HashMap<String, ImageIcon>();
72
                        this.icons.put("forward-icon", new ImageIcon(System.getProperty("user.dir") + "/src/main/resources/images/forward-icon.png", ""));
73
                        this.icons.put("backward-icon", new ImageIcon(System.getProperty("user.dir") + "/src/main/resources/images/backward-icon.png", ""));
74
                }
75
                this.extended = extended;
76
                init();
77
        }
78
        
79
        private void init() {
80
                setLayout(new GridBagLayout());
81
                GridBagConstraints gbc = new GridBagConstraints();
82

    
83
                if(extended == null) {
84
                        gbc.fill = GridBagConstraints.BOTH;
85
                        gbc.weightx = 1;
86
                        gbc.weighty = 1;
87
                } else {
88
                        //gbc.anchor = GridBagConstraints.WEST;
89
                        gbc.fill = GridBagConstraints.VERTICAL;
90
                        gbc.weighty = 1;
91
                }
92
                gbc.insets = new java.awt.Insets(2, 2, 2, 2);
93
                add((Component)getPixelInspectorPanel(), gbc);
94

    
95
                if(extended == null) {
96
                        gbc.fill = GridBagConstraints.HORIZONTAL;
97
                        gbc.weightx = 1;
98
                        gbc.weighty = 0;
99
                } else {
100
                        gbc.fill = GridBagConstraints.NONE;
101
                        gbc.weighty = 0;
102
                }
103
                
104
                gbc.gridy = 1;
105
                add(getinfoByPointPanel(), gbc);
106
                
107
                if(extended != null) {
108
                        gbc.insets = new java.awt.Insets(0, 6, 0, 6);
109
                        gbc.gridy = 2;
110
                        gbc.fill = GridBagConstraints.HORIZONTAL;
111
                        add(getButtonsPanel(), gbc);
112
                        
113
                        gbc.gridx = 1;
114
                        gbc.gridy = 0;
115
                        gbc.gridheight = 3;
116
                        gbc.insets = new java.awt.Insets(0, 0, 0, 0);
117
                        gbc.fill = GridBagConstraints.BOTH;
118
                        gbc.weightx = 1;
119
                        gbc.weighty = 1;
120
                        //extended.setBorder(BorderFactory.createLineBorder(Color.red));
121
                        add(extended, gbc);
122
                }
123
        }
124
        
125
        public InfoByPointDataModel getInfoByPointDataModel() {
126
                if(dataModel == null)
127
                        dataModel = new DefaultInfoByPointDataModel();
128
                return dataModel;
129
        }
130
        
131
        public PixelInspector getPixelInspectorPanel() {
132
                if(pixelInspectorPanel == null)
133
                        pixelInspectorPanel = new PixelInspectorPanel(tr);
134
                return pixelInspectorPanel;
135
        }
136
        
137
        public InfoByPointPanel getinfoByPointPanel() {
138
                if(infoByPointPanel == null)
139
                        infoByPointPanel = new InfoByPointPanel(tr, getInfoByPointDataModel());
140
                return infoByPointPanel;
141
        }
142
        
143
        public ButtonsPanel getButtonsPanel() {
144
                if(buttonsPanel == null)
145
                        buttonsPanel = new ButtonsPanel(icons);
146
                return buttonsPanel;
147
        }
148
        
149
        public void addListenerExtendedButton(ActionListener listener) {
150
                getButtonsPanel().getExtendedButton().addActionListener(listener);
151
        }
152
        
153
        public void update(Observable o, Object arg) {
154
                getinfoByPointPanel().updateDataModel();
155
        }
156
}