001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032:
033: package com.vividsolutions.jump.workbench.ui.plugin.wms;
034:
035: import java.awt.GridBagConstraints;
036: import java.awt.GridBagLayout;
037: import java.awt.Insets;
038: import java.util.Iterator;
039: import java.util.List;
040: import java.util.Map;
041:
042: import javax.swing.DefaultComboBoxModel;
043: import javax.swing.JComboBox;
044: import javax.swing.JLabel;
045: import javax.swing.JPanel;
046:
047: import com.vividsolutions.jump.I18N;
048: import com.vividsolutions.jump.workbench.ui.InputChangedFirer;
049: import com.vividsolutions.jump.workbench.ui.InputChangedListener;
050: import com.vividsolutions.jump.workbench.ui.wizard.WizardPanel;
051:
052: public class SRSWizardPanel extends JPanel implements WizardPanel {
053: public static final String SRS_KEY = "SRS";
054: private InputChangedFirer inputChangedFirer = new InputChangedFirer();
055: private Map dataMap;
056: private GridBagLayout gridBagLayout1 = new GridBagLayout();
057: private JLabel srsLabel = new JLabel();
058: private JPanel fillerPanel = new JPanel();
059: private DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
060: private JComboBox comboBox = new JComboBox();
061:
062: public SRSWizardPanel() {
063: try {
064: jbInit();
065: } catch (Exception ex) {
066: ex.printStackTrace();
067: }
068: }
069:
070: public void add(InputChangedListener listener) {
071: inputChangedFirer.add(listener);
072: }
073:
074: public void remove(InputChangedListener listener) {
075: inputChangedFirer.remove(listener);
076: }
077:
078: public String getInstructions() {
079: return I18N
080: .get("ui.plugin.wms.SRSWizardPanel.the-layers-you-chosen-support-more-than-one-coordinate-reference");
081: }
082:
083: void jbInit() throws Exception {
084: srsLabel
085: .setText(I18N
086: .get("ui.plugin.wms.SRSWizardPanel.coordinate-reference-system"));
087: this .setLayout(gridBagLayout1);
088: this .add(srsLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
089: GridBagConstraints.CENTER, GridBagConstraints.NONE,
090: new Insets(0, 0, 0, 4), 0, 0));
091: this .add(fillerPanel, new GridBagConstraints(2, 10, 1, 1, 1.0,
092: 1.0, GridBagConstraints.CENTER,
093: GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
094: this .add(comboBox, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
095: GridBagConstraints.CENTER, GridBagConstraints.NONE,
096: new Insets(0, 0, 0, 0), 0, 0));
097: }
098:
099: public void exitingToRight() {
100: int index = comboBox.getSelectedIndex();
101: String srsCode = (String) getCommonSrsList().get(index);
102: dataMap.put(SRS_KEY, srsCode);
103: }
104:
105: private List getCommonSrsList() {
106: return (List) dataMap
107: .get(MapLayerWizardPanel.COMMON_SRS_LIST_KEY);
108: }
109:
110: public void enteredFromLeft(Map dataMap) {
111: this .dataMap = dataMap;
112:
113: for (Iterator i = getCommonSrsList().iterator(); i.hasNext();) {
114: String srs = (String) i.next();
115: String srsName = SRSUtils.getName(srs);
116: comboBoxModel.addElement(srsName);
117: }
118:
119: comboBox.setModel(comboBoxModel);
120: }
121:
122: public String getTitle() {
123: return I18N
124: .get("ui.plugin.wms.SRSWizardPanel.select-coordinate-reference-system");
125: }
126:
127: public String getID() {
128: return getClass().getName();
129: }
130:
131: public boolean isInputValid() {
132: return true;
133: }
134:
135: public String getNextID() {
136: return null;
137: }
138: }
|