/***
 * Image/J Plugins
 * Copyright (C) 2002-2008 Jarek Sacha
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Latest release available at http://sourceforge.net/projects/ij-plugins/
 */
package net.sf.ij_plugins.grow;

import ij.IJ;
import ij.plugin.PlugIn;

import javax.swing.*;


/**
 * Date: Feb 8, 2008
 * Time: 8:47:19 PM
 *
 * @author Jarek Sacha
 */
public final class RegionGrowingPlugIn implements PlugIn {

    private static final String TITLE = "Seeded Region Growing";

    private static RegionGrowingView view;
    private static JDialog dialog;

    public void run(String arg) {
        if (view == null) {
            view = new RegionGrowingView();
            dialog = new JDialog(IJ.getInstance(), TITLE, false);
            dialog.getContentPane().add(view);
            dialog.pack();
            dialog.setLocationRelativeTo(null);
            dialog.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        }

        dialog.setVisible(true);
    }
}

@@ -947,16 +947,54 @@
 ij.IJ;%0D%0A
+import ij.Prefs;%0D%0Aimport ij.gui.GUI;%0D%0A
 import i
@@ -1040,61 +1040,140 @@
 *;%0D%0A
-%0D%0A%0D%0A/**%0D%0A * Date: Feb 8, 2008%0D%0A * Time: 8:47:19 PM%0D%0A 
+import java.awt.Dimension;%0D%0Aimport java.awt.Point;%0D%0Aimport java.awt.event.WindowAdapter;%0D%0Aimport java.awt.event.WindowEvent;%0D%0A%0D%0A%0D%0A/*
 *%0D%0A 
@@ -1195,16 +1195,39 @@
  Sacha%0D%0A
+ * @since Feb 8, 2008%0D%0A
  */%0D%0Apub
@@ -1281,24 +1281,243 @@
 PlugIn %7B%0D%0A%0D%0A
+    public static final String LOC_KEY = %22RegionGrowingPlugIn.loc%22;%0D%0A    public static final String WIDTH_KEY = %22RegionGrowingPlugIn.width%22;%0D%0A    public static final String HEIGHT_KEY = %22RegionGrowingPlugIn.height%22;%0D%0A%0D%0A
     private 
@@ -2022,16 +2022,994 @@
 CLOSE);%0D
+%0A%0D%0A            // Add listener to store window location and size%0D%0A            dialog.addWindowListener(new WindowAdapter() %7B%0D%0A                @Override%0D%0A                public void windowClosing(WindowEvent e) %7B%0D%0A                    super.windowClosing(e);%0D%0A                    Prefs.saveLocation(LOC_KEY, dialog.getLocation());%0D%0A                    Dimension d = dialog.getSize();%0D%0A                    Prefs.set(WIDTH_KEY, d.width);%0D%0A                    Prefs.set(HEIGHT_KEY, d.height);%0D%0A                %7D%0D%0A            %7D);%0D%0A%0D%0A            // Restore location and size%0D%0A            Point loc = Prefs.getLocation(LOC_KEY);%0D%0A            int w = (int) Prefs.get(WIDTH_KEY, 0.0);%0D%0A            int h = (int) Prefs.get(HEIGHT_KEY, 0.0);%0D%0A            if (loc != null && w %3E 0 && h %3E 0) %7B%0D%0A                dialog.setSize(w, h);%0D%0A                dialog.setLocation(loc);%0D%0A            %7D else %7B%0D%0A//                setSize(width, height);%0D%0A                GUI.center(dialog);%0D%0A            %7D%0D
 %0A       

Store window location and size so it can be restored after ImageJ restarts.