[TeamTalk 128]: [665] TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/ PenDecoderDisplay.java: Minor retooling of dock and undock functions.
tk@edam.speech.cs.cmu.edu
tk at edam.speech.cs.cmu.edu
Fri Jul 20 19:05:02 EDT 2007
An HTML attachment was scrubbed...
URL: http://mailman.srv.cs.cmu.edu/pipermail/teamtalk-developers/attachments/20070720/3b0cb944/attachment.html
-------------- next part --------------
Modified: TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderDisplay.java
===================================================================
--- TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderDisplay.java 2007-07-20 11:34:30 UTC (rev 664)
+++ TeamTalk/Agents/PenDecoder/src/edu/cmu/ravenclaw/pendecoder/PenDecoderDisplay.java 2007-07-20 23:05:01 UTC (rev 665)
@@ -86,33 +86,41 @@
*/
public void undock() {
dockedFrame.setVisible(false);
+
+ //save docked viewpane parameters
dockSize = mapCanvas.getPreferredSize();
JViewport viewport = (JViewport) mapCanvas.getParent();
- Dimension oldViewSize = null;
- if(viewport != null) {
+ Dimension oldViewSize;
+ if(viewport == null) {
+ //we've never been docked, just give me a view of the whole map
+ dockAnchor = new Point(0, 0);
+ oldViewSize = dockSize;
+ } else {
dockAnchor = viewport.getViewPosition();
oldViewSize = viewport.getSize();
- dockedRootPane.setContentPane(new JPanel());
-
- //zoom out
- Dimension newSize = new Dimension(dockSize.width*320/oldViewSize.width,
- dockSize.height*320/oldViewSize.width);
- Dimension newViewSize = new Dimension(320,
- 320*oldViewSize.height/oldViewSize.width);
- mapCanvas.setPreferredSize(newSize);
- mapCanvas.setSize(newSize);
- Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
- mapCanvasFrame.setBounds(0, screenSize.height-newViewSize.height,
- newViewSize.width, newViewSize.height);
}
+
+ //clear map canvas from docked frame
+ dockedRootPane.setContentPane(new JPanel());
+ //build undocked viewpane and set paramters congruent with docked parameters
JScrollPane pane = new JScrollPane(mapCanvas);
pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER);
+ Dimension newSize = new Dimension(dockSize.width*320/oldViewSize.width,
+ dockSize.height*320/oldViewSize.width);
+ Dimension newViewSize = new Dimension(320, 320*oldViewSize.height/oldViewSize.width);
+ mapCanvas.setPreferredSize(newSize);
+ mapCanvas.setSize(newSize);
+ pane.getViewport().setViewPosition(new Point(dockAnchor.x*320/oldViewSize.width,
+ dockAnchor.y*320/oldViewSize.width));
+
+ //resize undocked frame and attach undocked map viewpane
+ Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
+ mapCanvasFrame.setBounds(0, screenSize.height-newViewSize.height,
+ newViewSize.width, newViewSize.height);
mapCanvasFrame.setContentPane(pane);
- if(oldViewSize != null)
- pane.getViewport().setViewPosition(new Point(dockAnchor.x*320/oldViewSize.width,
- dockAnchor.y*320/oldViewSize.width));
+
mapCanvasFrame.setVisible(true);
docked = false;
}
@@ -122,14 +130,21 @@
*/
public void dock() {
mapCanvasFrame.setVisible(false);
+
+ //clear map canvas from undocked frame
mapCanvasFrame.setContentPane(new JPanel());
+
+ //build docked viewpane and restore viewpane parameters
+ JScrollPane pane = new JScrollPane(mapCanvas);
+ pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
+ pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
mapCanvas.setPreferredSize(dockSize);
mapCanvas.setSize(dockSize);
- JScrollPane pane = new JScrollPane(mapCanvas);
- pane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
- pane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
+ pane.getViewport().setViewPosition(dockAnchor);
+
+ //reattach docked viewpane
dockedRootPane.setContentPane(pane);
- if(dockAnchor != null) pane.getViewport().setViewPosition(dockAnchor);
+
dockedFrame.setVisible(true);
docked = true;
}
@@ -202,8 +217,11 @@
public void repaint() {
if(docked) {
dockedFrame.repaint();
+ } else {
+ mapCanvasFrame.repaint();
}
}
+
/**
* Replace camera image in imager.
* @param i image to paint in imager panel
@@ -573,10 +591,24 @@
*/
protected JFrame mapCanvasFrame;
+ /**
+ * This is the root pane for the docked map canvas. It is a container for the
+ * JScrollPane which has the map and the GlassPane which has the floating logo.
+ */
protected JRootPane dockedRootPane;
+ /**
+ * The dimensions of the docked map canvas viewpane. This is used to fix the
+ * aspect ratio of the undocked map canvas, and also to reaquire the settings
+ * for when the map canvas is redocked.
+ */
protected Dimension dockSize;
+ /**
+ * The position of the viewpane of the docked map canvas. This is used to
+ * position the viewpane of the undocked map canvas and also to reaquire the
+ * position when the map canvas is redocked.
+ */
protected Point dockAnchor = null;
private static final long serialVersionUID = -3941481106291332264L;
More information about the TeamTalk-developers
mailing list