Ignore:
Timestamp:
2014-02-17T14:27:01+01:00 (11 years ago)
Author:
malcolmh
Message:

save

Location:
applications/editors/josm/plugins/smed2/src/panels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed2/src/panels/PanelMain.java

    r30269 r30285  
     1/* Copyright 2014 Malcolm Herring
     2 *
     3 * This is free software: you can redistribute it and/or modify
     4 * it under the terms of the GNU General Public License as published by
     5 * the Free Software Foundation, version 3 of the License.
     6 *
     7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
     8 */
     9
    110package panels;
    211
     
    918import java.awt.event.ActionListener;
    1019import java.awt.image.BufferedImage;
    11 import java.io.File;
    12 import java.util.ArrayList;
    13 import java.util.Iterator;
     20import java.io.*;
    1421
    1522import javax.imageio.ImageIO;
     
    2027import org.openstreetmap.josm.Main;
    2128
    22 import s57.S57att.Att;
    23 import s57.S57obj.Obj;
    24 import s57.S57val.*;
     29import s57.S57att.*;
     30import s57.S57obj.*;
    2531import s57.S57map.*;
    2632import render.Renderer;
     
    2935public class PanelMain extends JPanel {
    3036
    31         Smed2Action dlg;
    3237        BufferedImage img;
    3338        int w, h, z, f;
     
    4247        };
    4348        private JButton importButton = null;
    44         final JFileChooser ifc = new JFileChooser();
     49        JFileChooser ifc = new JFileChooser(Main.pref.get("smed2plugin.file"));
    4550        private ActionListener alImport = new ActionListener() {
    4651                public void actionPerformed(java.awt.event.ActionEvent e) {
    4752                        if (e.getSource() == importButton) {
    48         messageBar.setText("Select file");
    49         int returnVal = ifc.showOpenDialog(Main.parent);
    50         if (returnVal == JFileChooser.APPROVE_OPTION) {
    51 //          xxx.startImport(ifc.getSelectedFile());
    52          } else {
    53            messageBar.setText("");
    54          }
    55       }
     53                                Smed2Action.panelS57.setVisible(true);
     54        messageBar.setText("Select S-57 ENC file for import");
     55                                int returnVal = ifc.showOpenDialog(Main.parent);
     56                                if (returnVal == JFileChooser.APPROVE_OPTION) {
     57                                        try {
     58                                                Main.pref.put("smed2plugin.file", ifc.getSelectedFile().getPath());
     59                                                Smed2Action.panelS57.startImport(ifc.getSelectedFile());
     60                                        } catch (IOException e1) {
     61                                                Smed2Action.panelS57.setVisible(false);
     62                                                messageBar.setText("IO Exception");
     63                                        }
     64                                } else {
     65                                        Smed2Action.panelS57.setVisible(false);
     66                                        messageBar.setText("");
     67                                }
     68                        }
    5669                }
    5770        };
     
    6275                public void actionPerformed(java.awt.event.ActionEvent e) {
    6376                        if (e.getSource() == exportButton) {
    64         messageBar.setText("Select file");
     77                                Smed2Action.panelS57.setVisible(true);
     78        messageBar.setText("Select S-57 ENC file for export");
    6579        int returnVal = efc.showOpenDialog(Main.parent);
    6680        if (returnVal == JFileChooser.APPROVE_OPTION) {
    67 //          xxx.startExport(efc.getSelectedFile());
     81                try {
     82                                                Smed2Action.panelS57.startExport(efc.getSelectedFile());
     83                                        } catch (IOException e1) {
     84                                                Smed2Action.panelS57.setVisible(false);
     85                                                messageBar.setText("IO Exception");
     86                                        }
    6887         } else {
    69            messageBar.setText("");
     88                                        Smed2Action.panelS57.setVisible(false);
     89                                        messageBar.setText("");
    7090         }
    7191      }
     
    7393        };
    7494
    75         public PanelMain(Smed2Action dia) {
    76                 dlg = dia;
     95        public PanelMain() {
    7796                setLayout(null);
    7897                setSize(new Dimension(480, 480));
     
    120139                img = new BufferedImage(Integer.parseInt(wt.getText()), Integer.parseInt(ht.getText()), BufferedImage.TYPE_INT_ARGB);
    121140                Graphics2D g2 = img.createGraphics();
    122                 Renderer.reRender(g2, Integer.parseInt(zt.getText()), Integer.parseInt(ft.getText()), dlg.map, dlg.rendering);
     141                Renderer.reRender(g2, Integer.parseInt(zt.getText()), Integer.parseInt(ft.getText()), Smed2Action.map, Smed2Action.rendering);
    123142                try {
    124143                        ImageIO.write(img, "png", new File("/Users/mherring/Desktop/export.png"));
  • applications/editors/josm/plugins/smed2/src/panels/ShowFrame.java

    r30215 r30285  
     1/* Copyright 2014 Malcolm Herring
     2 *
     3 * This is free software: you can redistribute it and/or modify
     4 * it under the terms of the GNU General Public License as published by
     5 * the Free Software Foundation, version 3 of the License.
     6 *
     7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>.
     8 */
     9
    110package panels;
    211
Note: See TracChangeset for help on using the changeset viewer.