📄 mapoptiondialog.java
字号:
package mapcenter.weihu;import java.awt.*;import java.awt.event.*;import javax.swing.*;import mapcenter.service.*;import com.mapinfo.coordsys.*;public class MapOptionDialog extends JDialog implements ActionListener{ private static final Log log = LogFactory.getLog("WebGIS"); private MapHandle mapHandle = null; JPanel contentPanel = new JPanel(); JPanel buttonPanel = new JPanel(); JLabel unitLabel = new JLabel("距离单位:"); JLabel coordLabel = new JLabel("坐标系:"); JComboBox unitComb = null; JComboBox coordComb = null; JButton okButton = new JButton("开始"); JButton noButton = new JButton("退出"); public MapOptionDialog(Frame frame) { super(frame, "地图选项", false); try { unitComb = new JComboBox(new String[]{"公里","米"}); coordComb = new JComboBox(); coordComb.addItem("\"Non-Earth (kilometers)\", 0, 1"); coordComb.addItem("\"Longitude / Latitude (WGS 84)\", 1, 104"); mapHandle = ((MainFrame)frame).mapHandle; okButton.addActionListener(this); this.setSize(300,120); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = this.getSize(); this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); jbInit(); } catch(Exception ex){log.error(ex);} } private void jbInit() throws Exception { this.setContentPane(contentPanel); contentPanel.setLayout(new GridLayout(3, 2)); buttonPanel.setLayout(new FlowLayout()); contentPanel.add(unitLabel); contentPanel.add(unitComb); contentPanel.add(coordLabel); contentPanel.add(coordComb); contentPanel.add(new JLabel()); contentPanel.add(buttonPanel); buttonPanel.add(okButton); buttonPanel.add(noButton); } public void actionPerformed(ActionEvent parm1){ com.mapinfo.unit.LinearUnit Unit_Meter = com.mapinfo.unit.LinearUnit.meter; com.mapinfo.unit.LinearUnit Unit_Kilometer = com.mapinfo.unit.LinearUnit.kilometer; try{ int index = unitComb.getSelectedIndex(); com.mapinfo.unit.LinearUnit unit = null; if(index == 0){ unit = Unit_Kilometer; }else{ unit = Unit_Meter; } String csProj = (String)coordComb.getSelectedItem(); mapHandle.getMapJ().setDistanceUnits(unit); mapHandle.getMapJ().setNumericCoordSys(CoordSys.createFromPRJ(csProj)); mapHandle.getMapJ().setDisplayCoordSys(CoordSys.createFromPRJ(csProj)); this.hide(); }catch(Exception e){log.error(e);} } public void show(){ com.mapinfo.unit.LinearUnit Unit_Meter = com.mapinfo.unit.LinearUnit.meter; com.mapinfo.unit.LinearUnit Unit_Kilometer = com.mapinfo.unit.LinearUnit.kilometer; try{ com.mapinfo.unit.LinearUnit unit = mapHandle.getMapJ().getDistanceUnits(); if(unit.equivalent(Unit_Kilometer)){ unitComb.setSelectedIndex(0); }else if(unit.equivalent(Unit_Meter)){ unitComb.setSelectedIndex(1); } for(int i=0; i<coordComb.getItemCount(); i++){ String csProj = (String)coordComb.getItemAt(i); CoordSys coord = mapHandle.getMapJ().getNumericCoordSys(); if(coord.equivalent(CoordSys.createFromPRJ(csProj))){ coordComb.setSelectedIndex(i); super.show(); return; } } coordComb.addItem("请选择坐标系!!!"); coordComb.setSelectedItem("请选择坐标系!!!"); super.show(); }catch(Exception e){log.error(e);} } public static void main(String[] args){ }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -