Skip to content
Snippets Groups Projects
Commit e383b4c4 authored by J. M. Bailey's avatar J. M. Bailey
Browse files

Save image window preferences

parent d971bd90
No related branches found
No related tags found
No related merge requests found
......@@ -23,6 +23,7 @@
package edu.nps.moves.qrtda.elements.gui;
import edu.nps.moves.misc.StretchIcon;
import edu.nps.moves.qrtda.QRPreferences;
import edu.nps.moves.qrtda.TdaEnvironment;
import edu.nps.moves.qrtda.elements.misc.NameDefault;
import edu.nps.moves.qrtda.elements.misc.QrtdaParameter;
......@@ -159,6 +160,10 @@ public class ImageProjectorPanel extends JPanel
public class ImageProjectorWin extends JFrame
{
private static final long serialVersionUID = 1L;
public final static String IMAGEPROJECTOR_WIN_X_PREF = "ImageProjector_Win_X";
public final static String IMAGEPROJECTOR_WIN_Y_PREF = "ImageProjector_Win_Y";
public final static String IMAGEPROJECTOR_WIN_W_PREF = "ImageProjector_Win_W";
public final static String IMAGEPROJECTOR_WIN_H_PREF = "ImageProjector_Win_H";
BufferedImage img;
JLabel imgLab;
......@@ -169,15 +174,23 @@ public class ImageProjectorPanel extends JPanel
super.setTitle("Image Projector");
JFrame.setDefaultLookAndFeelDecorated(false);
this.full = full;
Rectangle bounds = conf.getBounds();
super.setLocation(bounds.x, bounds.y);
QRPreferences prefs = QRPreferences.getInstance();
//Rectangle bounds = conf.getBounds();
// super.setLocation(bounds.x, bounds.y);
super.setLocation(Integer.parseInt(prefs.get(IMAGEPROJECTOR_WIN_X_PREF, "0")),
Integer.parseInt(prefs.get(IMAGEPROJECTOR_WIN_Y_PREF, "0")));
super.getContentPane().setBackground(Color.black);
if (full) {
super.setUndecorated(true);
super.setExtendedState(JFrame.MAXIMIZED_BOTH);
}
else
super.setSize(600, 600);
//super.setSize(600, 600);
super.setSize(Integer.parseInt(prefs.get(IMAGEPROJECTOR_WIN_W_PREF, "600")),
Integer.parseInt(prefs.get(IMAGEPROJECTOR_WIN_H_PREF, "600")));
super.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
super.addWindowListener(new WindowAdapter()
......@@ -189,12 +202,25 @@ public class ImageProjectorPanel extends JPanel
closeButt.setEnabled(false);
}
});
// Want to adjust image on frame resize
// Want to adjust image on frame resize and save position and size
super.addComponentListener(new ComponentAdapter()
{
@Override
public void componentMoved(ComponentEvent e)
{
QRPreferences prefs = QRPreferences.getInstance();
Rectangle rect = ImageProjectorWin.this.getBounds();
prefs.put(IMAGEPROJECTOR_WIN_X_PREF, ""+rect.x);
prefs.put(IMAGEPROJECTOR_WIN_Y_PREF, ""+rect.y);
}
@Override
public void componentResized(ComponentEvent e)
{
QRPreferences prefs = QRPreferences.getInstance();
Dimension dim = ImageProjectorWin.this.getSize();
prefs.put(IMAGEPROJECTOR_WIN_W_PREF, ""+dim.width);
prefs.put(IMAGEPROJECTOR_WIN_H_PREF, ""+dim.height);
if (img != null)
setImage(img);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment