Index: trunk/src/org/apollo/gui/FrameLayoutDaemon.java
===================================================================
--- trunk/src/org/apollo/gui/FrameLayoutDaemon.java	(revision 1061)
+++ trunk/src/org/apollo/gui/FrameLayoutDaemon.java	(revision 1102)
@@ -1,15 +1,8 @@
 package org.apollo.gui;
 
-import java.awt.Point;
-import java.awt.event.ComponentEvent;
-import java.awt.event.ComponentListener;
-import java.awt.event.MouseEvent;
 import java.io.File;
-import java.lang.reflect.InvocationTargetException;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
-
-import javax.swing.SwingUtilities;
 
 import org.apollo.audio.ApolloSubjectChangedEvent;
@@ -30,14 +23,16 @@
 import org.apollo.widgets.LinkedTrack;
 import org.apollo.widgets.SampledTrack;
-import org.expeditee.gui.Browser;
-import org.expeditee.gui.DisplayIO;
-import org.expeditee.gui.DisplayIOObserver;
+import org.expeditee.core.Point;
+import org.expeditee.gio.EcosystemManager;
+import org.expeditee.gio.InputManager.WindowEventListener;
+import org.expeditee.gio.InputManager.WindowEventType;
+import org.expeditee.gio.gesture.StandardGestureActions;
+import org.expeditee.gui.DisplayController;
+import org.expeditee.gui.DisplayObserver;
 import org.expeditee.gui.Frame;
-import org.expeditee.gui.FrameMouseActions;
 import org.expeditee.gui.FreeItems;
-import org.expeditee.gui.MouseEventRouter;
 import org.expeditee.items.Item;
 import org.expeditee.items.ItemUtils;
-import org.expeditee.items.widgets.InteractiveWidget;
+import org.expeditee.items.widgets.Widget;
 import org.expeditee.items.widgets.WidgetCorner;
 import org.expeditee.items.widgets.WidgetEdge;
@@ -46,5 +41,5 @@
  * A daemon that lays out overdubbed frames.
  * 
- * It is a singletone. Also it is a subject which raises empty events whenever
+ * It is a singleton. Also it is a subject which raises empty events whenever
  * a new timeline is created.
  * 
@@ -52,5 +47,5 @@
  *
  */
-public class FrameLayoutDaemon extends AbstractSubject implements Observer, DisplayIOObserver {
+public class FrameLayoutDaemon extends AbstractSubject implements Observer, DisplayObserver {
 	
 	/** The frame that should not be layout out at any point in time. */
@@ -98,30 +93,12 @@
 		daemon.start();
 		AudioStructureModel.getInstance().addObserver(this);
-		DisplayIO.addDisplayIOObserver(this);
-		
-		// Listen for resize events
-		SwingUtilities.invokeLater(new Runnable() {
-			public void run() {
-
-				// Keep expanded view centered to the browser window
-				if (Browser._theBrowser != null) {
-					Browser._theBrowser.addComponentListener(new ComponentListener() {
-
-						public void componentHidden(ComponentEvent e) {
-						}
-
-						public void componentMoved(ComponentEvent e) {
-						}
-
-						public void componentResized(ComponentEvent e) {
-							forceRecheck();
-						}
-
-						public void componentShown(ComponentEvent e) {
-						}
-						
-					});
-				}
-				
+		DisplayController.addDisplayObserver(this);
+		
+		EcosystemManager.getInputManager().addWindowEventListener(new WindowEventListener()
+		{
+			@Override
+			public void onWindowEvent(WindowEventType type)
+			{
+				if (type == WindowEventType.WINDOW_RESIZED) forceRecheck();
 			}
 		});
@@ -321,5 +298,5 @@
 				// Note that accessing expeditee model in another thread --
 				// Being real careful not to do anything unsafe
-				Frame currentFrame = DisplayIO.getCurrentFrame();
+				Frame currentFrame = DisplayController.getCurrentFrame();
 				if (currentFrame == null) continue;
 
@@ -340,9 +317,7 @@
 				
 				try {
-					SwingUtilities.invokeAndWait(trackFormatter);
-				} catch (InterruptedException e) {
+					EcosystemManager.getMiscManager().runOnGIOThread(trackFormatter);
+				} catch (Throwable e) {
 					e.printStackTrace();
-				} catch (InvocationTargetException e) {
-					e.printStackTrace();
 				}
 				
@@ -359,6 +334,6 @@
 				assert(toFormat != null);
 				
-				// To late?
-				if (toFormat != DisplayIO.getCurrentFrame()) return;
+				// Too late?
+				if (toFormat != DisplayController.getCurrentFrame()) return;
 				
 				boolean supressSpatialLayout = suspendedFrame == toFormat;
@@ -370,7 +345,7 @@
 				boolean hasRunningTime = false; // A flag set to true if there is actual audio to [lay
 				
-				Map<InteractiveWidget, AbstractTrackGraphNode> widgetsToFormat = new HashMap<InteractiveWidget, AbstractTrackGraphNode>();
-	
-				for (InteractiveWidget iw : toFormat.getInteractiveWidgets()) {
+				Map<Widget, AbstractTrackGraphNode> widgetsToFormat = new HashMap<Widget, AbstractTrackGraphNode>();
+	
+				for (Widget iw : toFormat.getInteractiveWidgets()) {
 					
 					AbstractTrackGraphNode abinf = null;
@@ -429,7 +404,5 @@
 				
 				// Anything to format?
-				if (!hasRunningTime || 
-						widgetsToFormat.isEmpty() || 
-						longestEndTime == firstInitiationTime) {
+				if (!hasRunningTime || widgetsToFormat.isEmpty() || longestEndTime == firstInitiationTime) {
 					
 					// NOTE: longestEndTime == firstInitiationTime indicates linked tracks 
@@ -450,5 +423,5 @@
 					// Ensure that left most pixel is at a reasonable position
 					if (!supressSpatialLayout && (initiationXPixel < 0 ||
-							(initiationXPixel > Browser._theBrowser.getWidth() && Browser._theBrowser.getWidth() > leftMargin))) {
+							(initiationXPixel > DisplayController.getFramePaintArea().getWidth() && DisplayController.getFramePaintArea().getWidth() > leftMargin))) {
 						initiationXPixel = leftMargin;
 					} else if (!supressSpatialLayout && initiationXPixel > LAYOUT_MAX_INITIATION_PIXEL) {
@@ -459,5 +432,5 @@
 						timelineWidth = rightMostPixel - initiationXPixel;
 					} else {
-						timelineWidth = Browser._theBrowser.getWidth() - initiationXPixel - rightMargin;
+						timelineWidth = DisplayController.getFramePaintArea().getWidth() - initiationXPixel - rightMargin;
 					}
 					
@@ -483,5 +456,5 @@
 				if (!supressSpatialLayout) {
 					
-					for (InteractiveWidget iw : widgetsToFormat.keySet()) {
+					for (Widget iw : widgetsToFormat.keySet()) {
 						
 						AbstractTrackGraphNode atgi = widgetsToFormat.get(iw);
@@ -545,5 +518,5 @@
 			
 				Item i = FreeItems.getItemAttachedToCursor();
-				InteractiveWidget freespaceTrackToFormat = null;
+				Widget freespaceTrackToFormat = null;
 				if (i != null && i instanceof WidgetEdge) {
 					freespaceTrackToFormat = ((WidgetEdge)i).getWidgetSource();
@@ -573,6 +546,7 @@
 					if (width > 0) {
 						
-						if (width > (Browser._theBrowser.getWidth() - (2 * FREE_SPACE_MARGINS)))
-							width = Browser._theBrowser.getWidth() - (2 * FREE_SPACE_MARGINS);
+						if (width > (DisplayController.getFramePaintArea().getWidth() - (2 * FREE_SPACE_MARGINS))) {
+							width = DisplayController.getFramePaintArea().getWidth() - (2 * FREE_SPACE_MARGINS);
+						}
 
 						freespaceTrackToFormat.setSize(
@@ -582,16 +556,12 @@
 						
 						// Keep the floating track on the cursor
-						MouseEvent me = MouseEventRouter.getCurrentMouseEvent();
-						Point containerPoint = SwingUtilities.convertPoint(me.getComponent(), me.getPoint(), Browser._theBrowser.getContentPane());
-						
+						Point containerPoint = EcosystemManager.getInputManager().getCursorPosition();
+						
+						// If due to resize the track is not longer over the cursor then just center it.
 						if (!ItemUtils.expandRectangle(freespaceTrackToFormat.getBounds(), 20).contains(containerPoint)) {
-							// If due to resize the track is not longer over the cursor then just center it.
 							int offsetX = width / 2; 
 							int offsetY = freespaceTrackToFormat.getHeight() / 2;
-							freespaceTrackToFormat.setPosition(
-									containerPoint.x - offsetX, 
-									containerPoint.y - offsetY);
-							FrameMouseActions.resetOffset();
-		
+							freespaceTrackToFormat.setPosition(containerPoint.x - offsetX, containerPoint.y - offsetY);
+							StandardGestureActions.resetOffset();
 						}
 						
@@ -756,5 +726,5 @@
 
 		// Look for all track widgets
-		for (InteractiveWidget iw : frame.getInteractiveWidgets()) {
+		for (Widget iw : frame.getInteractiveWidgets()) {
 			
 			if (iw instanceof SampledTrack) {
@@ -928,5 +898,5 @@
 	public static long inferCurrentTotalMSTime() {
 		
-		Frame currentFrame = DisplayIO.getCurrentFrame();
+		Frame currentFrame = DisplayController.getCurrentFrame();
 		String currentFrameName = (currentFrame != null) ? currentFrame.getName() : null;
 		
