Author: pwang
Date: 2010-01-29 13:42:17 -0800 (Fri, 29 Jan 2010)
New Revision: 19073
Modified:
cytoscape/trunk/src/cytoscape/view/CytoscapeDesktop.java
Log:
Fixed bug 0002126: Cytoscape main window should remember its previous location
Modified: cytoscape/trunk/src/cytoscape/view/CytoscapeDesktop.java
===================================================================
--- cytoscape/trunk/src/cytoscape/view/CytoscapeDesktop.java 2010-01-29
20:17:28 UTC (rev 19072)
+++ cytoscape/trunk/src/cytoscape/view/CytoscapeDesktop.java 2010-01-29
21:42:17 UTC (rev 19073)
@@ -45,6 +45,7 @@
import java.awt.event.WindowEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.io.File;
import java.util.HashMap;
import java.util.List;
@@ -64,6 +65,7 @@
import cytoscape.CyNetwork;
import cytoscape.Cytoscape;
+import cytoscape.CytoscapeInit;
import cytoscape.CytoscapeVersion;
import cytoscape.data.webservice.ui.WebServiceContextMenuListener;
import cytoscape.util.undo.CyUndo;
@@ -76,8 +78,11 @@
import cytoscape.visual.ui.NestedNetworkListener;
import cytoscape.visual.ui.VizMapBypassNetworkListener;
import cytoscape.visual.ui.VizMapperMainPanel;
+import java.util.Properties;
+import java.io.FileOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
-
/**
* The CytoscapeDesktop is the central Window for working with Cytoscape
*/
@@ -341,14 +346,33 @@
}
});
- // show the Desktop
setContentPane(main_panel);
pack();
setSize(DEF_DESKTOP_SIZE);
+
+ // restore desktop location
+ restoreDesktop();
+
+ // show the Desktop
setVisible(true);
toFront();
}
+ private void restoreDesktop(){
+ //restore desktop to previous location
+ try {
+ Properties props = new Properties();
+ File desktop_prop_file = new
File(CytoscapeInit.getConfigVersionDirectory(), "desktop.props");
+ props.load(new FileInputStream(desktop_prop_file));
+ this.setLocation(new
Integer(props.get("x").toString()).intValue(),
+ new
Integer(props.get("y").toString()).intValue());
+ this.setSize(new
Integer(props.get("w").toString()).intValue(),
+ new
Integer(props.get("h").toString()).intValue());
+ }
+ catch (Exception e){
+ }
+ }
+
private void initStatusBar(JPanel panel) {
statusBar = new JLabel();
statusBar.setBorder(new EmptyBorder(0, 7, 5, 7));
@@ -604,6 +628,20 @@
// pass on the event
pcs.firePropertyChange(e);
}
+ else if
(e.getPropertyName().equalsIgnoreCase(Cytoscape.CYTOSCAPE_EXIT)){
+ // save Desktop location into property file
"desktop.prop"
+ File desktop_prop_file = new
File(CytoscapeInit.getConfigVersionDirectory(), "desktop.props");
+ Properties props = new Properties();
+ props.setProperty("x", new
Integer(this.getX()).toString());
+ props.setProperty("y", new
Integer(this.getY()).toString());
+ props.setProperty("w", new
Integer(this.getWidth()).toString());
+ props.setProperty("h", new
Integer(this.getHeight()).toString());
+ try {
+ props.store(new
FileOutputStream(desktop_prop_file), "Remember desktop frame location");
+ }
+ catch (IOException ioe){
+ }
+ }
}
//
---------------------------------------------------------------------------//
--
You received this message because you are subscribed to the Google Groups
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/cytoscape-cvs?hl=en.