Index: /trunk/src/org/apollo/audio/util/SoundDesk.java
===================================================================
--- /trunk/src/org/apollo/audio/util/SoundDesk.java	(revision 1560)
+++ /trunk/src/org/apollo/audio/util/SoundDesk.java	(revision 1561)
@@ -747,4 +747,8 @@
 		
 		// Create the (new) track sequence to associate the mix with
+		// **** Look for TimeStretchFactor
+		// **** Apply 'factor' to generate new version of Audio (WAV file??)
+		// **** Feed to audio bytes from that into a TrackSequence
+		
 		TrackSequence ts = new TrackSequence(
 				tmodel.getAllAudioBytes(), 
Index: /trunk/src/org/apollo/gui/PlaybackControlPopup.java
===================================================================
--- /trunk/src/org/apollo/gui/PlaybackControlPopup.java	(revision 1560)
+++ /trunk/src/org/apollo/gui/PlaybackControlPopup.java	(revision 1561)
@@ -39,4 +39,5 @@
 	public JToggleButton muteButton;
 	public JToggleButton soloButton;
+	public JToggleButton beatDetectButton;
 	public JButton miscButton;
 	public JSlider volumeSlider;
@@ -100,4 +101,18 @@
 		});
 		
+		beatDetectButton = new JToggleButton();
+		SwingMiscManager.setJButtonIcon(beatDetectButton,IconRepository.getIcon("beatDetect.png"));
+		SwingMiscManager.setJButtonSelectedIcon(beatDetectButton,IconRepository.getIcon("beatDetect-no-sticks.png"));
+		beatDetectButton.setPreferredSize(new Dimension(BUTTON_SIZE, BUTTON_SIZE));
+		beatDetectButton.setToolTipText("Toggle beat detection in track");
+
+		beatDetectButton.addChangeListener(new ChangeListener() {
+			public void stateChanged(ChangeEvent e) {
+				if (!PlaybackControlPopup.this.isUpdatingGUI) {
+					beatDetectChanged();
+				}
+			}
+		});
+
 		miscButton = new JButton();
 		miscButton.addActionListener(this);
@@ -155,9 +170,15 @@
 		c.gridy = 0;
 		c.fill = GridBagConstraints.BOTH;
+		panel.add(beatDetectButton, c);
+		
+		c = new GridBagConstraints();
+		c.gridx = 6;
+		c.gridy = 0;
+		c.fill = GridBagConstraints.BOTH;
 		c.insets = new Insets(0,VOLUME_SPACING,0,VOLUME_SPACING);
 		panel.add(volumeSlider, c);
 		
 		c = new GridBagConstraints();
-		c.gridx = 7;
+		c.gridx = 8;
 		c.gridy = 0;
 		c.fill = GridBagConstraints.BOTH;
@@ -211,5 +232,5 @@
 //		this.setSize(BUTTON_SIZE * 4, BUTTON_SIZE * 2);
 		
-		panel.setSize(BUTTON_SIZE * 8, BUTTON_SIZE);
+		panel.setSize(BUTTON_SIZE * 9, BUTTON_SIZE);
 		
 		panel.doLayout();
@@ -270,4 +291,6 @@
 	protected abstract void soloChanged();
 	
+	protected abstract void beatDetectChanged();
+
 	
 	/**
Index: /trunk/src/org/apollo/gui/SampledTrackGraphView.java
===================================================================
--- /trunk/src/org/apollo/gui/SampledTrackGraphView.java	(revision 1560)
+++ /trunk/src/org/apollo/gui/SampledTrackGraphView.java	(revision 1561)
@@ -70,4 +70,6 @@
 	private int timescaleFrameLength = 0; // in frames
 	
+	private double timeStretchFactor = 1.0;
+	
 	private final Font RENDER_MESSAGE_FONT = new Font("Arial", Font.BOLD | Font.ITALIC, 14);
 	
@@ -80,5 +82,5 @@
 	private Color backColorHighlights = DEFAULT_BACKGROUND_HIGHTLIGHTS_COLOR;
 	
-	public static final Color PLAYBACK_BAR_COLOR = new Color(225, 187, 15);
+	public static final Color PLAYBACK_BAR_COLOR = new Color(225, 187, 15); // ******
 	
 	/** The stroke used for drawing graph bars. E.G: The selection Start bar. */
@@ -546,4 +548,14 @@
 	}
 	
+	
+	public void setTimeStretchFactor(double time_stretch_factor) {
+		timeStretchFactor = time_stretch_factor;
+	}
+	
+	public double getTimeStretchFactor()
+	{
+		return timeStretchFactor;
+	}
+
 	/**
 	 * Re-renders the waveform buffers to match the graph size if it needs to.
@@ -623,4 +635,5 @@
 				trackModel.getAllAudioBytes(),
 				trackModel.getFormat(),
+				trackModel.getBeats(),
 				timescaleFrameStart,
 				timescaleFrameLength,
@@ -743,7 +756,10 @@
 			
 			int x = getPlaybackXPos(currentPlaybackFramePosition);
+			//System.out.println("*** playback x = " + x);
+			
+			x = (int)Math.rint(((double)x) * getTimeStretchFactor()); // ******
 			
 			if (x >= 0 && x <= getWidth()) {
-				
+					
 				((Graphics2D)g).setStroke(GRAPH_BAR_STROKE);
 				g.setColor(PLAYBACK_BAR_COLOR);
Index: /trunk/src/org/apollo/gui/WaveFormRenderProccessingUnit.java
===================================================================
--- /trunk/src/org/apollo/gui/WaveFormRenderProccessingUnit.java	(revision 1560)
+++ /trunk/src/org/apollo/gui/WaveFormRenderProccessingUnit.java	(revision 1561)
@@ -3,4 +3,5 @@
 import java.awt.Graphics2D;
 import java.util.LinkedList;
+import java.util.List;
 
 import javax.sound.sampled.AudioFormat;
@@ -269,4 +270,6 @@
 							for (int i = 0; i < amps.length; i+=2) {
 								
+								g.setColor(SwingConversions.toSwingColor(ApolloColorIndexedModels.WAVEFORM_COLOR));
+								
 								float peak = amps[i];
 								float trough = amps[i + 1];
@@ -293,4 +296,16 @@
 								}
 								
+								int frameSize = 4;
+								int bi_start = (currentTask.startFrame + renderStart);
+								int bi_end = bi_start + (renderLength);
+
+								for (int bi = bi_start; bi<bi_end; bi++) {
+									if (currentTask.frameIsBeat[bi]) {
+										g.setColor(SwingConversions.toSwingColor(ApolloColorIndexedModels.WAVEFORM_SELECTION_COLOR));
+										g.drawLine(x, halfMaxHeight, x, -halfMaxHeight);
+										break;
+									}
+								}
+
 								currentAmplitude ++;
 							}
@@ -303,6 +318,6 @@
 				} // next pass
 				
-				// Lession learnt: do not request lots of requests to repaint
-				// later on the AWT Event queu otherwise it will get congested
+				// Lesson learnt: do not request lots of requests to repaint
+				// later on the AWT Event queue otherwise it will get congested
 				// and will freeze up the interact for annoying periods of time.
 				currentTask.setState(WaveFormRenderTask.STATE_STOPPED);
@@ -348,4 +363,6 @@
 		private Image imageBuffer; // nullified when stopped.
 		private byte[] audioBytes; // nullified when stopped. - Arrays (not contents) are immutable so no need to worry about threading issues with indexes
+		private boolean[] frameIsBeat;
+		
 		private final int startFrame;
 		private final int frameLength; // in frames
@@ -357,4 +374,5 @@
 				byte[] audioBytes, 
 				AudioFormat format,
+				List<Double> detectedBeats,
 				int startFrame, 
 				int frameLength, 
@@ -371,4 +389,13 @@
 			this.frameLength = frameLength;
 			this.recommendInvalidations = recommendInvalidations;
+						
+			this.frameIsBeat = new boolean[frameLength];
+			if (detectedBeats != null) {
+				for (double beat_in_secs: detectedBeats){
+					int frame_pos = (int)Math.round(beat_in_secs * format.getSampleRate());
+					frameIsBeat[frame_pos] = true;
+				}
+			}
+
 			renderer = new DualPeakTroughWaveFormRenderer(format);
 		}
@@ -384,4 +411,5 @@
 			if (state == STATE_STOPPED) {
 				audioBytes = null;
+				frameIsBeat = null;
 				imageBuffer = null;
 			}
Index: /trunk/src/org/apollo/widgets/LinkedTrack.java
===================================================================
--- /trunk/src/org/apollo/widgets/LinkedTrack.java	(revision 1560)
+++ /trunk/src/org/apollo/widgets/LinkedTrack.java	(revision 1561)
@@ -1504,4 +1504,6 @@
 	{
 		public PlaybackPopup() {
+			super();
+			
 			miscButton.setActionCommand("goto");
 			SwingMiscManager.setJButtonIcon(miscButton, IconRepository.getIcon("goto.png"));
@@ -1554,4 +1556,17 @@
 		}
 
+		@Override
+		protected void beatDetectChanged() {
+
+			System.err.println("*** Need to implement beat detection for linked tracks");
+			/*boolean toggleDetectBeat = beatDetectButton.isSelected();
+
+			updateData(TrackWidgetCommons.META_BEAT_DETECT_TAG, TrackWidgetCommons.META_BEAT_DETECT_TAG + toggleDetectBeat);
+
+			if (toggleDetectBeat) {
+				runDetectBeats();
+				// cause refresh
+			}*/
+		}
 	}
 
Index: /trunk/src/org/apollo/widgets/SampledTrack.java
===================================================================
--- /trunk/src/org/apollo/widgets/SampledTrack.java	(revision 1560)
+++ /trunk/src/org/apollo/widgets/SampledTrack.java	(revision 1561)
@@ -27,4 +27,5 @@
 import javax.sound.sampled.LineUnavailableException;
 import javax.sound.sampled.UnsupportedAudioFileException;
+import javax.swing.ButtonModel;
 import javax.swing.JSlider;
 import javax.swing.SwingUtilities;
@@ -72,8 +73,10 @@
 import org.expeditee.gio.swing.SwingConversions;
 import org.expeditee.gio.swing.SwingMiscManager;
+import org.expeditee.gui.Browser;
 import org.expeditee.gui.DisplayController;
 import org.expeditee.gui.Frame;
 import org.expeditee.gui.FrameIO;
 import org.expeditee.gui.PopupManager;
+import org.expeditee.gui.PopupManager.ExpandShrinkAnimator;
 import org.expeditee.gui.management.ResourceManager;
 import org.expeditee.items.ItemParentStateChangedEvent;
@@ -101,4 +104,6 @@
 import be.tarsos.dsp.io.jvm.WaveformWriter;
 
+
+
 /**
  * The sampled track widgets in apollo.
@@ -109,5 +114,6 @@
 public class SampledTrack extends HeavyDutyInteractiveWidget implements TrackModelHandler, EffecientInvalidator, Observer {
 
-	/** The observered subject. Can be null */
+	/** The observed subject. Can be null */
+	private SampledTrackModel unityTrackModel = null;
 	private SampledTrackModel trackModel = null;
 	
@@ -144,6 +150,6 @@
 	
 	
-	/** If a track widget has a data string thaty contains META_SHOULD_INDEX_AUDIO_TAG, then
-	 * the track should not be indexed for searching the audio.... default isdoes not exist
+	/** If a track widget has a data string that contains META_SHOULD_INDEX_AUDIO_TAG, then
+	 * the track should not be indexed for searching the audio.... default is that it does not exist
 	 */
 	public static final String META_DONT_INDEX_AUDIO_TAG = "dontindexaudio";
@@ -170,15 +176,25 @@
 				true);
 
+		if (Browser.DEBUG) {
+			System.out.println("**** SampleTrack(source,audiobytes,format,mixTemplate): source="+ source);
+		}		
 		// Must set upon construction - always
 		localFileName = AudioPathManager.generateLocateFileName("wav");
 		updateData(META_LOCALNAME_TAG, META_LOCALNAME_TAG + localFileName);
 		
-		trackModel = new SampledTrackModel(audioBytes, format, localFileName);
-		
+		unityTrackModel = new SampledTrackModel(audioBytes, format, localFileName);
+		trackModel = unityTrackModel;
+		
+		boolean detectBeat = getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG,false);
+		if (detectBeat) {
+			runDetectBeats();
+		}
+
 		// Ensure that the model is marked as modified so that it will save
 		trackModel.setAudioModifiedFlag(true);
 		
 		trackModel.setName(getStrippedDataString(TrackWidgetCommons.META_NAME_TAG));
-
+		
+		
 		// Create the immutable mix subject
 		if (mixTemplate == null) {
@@ -222,4 +238,8 @@
 				TrackWidgetCommons.CACHE_DEPTH);
 		
+		if (Browser.DEBUG) {
+			System.out.println("**** SampleTrack(source,args): source=" + source);
+		}
+		
 		// Read the metadata
 		localFileName = getStrippedDataString(META_LOCALNAME_TAG);
@@ -261,4 +281,21 @@
 		}
 	}
+
+	private void runDetectBeats()
+	{
+		if (Browser.DEBUG) {
+			System.out.println("*** runDetectBeats()");
+		}
+		try {
+			// consider adding support for parameters from data statement
+			int size = 512;
+			int overlap = 256;
+			trackModel.detectBeats(size,overlap);
+		}
+		catch (Exception ex) {
+			ex.printStackTrace();
+		}
+	}
+
 
 	private void createGUI() {
@@ -281,6 +318,9 @@
 		
 		shouldOmitAudioIndexing = containsDataTrimmedIgnoreCase(META_DONT_INDEX_AUDIO_TAG);
-
+		
+		boolean beatDetect=getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG,false); 
+				
 		playbackControlPopup = new PlaybackPopup();
+		playbackControlPopup.beatDetectButton.setSelected(beatDetect);
 		
 		fulltrackView = (EditableSampledTrackGraphView)_swingComponent;
@@ -317,4 +357,5 @@
 				if (playbackControlPopup == null) {
 					playbackControlPopup = new PlaybackPopup();
+							
 				} 
 
@@ -329,5 +370,5 @@
 					
 					// Determine where popup should show
-					//int x = SampledTrack.this.getX();
+					int x = SampledTrack.this.getX();
 					int y = SampledTrack.this.getY() - playbackControlPopup.getFullBounds().getHeight() - 2; // by default show above
 					
@@ -340,8 +381,10 @@
 						animationSource.y = y - 2;
 					} 
-
+					animationSource.x = x;
+					
 					// Animate the popup
 					playbackControlPopup.getAutoHideTime().setLifetime(TrackWidgetCommons.POPUP_LIFETIME);
 					PopupManager.getInstance().add(playbackControlPopup);
+					
 					playbackControlPopup.show();
 				} else {
@@ -459,4 +502,34 @@
 				}
 				
+				else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_S) {
+					// Stop
+					TrackSequence ts = SoundDesk.getInstance().getTrackSequence(trackMix.getChannelID());
+
+					// reset any paused mark
+					SoundDesk.getInstance().setPaused(trackMix.getChannelID(), false);
+
+					if (ts != null &&
+							ts.isPlaying()) {
+						// Stop playback
+						ApolloPlaybackMixer.getInstance().stop(ts);
+					}
+
+				} else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_R) {
+					// rewind
+
+					trackModel.setSelection(0, 0);
+					SoundDesk.getInstance().setPaused(trackMix.getChannelID(), false);
+				}
+				else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_B) {
+
+					boolean detectBeat = getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG,false);
+					boolean toggleDetectBeat = (detectBeat) ? false : true;
+
+					updateData(TrackWidgetCommons.META_BEAT_DETECT_TAG, TrackWidgetCommons.META_BEAT_DETECT_TAG + toggleDetectBeat);
+
+					if (toggleDetectBeat) {
+						runDetectBeats();
+					}
+				}			
 				// Toggle pitch-track indexing
 				else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) {
@@ -753,4 +826,9 @@
 		data.add(TrackWidgetCommons.META_RUNNINGMSTIME_TAG + getRunningMSTimeFromRawAudio());
 
+		boolean beatDetect=getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG,false);
+		if (beatDetect) {
+			data.add(TrackWidgetCommons.META_BEAT_DETECT_TAG + "true");
+		}
+
 		return data;
 	}
@@ -844,5 +922,6 @@
 			try {
 				
-				trackModel = TrackModelLoadManager.getInstance().load(f.getPath(), localFileName, this, false);
+				unityTrackModel = TrackModelLoadManager.getInstance().load(f.getPath(), localFileName, this, false);
+				trackModel = unityTrackModel;
 				
 				if (trackModel == null) { // load operation canceled
@@ -850,5 +929,5 @@
 					return LOAD_STATE_INCOMPLETED;
 					
-				} else if(isImporting) { // ensure that file path is null - since not yet saved
+				} else if (isImporting) { // ensure that file path is null - since not yet saved
 					trackModel.setFilepath(null);
 					
@@ -889,4 +968,9 @@
 		}
 		
+		boolean beatDetect = getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG, false);
+		if (beatDetect) {
+			runDetectBeats();
+		}
+
 		initObservers(); // sets default name if non set
 		
@@ -913,10 +997,10 @@
 					if (tinf == null) {
 
-						// Determine new initation time according to position
+						// Determine new initiation time according to position
 						long initTime = (parent != null) ? 
 								FrameLayoutDaemon.getInstance().getMSAtX(getX(), parent)
 								: 0;
 
-						// Keep TrackGraphModel consistant
+						// Keep TrackGraphModel consistent
 						AudioStructureModel.getInstance().onTrackWidgetAnchored(
 								localFileName, 
@@ -938,5 +1022,5 @@
 		
 		// Notify layout manager - not really needed but to be extra safe force the daemon
-		// to be super consistant
+		// to be super consistent
 		FrameLayoutDaemon.getInstance().forceRecheck();
 
@@ -1144,5 +1228,5 @@
 	/**
 	 * To be called by the swing thread only
-	 * This is nessessary to avoid runtime memory leaks!!
+	 * This is necessary to avoid runtime memory leaks!!
 	 */
 	private void releaseMemory(boolean onlyIfExpired) {
@@ -1321,5 +1405,5 @@
 					parent = getParentFrame();
 					
-					// Keep TrackGraphModel consistant
+					// Keep TrackGraphModel consistent
 					AudioStructureModel.getInstance().onTrackWidgetAudioEdited(
 							localFileName,
@@ -1749,5 +1833,5 @@
 	 * @return
 	 * 		The initiation time or this track in MS.
-	 * 		null if unavilable.
+	 * 		null if unavailable.
 	 */
 	public Mutable.Long getInitiationTimeFromMeta() {
@@ -2026,4 +2110,6 @@
 		public PlaybackPopup()
 		{
+			super();
+			
 			miscButton.setActionCommand("expand");
 			SwingMiscManager.setJButtonIcon(miscButton, IconRepository.getIcon("expand.png"));
@@ -2044,4 +2130,23 @@
 		public void onShow()
 		{
+			// Make sure the popup is in the most up to date position, 
+			// relative to the SampledTrack
+			ExpandShrinkAnimator es_animator = (ExpandShrinkAnimator)this.getAnimator();
+			
+			int pcp_x_dim = this.getFullBounds().getWidth();
+			int pcp_y_dim = this.getFullBounds().getHeight();
+			
+			int pcp_x_org = SampledTrack.this.getX();
+			int pcp_y_org = SampledTrack.this.getY() - pcp_y_dim - 2; // by default show above
+			
+			if (pcp_y_org < 0) {
+				// if doesn't fit above, show below
+				pcp_y_org = SampledTrack.this.getY() + SampledTrack.this.getHeight() + 2;
+			} 
+			
+			AxisAlignedBoxBounds initial_bounds = new AxisAlignedBoxBounds(pcp_x_org,pcp_y_org,pcp_x_dim,pcp_y_dim);
+			
+			es_animator.setInitialBounds(initial_bounds);
+			
 			// Listen for volume or mute changed events
 			trackMix.addObserver(this);
@@ -2088,5 +2193,17 @@
 				SoundDesk.getInstance().setPaused(trackMix.getChannelID(), false);
 				
-			} else if (e.getSource() == miscButton) {
+			} 	
+			else if (e.getSource() == beatDetectButton) {
+
+				boolean detectBeat = getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG,false);
+				boolean toggleDetectBeat = (detectBeat) ? false : true;
+
+				updateData(TrackWidgetCommons.META_BEAT_DETECT_TAG, TrackWidgetCommons.META_BEAT_DETECT_TAG + toggleDetectBeat);
+
+				if (toggleDetectBeat) {
+					runDetectBeats();
+				}
+			}
+			else if (e.getSource() == miscButton) {
 				expand(false);
 			}
@@ -2286,6 +2403,18 @@
 							if (stretched_track_model != null) {
 								trackModel = stretched_track_model;
+								fulltrackView.setTimeStretchFactor(time_stretch);
 							}
 						}
+						else {
+							double prev_time_stretch_factor = fulltrackView.getTimeStretchFactor();
+							if (prev_time_stretch_factor != 1.0) {
+								trackModel = unityTrackModel;
+								fulltrackView.setTimeStretchFactor(1.0);
+							}
+						}
+					}
+					else {
+						trackModel = unityTrackModel;
+						fulltrackView.setTimeStretchFactor(1.0);
 					}
 					
@@ -2432,4 +2561,44 @@
 					);
 		}
+		
+		
+		@Override
+		protected void beatDetectChanged() {
+
+			ButtonModel buttonModel = beatDetectButton.getModel();
+			boolean isSelected = buttonModel.isSelected();
+			boolean isPressed  = buttonModel.isPressed();
+
+			if (Browser.DEBUG) {
+				System.out.println("**** isPressed=" + isPressed + ", isSelected=" + isSelected);
+			}
+			
+			if (isPressed) {
+
+				boolean newBeatDetectState = isSelected;
+				boolean curBeatDetectState = getStrippedDataBool(TrackWidgetCommons.META_BEAT_DETECT_TAG,false);
+
+				if (Browser.DEBUG) {
+					System.out.println("**** curBeatDetectState=" + curBeatDetectState + ",  newBeatDetectState=" + newBeatDetectState);
+				}
+				
+				if (newBeatDetectState != curBeatDetectState) {
+
+					// change of state has occurred
+					updateData(TrackWidgetCommons.META_BEAT_DETECT_TAG, TrackWidgetCommons.META_BEAT_DETECT_TAG + newBeatDetectState);
+
+					if (newBeatDetectState==true) {
+						runDetectBeats();
+					}
+					else {
+						trackModel.clearBeats();
+					}
+
+					EditableSampledTrackGraphView thisTrackView = (EditableSampledTrackGraphView)_swingComponent;
+					thisTrackView.releaseBuffer();
+					thisTrackView.updateBuffer();
+				}
+			}
+		}
 	}
 
Index: /trunk/src/org/apollo/widgets/TrackWidgetCommons.java
===================================================================
--- /trunk/src/org/apollo/widgets/TrackWidgetCommons.java	(revision 1560)
+++ /trunk/src/org/apollo/widgets/TrackWidgetCommons.java	(revision 1561)
@@ -17,4 +17,6 @@
 	public static final String META_LAST_WIDTH_TAG = "lw=";
 	public static final String META_OMIT_LAYOUT_TAG = "dontlayout";
+	public static final String META_BEAT_DETECT_TAG="beatDetect=";
+
 	
 	public static final int CACHE_DEPTH = 1;
Index: /trunk/src/org/expeditee/gio/swing/MouseEventRouter.java
===================================================================
--- /trunk/src/org/expeditee/gio/swing/MouseEventRouter.java	(revision 1560)
+++ /trunk/src/org/expeditee/gio/swing/MouseEventRouter.java	(revision 1561)
@@ -176,5 +176,5 @@
 	private void routeMouseEvent(MouseEvent e) {
 		_currentMouseEvent = e;
-
+		
 		// First convert the point to expeditee space
 		Point containerPoint = SwingUtilities.convertPoint(e.getComponent(), e.getPoint(), _contentPane);
@@ -218,6 +218,6 @@
 			// whether an expeditee item is currently picked up
 			boolean forwardToExpeditee = false;
-			boolean isOverPopup = PopupManager.getInstance()
-					.isPointOverPopup(SwingConversions.fromSwingPoint(containerPoint));
+			boolean isOverPopup = PopupManager.getInstance().isPointOverPopup(SwingConversions.fromSwingPoint(containerPoint));
+			
 			if (isOverPopup) {
 				// Popups have highest preference
Index: /trunk/src/org/expeditee/gui/Browser.java
===================================================================
--- /trunk/src/org/expeditee/gui/Browser.java	(revision 1560)
+++ /trunk/src/org/expeditee/gui/Browser.java	(revision 1561)
@@ -144,5 +144,5 @@
 public class Browser implements SaveStateChangedEventListener {
 	
-	public static final boolean DEBUG = true;
+	public static final boolean DEBUG = false;
 	
 	public static final Ecosystem ECOSYSTEM_TYPE = Ecosystem.Swing;
Index: /trunk/src/org/expeditee/gui/FrameGraphics.java
===================================================================
--- /trunk/src/org/expeditee/gui/FrameGraphics.java	(revision 1560)
+++ /trunk/src/org/expeditee/gui/FrameGraphics.java	(revision 1561)
@@ -53,5 +53,5 @@
 	private static Item _lastToolTippedItem = null;
 	
-	private static HashSet<Item> itemsPaintedRecently = new HashSet<Item>();
+	private static HashSet<Item> _itemsPaintedRecently = null;
 
 	/** Static-only class. */
@@ -111,7 +111,8 @@
 	public static void paintFrame(Frame toPaint, boolean isActualFrame, boolean createVolitile)	{
 		
-		Browser.debugMessage("FrameGraphics", "paintFrame", "Debug Job: Trying to detect Items being painted multiple times");
-		itemsPaintedRecently = new HashSet<Item>();
-		
+		if (Browser.DEBUG) {
+			Browser.debugMessage("FrameGraphics", "paintFrame", "Debug Job: Trying to detect Items being painted multiple times");
+			_itemsPaintedRecently = new HashSet<Item>();
+		}	
 		
 		Clip clip = EcosystemManager.getGraphicsManager().peekClip();
@@ -467,8 +468,10 @@
 			i.paint();
 			
-			if (itemsPaintedRecently.contains(i)) {
-				Browser.debugMessage("FrameGraphics", "PaintItem", "Repaining Item Between Clears: " + i);
-			} else {
-				itemsPaintedRecently.add(i);
+			if (Browser.DEBUG) {
+				if (_itemsPaintedRecently.contains(i)) {
+					Browser.debugMessage("FrameGraphics", "PaintItem", "Repaining Item Between Clears: " + i);
+				} else {
+					_itemsPaintedRecently.add(i);
+				}
 			}
 		}
Index: /trunk/src/org/expeditee/gui/FrameIO.java
===================================================================
--- /trunk/src/org/expeditee/gui/FrameIO.java	(revision 1560)
+++ /trunk/src/org/expeditee/gui/FrameIO.java	(revision 1561)
@@ -952,5 +952,7 @@
 				while ((titleItem.getSize() > Text.MINIMUM_FONT_SIZE) && title_item_xr > frame_name_xl) {
 					titleItem.setSize(titleItem.getSize() - 1);
-					System.err.println("**** shrunk titleItem: " + titleItem + " to font size: " + titleItem.getSize());
+					if (Browser.DEBUG) {
+						System.err.println("**** shrunk titleItem: " + titleItem + " to font size: " + titleItem.getSize());
+					}
 				}
 			} else {
@@ -1206,5 +1208,7 @@
 			boolean versionConflict = savedVersion > toSave.getVersion() && !isBayFrameset;
 			
-			System.err.println("FrameIO::SaveFrame::Checking for conflicts for frame:" + toSave.getName());
+			if (Browser.DEBUG) {
+				System.err.println("FrameIO::SaveFrame::Checking for conflicts for frame:" + toSave.getName());
+			}
 			
 			if ((fileModifyConflict || versionConflict) && savedVersion > 0) {
Index: /trunk/src/org/expeditee/gui/FrameMouseActions.java
===================================================================
--- /trunk/src/org/expeditee/gui/FrameMouseActions.java	(revision 1560)
+++ /trunk/src/org/expeditee/gui/FrameMouseActions.java	(revision 1561)
@@ -1712,5 +1712,5 @@
 	public void mouseDragged(MouseEvent e) {
 		_lastMouseDragged = e;
-		// System.out.println("MouseDragged");
+		//System.out.println("MouseDragged");
 
 		// Stop the longDepress mouse timer if the user drags above a threshold
Index: /trunk/src/org/expeditee/gui/PopupManager.java
===================================================================
--- /trunk/src/org/expeditee/gui/PopupManager.java	(revision 1560)
+++ /trunk/src/org/expeditee/gui/PopupManager.java	(revision 1561)
@@ -118,6 +118,6 @@
 		synchronized(_popups) {
 			for (Popup popup : _popups) {
-				if (popup.getBounds().contains(p)) {
-					return true;
+				if (popup.getBounds().contains(p) && popup.isShowing()) {
+						return true;
 				}
 			}
@@ -199,11 +199,20 @@
 	public void paint()
 	{
-		//Bryce: popups temporarly disabled due to them not working and interfering in things.
-//		synchronized (_popups) {
-//			for (Popup popup : _popups) {
-//				popup.update();
-//				popup.paint();
-//			}
-//		}
+		/*
+		if (Browser.DEBUG) {
+			System.out.println("**** PopupManger::paint() -- num popups in arraylist: " + _popups.size());
+		}
+		*/
+		
+		//Bryce: popups temporarily disabled due to them not working and interfering in things.
+		//David: block of code now reintroduced: still some issue but working through them.
+		
+		synchronized (_popups) {
+			for (Popup popup : _popups) {
+				popup.update();
+				popup.paint();
+			}
+		}
+		
 	}
 	
@@ -252,4 +261,7 @@
 			}
 			
+			if (Browser.DEBUG) {
+				System.out.println("*** PopupManager::upate() updating animationCurrentTime: " + currentTime);
+			}
 			_animationCurrentTime = currentTime;
 			
@@ -353,5 +365,7 @@
 				setInitialBounds(fullBounds.clone());
 				_initialBounds.getTopLeft().setY(_initialBounds.getTopLeft().getY() + _initialBounds.getSize().height); 
+				//System.out.println("**** PopupManager::getAnimateBounds() forcing height to be fullBoundsHeight: ");
 				_initialBounds.getSize().height = 0;
+				//_initialBounds.getSize().height = fullBounds.getHeight(); // used to be 0
 			}
 			
@@ -360,5 +374,7 @@
 				percentShown = 1 - percentShown;
 			}
-			
+			if (Browser.DEBUG) {
+				System.out.println("Percentage = " + percentShown + " " + fullBounds);
+			}
 			return AxisAlignedBoxBounds.lerp(_initialBounds, fullBounds, percentShown);
 		}
Index: /trunk/src/org/expeditee/items/Text.java
===================================================================
--- /trunk/src/org/expeditee/items/Text.java	(revision 1560)
+++ /trunk/src/org/expeditee/items/Text.java	(revision 1561)
@@ -2469,6 +2469,8 @@
 			int model_frame_name_x = modelFrame.getNameItem().getX();
 			if (model_frame_name_x < DisplayController.MINIMUM_FRAME_WIDTH) {
-				System.err.println("**** Text::resetTitlePostion(): value to be used as right margin from position of frameName < 512");
-				System.err.println("  Overriding to ensure reasonable width for title"); 
+				if (org.expeditee.gui.Browser.DEBUG) {
+					System.err.println("**** Text::resetTitlePostion(): value to be used as right margin from position of frameName < 512");
+					System.err.println("  Overriding to ensure reasonable width for title"); 
+				}
 				model_frame_name_x = DisplayController.MINIMUM_FRAME_WIDTH;
 			}
Index: /trunk/src/org/expeditee/items/widgets/SwingWidget.java
===================================================================
--- /trunk/src/org/expeditee/items/widgets/SwingWidget.java	(revision 1560)
+++ /trunk/src/org/expeditee/items/widgets/SwingWidget.java	(revision 1561)
@@ -15,4 +15,5 @@
 
 import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
 
 import org.expeditee.core.bounds.AxisAlignedBoxBounds;
Index: /trunk/src/org/expeditee/items/widgets/Widget.java
===================================================================
--- /trunk/src/org/expeditee/items/widgets/Widget.java	(revision 1560)
+++ /trunk/src/org/expeditee/items/widgets/Widget.java	(revision 1561)
@@ -1117,9 +1117,13 @@
 			case ItemParentStateChangedEvent.EVENT_TYPE_ADDED:
 			case ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_OVERLAY:
-				System.err.println("Widget::onParentStateChanged: Added but not yet shown widget.");
+				if (org.expeditee.gui.Browser.DEBUG) {
+					System.err.println("Widget::onParentStateChanged: Added but not yet shown widget.");
+				}
 				break;
 			case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN:
 			case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY:
-				System.err.println("Widget::onParentStateChanged: Shown widget.");
+				if (org.expeditee.gui.Browser.DEBUG) {
+					System.err.println("Widget::onParentStateChanged: Shown widget.");
+				}
 				EcosystemManager.addInteractiveWidget(this);
 				addWidgetContent(e);
