Changeset 29215 in osm for applications


Ignore:
Timestamp:
2013-01-29T21:49:08+01:00 (11 years ago)
Author:
malcolmh
Message:

save

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  
    2525                }
    2626        };
    27         private JButton openButton = null;
    28         final JFileChooser fc = new JFileChooser();
    29         private ActionListener alOpen = new ActionListener() {
     27        private JButton importButton = null;
     28        final JFileChooser ifc = new JFileChooser();
     29        private ActionListener alImport = new ActionListener() {
    3030                public void actionPerformed(java.awt.event.ActionEvent e) {
    31                         if (e.getSource() == openButton) {
     31                        if (e.getSource() == importButton) {
    3232        messageBar.setText("Select file");
    33         int returnVal = fc.showOpenDialog(Main.parent);
     33        int returnVal = ifc.showOpenDialog(Main.parent);
    3434        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());
    3652         } else {
    3753           messageBar.setText("");
     
    5470               
    5571    messageBar = new JTextField();
    56     messageBar.setBounds(40, 430, 320, 20);
     72    messageBar.setBounds(70, 430, 290, 20);
    5773    messageBar.setEditable(false);
    5874    messageBar.setBackground(Color.WHITE);
    5975    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);
    6484                saveButton = new JButton();
    6585                saveButton.setBounds(370, 430, 100, 20);
  • applications/editors/josm/plugins/smed2/src/s57/S57att.java

    r29209 r29215  
    246246       
    247247        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()) {
    249249            for (Att att : AttStr.keySet()) {
    250250              if (AttStr.get(att).equals(attribute) && (verifyAttribute(obj, att) != Ver.NON ))
  • applications/editors/josm/plugins/smed2/src/s57/S57dat.java

    r29074 r29215  
    77import java.io.File;
    88import java.io.FileInputStream;
    9 import java.io.FileNotFoundException;
     9import java.io.FileOutputStream;
    1010import java.io.IOException;
    1111
     
    6666        private File importFile;
    6767        private FileInputStream inp;
     68        private File exportFile;
     69        private FileOutputStream outp;
    6870        private OsmDataLayer layer;
    6971        private DataSet data;
     
    7476                        if (e.getSource() == importButton) {
    7577                                readFile();
    76                     Smed2Action.panelS57.setVisible(false);
    77                     Smed2Action.panelMain.setVisible(true);
     78                    Smed2Action.panelS57.setVisible(true);
     79                    Smed2Action.panelMain.setVisible(false);
    7880        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");
    7992      }
    8093                }
     
    89102                    Smed2Action.panelS57.setVisible(false);
    90103                    Smed2Action.panelMain.setVisible(true);
    91         PanelMain.messageBar.setText("Import cancelled");
     104        PanelMain.messageBar.setText("Operation cancelled");
    92105      }
    93106                }
     
    108121                importButton.addActionListener(alImport);
    109122                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);
    110128        }
    111129
     
    120138    Smed2Action.panelMain.setVisible(false);
    121139    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() {
    122155        }
    123156
  • applications/editors/josm/plugins/smed2/src/s57/S57obj.java

    r29209 r29215  
    150150        static {
    151151                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());
    153154                }
    154155        }
     
    173174
    174175        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)))
    176177                        return StrObj.get(type);
    177178                else
  • applications/editors/josm/plugins/smed2/src/seamap/Renderer.java

    r29207 r29215  
    7171        }
    7272
    73         public static double calcArea(Feature feature) {
     73        public static double signedArea(Feature feature) {
    7474          if (feature.flag == Fflag.AREA) {
    7575                        ArrayList<Long> way;
     
    9191                                llat = lat;
    9292            }
    93             return Math.abs(sigma) * 3444 * 3444 / 2.0;
     93            return sigma;
    9494          }
    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;
    96104        }
    97105
  • applications/editors/josm/plugins/smed2/src/seamap/SeaMap.java

    r29206 r29215  
    2626                UNKN, NODE, LINE, AREA
    2727        }
     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        }
    2849
    2950        public class AttItem {
     
    98119                        atts = new AttMap();
    99120                        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;
    110121                }
    111122        }
  • applications/editors/josm/plugins/smed2/src/smed2/Smed2Action.java

    r29202 r29215  
    112112                editFrame.setResizable(true);
    113113                editFrame.setAlwaysOnTop(true);
    114                 editFrame.setVisible(false);
     114                editFrame.setVisible(true);
    115115                panelMain = new PanelMain();
    116116                editFrame.add(panelMain);
Note: See TracChangeset for help on using the changeset viewer.