Author: scooter
Date: 2011-08-15 16:39:00 -0700 (Mon, 15 Aug 2011)
New Revision: 26563
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/view/CytoscapeDesktop.java
cytoscape/trunk/application/src/main/java/cytoscape/view/cytopanels/CytoPanelImp.java
Log:
Fixes to auto-resizing of CytoPanels..
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/view/CytoscapeDesktop.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/view/CytoscapeDesktop.java
2011-08-15 23:36:16 UTC (rev 26562)
+++
cytoscape/trunk/application/src/main/java/cytoscape/view/CytoscapeDesktop.java
2011-08-15 23:39:00 UTC (rev 26563)
@@ -328,8 +328,10 @@
// Calculate panel sizes based on current window size.
calculateProperPanelSize();
- // Set the width of Cytopanel West
- masterPane.setDividerLocation(defaultControlPanelWidth);
+ /* Set the width of Cytopanel West
+ * ...now handled in CytoPanelImpl
+ * masterPane.setDividerLocation(defaultControlPanelWidth);
+ */
rightPane.setDividerLocation(getSize().height -
defaultDataPanelHeight);
masterPane.setDividerSize(DEVIDER_SIZE);
@@ -750,6 +752,10 @@
// set the cytopanel container
cytoPanelWest.setCytoPanelContainer(splitPane);
+ // We want to make sure that the networkPanel is selected (and
resized)
+ int index = cytoPanelWest.indexOfComponent(networkPanel);
+ cytoPanelWest.setSelectedIndex(index);
+
// outta here
return splitPane;
}
Modified:
cytoscape/trunk/application/src/main/java/cytoscape/view/cytopanels/CytoPanelImp.java
===================================================================
---
cytoscape/trunk/application/src/main/java/cytoscape/view/cytopanels/CytoPanelImp.java
2011-08-15 23:36:16 UTC (rev 26562)
+++
cytoscape/trunk/application/src/main/java/cytoscape/view/cytopanels/CytoPanelImp.java
2011-08-15 23:39:00 UTC (rev 26563)
@@ -567,6 +567,7 @@
public void setSelectedIndex(int index) {
// set selected index
tabbedPane.setSelectedIndex(index);
+ resizeSelectedComponent();
// do not have to sent out notification - the tabbedPane will
let us know.
}
@@ -646,6 +647,9 @@
* to determine when new tab has been selected
*/
public void stateChanged(ChangeEvent e) {
+ // Handle the resize
+ resizeSelectedComponent();
+
// let our listeners know
notifyListeners(NOTIFICATION_COMPONENT_SELECTED);
}
@@ -981,33 +985,6 @@
break;
case NOTIFICATION_COMPONENT_SELECTED:
-
- /*
- * Set default resize behavior based on
the currently
- * selected panel's preferredSize
setting
- *
- */
- Component panel =
tabbedPane.getSelectedComponent();
- // Make sure we're not being notified
that we've deleted
- // the last panel
- if (panel != null && cytoPanelContainer
instanceof JSplitPane) {
- int width =
panel.getPreferredSize().width;
- JSplitPane jsp =
(JSplitPane)cytoPanelContainer;
-
- if (compassDirection ==
SwingConstants.WEST) {
- if (width >
WEST_MAX_WIDTH)
- width =
WEST_MAX_WIDTH;
-
jsp.setDividerLocation(width+jsp.getInsets().left);
- } else if (compassDirection ==
SwingConstants.EAST) {
- if (width >
EAST_MAX_WIDTH)
- width =
EAST_MAX_WIDTH;
-
jsp.setDividerLocation(jsp.getSize().width
-
-jsp.getInsets().right
-
-jsp.getDividerSize()
-
-width);
- }
- // TODO: What's the right thing
to do with SOUTH?
- }
int selectedIndex =
tabbedPane.getSelectedIndex();
cytoPanelListener.onComponentSelected(selectedIndex);
@@ -1028,6 +1005,42 @@
}
/**
+ * Size the divider to the currently selected panel's preferredSize
+ */
+ private void resizeSelectedComponent() {
+ /*
+ * Set default resize behavior based on the currently
+ * selected panel's preferredSize setting
+ *
+ */
+ Component panel = tabbedPane.getSelectedComponent();
+ // Make sure we're not being notified that we've deleted
+ // the last panel
+ if (panel != null && cytoPanelContainer instanceof JSplitPane) {
+ int width = panel.getPreferredSize().width;
+ JSplitPane jsp = (JSplitPane)cytoPanelContainer;
+ if (compassDirection == SwingConstants.WEST) {
+ if (width > WEST_MAX_WIDTH)
+ width = WEST_MAX_WIDTH;
+ else if (width < WEST_MIN_WIDTH)
+ width = WEST_MIN_WIDTH;
+
jsp.setDividerLocation(width+jsp.getInsets().left+jsp.getInsets().right+5);
+ } else if (compassDirection == SwingConstants.EAST) {
+ if (width > EAST_MAX_WIDTH)
+ width = EAST_MAX_WIDTH;
+ else if (width < EAST_MIN_WIDTH)
+ width = EAST_MIN_WIDTH;
+ jsp.setDividerLocation(jsp.getSize().width
+ -jsp.getInsets().right
+ -jsp.getInsets().left
+ -jsp.getDividerSize()
+ -width-5);
+ }
+ // TODO: What's the right thing to do with SOUTH?
+ }
+ }
+
+ /**
* Returns the int indicating the location within the layout.
*
* @return The int indicating the location within the layout.
--
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.