Ignore:
Timestamp:
2013-10-13T19:17:33+02:00 (12 years ago)
Author:
malcolmh
Message:

save

File:
1 edited

Legend:

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

    r30006 r30022  
    55import java.awt.Color;
    66import java.awt.Dimension;
     7import java.awt.Graphics;
     8import java.awt.Graphics2D;
    79import java.awt.event.ActionListener;
     10import java.awt.image.BufferedImage;
     11import java.io.File;
    812import java.util.ArrayList;
    913import java.util.Iterator;
    1014
     15import javax.imageio.ImageIO;
    1116import javax.swing.*;
    1217
     
    1419
    1520import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.actions.search.SearchCompiler.Parent;
    1622
    1723import s57.S57att.Att;
    1824import s57.S57obj.Obj;
     25import seamap.Renderer;
    1926import seamap.SeaMap.*;
    2027import smed2.Smed2Action;
    2128
    2229public class PanelMain extends JPanel {
    23 
    24         /**
    25          *
    26          */
    2730        private static final long serialVersionUID = 1L;
     31       
     32        Smed2Action dlg;
     33        BufferedImage img;
     34        int w, h, z, f;
     35        JTextField wt, ht, zt, ft;
    2836        public static JTextArea decode = null;
    2937        public static JTextField messageBar = null;
     
    3139        private ActionListener alSave = new ActionListener() {
    3240                public void actionPerformed(java.awt.event.ActionEvent e) {
     41                        dumpMap();
    3342                }
    3443        };
     
    6574        };
    6675
    67         public PanelMain() {
    68 
     76        public PanelMain(Smed2Action dia) {
     77                dlg = dia;
    6978                setLayout(null);
    7079                setSize(new Dimension(480, 480));
    7180               
     81                w = h = z = f = 0;
     82                wt = new JTextField("0");
     83                wt.setBounds(10, 400, 40, 20);
     84    add(wt);
     85                ht = new JTextField("0");
     86                ht.setBounds(60, 400, 40, 20);
     87    add(ht);
     88                zt = new JTextField("0");
     89                zt.setBounds(110, 400, 40, 20);
     90    add(zt);
     91                ft = new JTextField("0");
     92                ft.setBounds(160, 400, 40, 20);
     93    add(ft);
     94
    7295    messageBar = new JTextField();
    7396    messageBar.setBounds(70, 430, 290, 20);
     
    92115                decode.setBounds(0, 0, 480, 420);
    93116                decode.setTabSize(1);
    94                 add(decode);
     117//              add(decode);
     118        }
     119       
     120        public void dumpMap() {
     121                img = new BufferedImage(Integer.parseInt(wt.getText()), Integer.parseInt(ht.getText()), BufferedImage.TYPE_INT_ARGB);
     122                Graphics2D g2 = img.createGraphics();
     123                Renderer.reRender(g2, Integer.parseInt(zt.getText()), Integer.parseInt(ft.getText()), dlg.map, dlg.rendering);
     124                try {
     125                        ImageIO.write(img, "png", new File("/Users/mherring/Desktop/export.png"));
     126                } catch (Exception x) {
     127                        System.out.println("Exception");
     128                }
     129                repaint();
     130        }
     131       
     132        public void paintComponent(Graphics g){
     133                super.paintComponent(g);
     134                Graphics2D g2 = (Graphics2D) g;
     135                g2.setBackground(new Color(0xb5d0d0));
     136                if (img != null) g2.clearRect(0, 0, img.getWidth(), img.getHeight());
     137                g2.drawImage(img, 0, 0, null);;
    95138        }
    96139       
Note: See TracChangeset for help on using the changeset viewer.