Changeset 29215 in osm for applications/editors/josm/plugins
- Timestamp:
- 2013-01-29T21:49:08+01:00 (12 years ago)
- Location:
- applications/editors/josm/plugins/smed2/src
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed2/src/panels/PanelMain.java
r29198 r29215 25 25 } 26 26 }; 27 private JButton openButton = null;28 final JFileChooser fc = new JFileChooser();29 private ActionListener al Open= new ActionListener() {27 private JButton importButton = null; 28 final JFileChooser ifc = new JFileChooser(); 29 private ActionListener alImport = new ActionListener() { 30 30 public void actionPerformed(java.awt.event.ActionEvent e) { 31 if (e.getSource() == openButton) {31 if (e.getSource() == importButton) { 32 32 messageBar.setText("Select file"); 33 int returnVal = fc.showOpenDialog(Main.parent);33 int returnVal = ifc.showOpenDialog(Main.parent); 34 34 if (returnVal == JFileChooser.APPROVE_OPTION) { 35 Smed2Action.panelS57.startImport(fc.getSelectedFile()); 35 Smed2Action.panelS57.startImport(ifc.getSelectedFile()); 36 } else { 37 messageBar.setText(""); 38 } 39 } 40 } 41 }; 42 43 private JButton exportButton = null; 44 final JFileChooser efc = new JFileChooser(); 45 private ActionListener alExport = new ActionListener() { 46 public void actionPerformed(java.awt.event.ActionEvent e) { 47 if (e.getSource() == exportButton) { 48 messageBar.setText("Select file"); 49 int returnVal = efc.showOpenDialog(Main.parent); 50 if (returnVal == JFileChooser.APPROVE_OPTION) { 51 Smed2Action.panelS57.startExport(efc.getSelectedFile()); 36 52 } else { 37 53 messageBar.setText(""); … … 54 70 55 71 messageBar = new JTextField(); 56 messageBar.setBounds( 40, 430, 320, 20);72 messageBar.setBounds(70, 430, 290, 20); 57 73 messageBar.setEditable(false); 58 74 messageBar.setBackground(Color.WHITE); 59 75 add(messageBar); 60 openButton = new JButton(new ImageIcon(getClass().getResource("/images/fileButton.png"))); 61 openButton.setBounds(10, 430, 20, 20); 62 add(openButton); 63 openButton.addActionListener(alOpen); 76 importButton = new JButton(new ImageIcon(getClass().getResource("/images/importButton.png"))); 77 importButton.setBounds(10, 430, 20, 20); 78 add(importButton); 79 importButton.addActionListener(alImport); 80 exportButton = new JButton(new ImageIcon(getClass().getResource("/images/exportButton.png"))); 81 exportButton.setBounds(40, 430, 20, 20); 82 add(exportButton); 83 exportButton.addActionListener(alExport); 64 84 saveButton = new JButton(); 65 85 saveButton.setBounds(370, 430, 100, 20); -
applications/editors/josm/plugins/smed2/src/s57/S57att.java
r29209 r29215 246 246 247 247 public static Att enumAttribute(String attribute, Obj obj) { // Convert OSeaM attribute string to OSeaM enumeration 248 if ((attribute != null) && (attribute.length() > 0)) {248 if ((attribute != null) && !attribute.isEmpty()) { 249 249 for (Att att : AttStr.keySet()) { 250 250 if (AttStr.get(att).equals(attribute) && (verifyAttribute(obj, att) != Ver.NON )) -
applications/editors/josm/plugins/smed2/src/s57/S57dat.java
r29074 r29215 7 7 import java.io.File; 8 8 import java.io.FileInputStream; 9 import java.io.File NotFoundException;9 import java.io.FileOutputStream; 10 10 import java.io.IOException; 11 11 … … 66 66 private File importFile; 67 67 private FileInputStream inp; 68 private File exportFile; 69 private FileOutputStream outp; 68 70 private OsmDataLayer layer; 69 71 private DataSet data; … … 74 76 if (e.getSource() == importButton) { 75 77 readFile(); 76 Smed2Action.panelS57.setVisible( false);77 Smed2Action.panelMain.setVisible( true);78 Smed2Action.panelS57.setVisible(true); 79 Smed2Action.panelMain.setVisible(false); 78 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"); 79 92 } 80 93 } … … 89 102 Smed2Action.panelS57.setVisible(false); 90 103 Smed2Action.panelMain.setVisible(true); 91 PanelMain.messageBar.setText(" Importcancelled");104 PanelMain.messageBar.setText("Operation cancelled"); 92 105 } 93 106 } … … 108 121 importButton.addActionListener(alImport); 109 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); 110 128 } 111 129 … … 120 138 Smed2Action.panelMain.setVisible(false); 121 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() { 122 155 } 123 156 -
applications/editors/josm/plugins/smed2/src/s57/S57obj.java
r29209 r29215 150 150 static { 151 151 for (Map.Entry<Obj, String> entry : ObjStr.entrySet()) { 152 StrObj.put(entry.getValue(), entry.getKey()); 152 if (!entry.getValue().isEmpty()) 153 StrObj.put(entry.getValue(), entry.getKey()); 153 154 } 154 155 } … … 173 174 174 175 public static Obj enumType(String type) { // Convert OSeaM object string to OSeaM object enumeration 175 if ( StrObj.containsKey(type))176 if ((type != null) && !type.isEmpty() && (StrObj.containsKey(type))) 176 177 return StrObj.get(type); 177 178 else -
applications/editors/josm/plugins/smed2/src/seamap/Renderer.java
r29207 r29215 71 71 } 72 72 73 public static double calcArea(Feature feature) {73 public static double signedArea(Feature feature) { 74 74 if (feature.flag == Fflag.AREA) { 75 75 ArrayList<Long> way; … … 91 91 llat = lat; 92 92 } 93 return Math.abs(sigma) * 3444 * 3444 / 2.0;93 return sigma; 94 94 } 95 return 0.0; 95 return 0; 96 } 97 98 public boolean handOfArea(Feature feature) { 99 return (signedArea(feature) < 0); 100 } 101 102 public static double calcArea(Feature feature) { 103 return Math.abs(signedArea(feature)) * 3444 * 3444 / 2.0; 96 104 } 97 105 -
applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java
r29206 r29215 26 26 UNKN, NODE, LINE, AREA 27 27 } 28 29 public enum Nflag { 30 ANON, ISOL, CONN 31 } 32 33 public class Coord { 34 public double lat; 35 public double lon; 36 public Nflag flg; 37 38 public Coord(double ilat, double ilon) { 39 lat = ilat; 40 lon = ilon; 41 flg = Nflag.ANON; 42 } 43 public Coord(double ilat, double ilon, Nflag iflg) { 44 lat = ilat; 45 lon = ilon; 46 flg = iflg; 47 } 48 } 28 49 29 50 public class AttItem { … … 98 119 atts = new AttMap(); 99 120 objs = new ObjMap(); 100 }101 }102 103 public class Coord {104 public double lat;105 public double lon;106 107 public Coord(double ilat, double ilon) {108 lat = ilat;109 lon = ilon;110 121 } 111 122 } -
applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java
r29202 r29215 112 112 editFrame.setResizable(true); 113 113 editFrame.setAlwaysOnTop(true); 114 editFrame.setVisible( false);114 editFrame.setVisible(true); 115 115 panelMain = new PanelMain(); 116 116 editFrame.add(panelMain);
Note:
See TracChangeset
for help on using the changeset viewer.