Changeset 30150 in osm for applications/editors/josm/plugins/smed2/src/s57/S57dat.java
- Timestamp:
- 2013-12-25T11:40:00+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/s57/S57dat.java
r29215 r30150 1 1 package s57; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 5 import java.awt.Dimension; 6 import java.awt.event.ActionListener; 7 import java.io.File; 8 import java.io.FileInputStream; 9 import java.io.FileOutputStream; 10 import java.io.IOException; 11 12 import javax.swing.*; 13 14 import org.openstreetmap.josm.Main; 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 16 import org.openstreetmap.josm.data.osm.DataSet; 17 18 import panels.PanelMain; 19 20 import smed2.Smed2Action; 21 22 import s57.S57obj; 23 import s57.S57att; 24 import s57.S57val; 25 26 public class S57dat extends JPanel { 3 public class S57dat { 27 4 28 5 private enum S57field { DSID, DSSI, DSPM, DSPR, DSRC, DSHT, DSAC, CATD, CATX, DDDF, DDDR, DDDI, DDOM, DDRF, DDSI, DDSC, … … 64 41 private enum S57ct2d { YCOO, XCOO } 65 42 66 private File importFile;67 private FileInputStream inp;68 private File exportFile;69 private FileOutputStream outp;70 private OsmDataLayer layer;71 private DataSet data;72 73 private JButton importButton;74 private ActionListener alImport = new ActionListener() {75 public void actionPerformed(java.awt.event.ActionEvent e) {76 if (e.getSource() == importButton) {77 readFile();78 Smed2Action.panelS57.setVisible(true);79 Smed2Action.panelMain.setVisible(false);80 PanelMain.messageBar.setText("File imported");81 }82 }83 };84 private JButton exportButton;85 private ActionListener alExport = new ActionListener() {86 public void actionPerformed(java.awt.event.ActionEvent e) {87 if (e.getSource() == exportButton) {88 writeFile();89 Smed2Action.panelS57.setVisible(true);90 Smed2Action.panelMain.setVisible(false);91 PanelMain.messageBar.setText("File exported");92 }93 }94 };95 private JButton cancelButton;96 private ActionListener alCancel = new ActionListener() {97 public void actionPerformed(java.awt.event.ActionEvent e) {98 if (e.getSource() == cancelButton) {99 try {100 inp.close();101 } catch (IOException e1) {}102 Smed2Action.panelS57.setVisible(false);103 Smed2Action.panelMain.setVisible(true);104 PanelMain.messageBar.setText("Operation cancelled");105 }106 }107 };108 109 public S57dat() {110 111 setLayout(null);112 setSize(new Dimension(480, 480));113 cancelButton = new JButton();114 cancelButton.setBounds(250, 430, 100, 20);115 cancelButton.setText(tr("Cancel"));116 cancelButton.addActionListener(alCancel);117 add(cancelButton);118 importButton = new JButton();119 importButton.setBounds(370, 430, 100, 20);120 importButton.setText(tr("Import"));121 importButton.addActionListener(alImport);122 add(importButton);123 exportButton = new JButton();124 exportButton.setBounds(370, 430, 100, 20);125 exportButton.setText(tr("Export"));126 exportButton.addActionListener(alExport);127 add(exportButton);128 }129 130 public void startImport(File file) {131 importFile = file;132 try {133 inp = new FileInputStream(file);134 } catch (IOException e) {135 PanelMain.messageBar.setText("Failed to open file");136 return;137 }138 Smed2Action.panelMain.setVisible(false);139 Smed2Action.panelS57.setVisible(true);140 }141 142 public void startExport(File file) {143 exportFile = file;144 try {145 outp = new FileOutputStream(file);146 } catch (IOException e) {147 PanelMain.messageBar.setText("Failed to open file");148 return;149 }150 Smed2Action.panelMain.setVisible(false);151 Smed2Action.panelS57.setVisible(true);152 }153 154 private void writeFile() {155 }156 157 private void readFile() {158 // Read & convert file.159 // read record at a time160 // read leader161 // if DDR, build conversion tables162 // if DR, build data structures163 // Extract list of features & present on chooser panel164 }165 166 private void importData() {167 data = new DataSet();168 // Transfer selected features169 layer = new OsmDataLayer(data, importFile.getName(), null);170 layer.setUploadDiscouraged(true);171 Main.main.addLayer(layer);172 173 }174 43 }
Note:
See TracChangeset
for help on using the changeset viewer.