Index: trunk/src/org/apollo/ApolloGestureActions.java
===================================================================
--- trunk/src/org/apollo/ApolloGestureActions.java	(revision 1098)
+++ trunk/src/org/apollo/ApolloGestureActions.java	(revision 1098)
@@ -0,0 +1,649 @@
+package org.apollo;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.apollo.gio.gesture.data.TrackAdjustmentGestureData;
+import org.apollo.util.Mutable;
+import org.apollo.widgets.LinkedTrack;
+import org.apollo.widgets.SampledTrack;
+import org.apollo.widgets.TrackWidgetCommons;
+import org.expeditee.core.Dimension;
+import org.expeditee.core.Point;
+import org.expeditee.gio.EcosystemManager;
+import org.expeditee.gio.gesture.Gesture;
+import org.expeditee.gio.gesture.GestureAction;
+import org.expeditee.gio.gesture.GestureListener;
+import org.expeditee.gio.gesture.StandardGestureActions;
+import org.expeditee.gio.gesture.StandardGestureActions.StandardGestureType;
+import org.expeditee.gio.gesture.data.ItemSpecificGestureData;
+import org.expeditee.gio.input.StandardInputEventListeners;
+import org.expeditee.gio.input.KBMInputEvent.Key;
+import org.expeditee.gio.gesture.Gesture.GestureType;
+import org.expeditee.gui.DisplayController;
+import org.expeditee.gui.Frame;
+import org.expeditee.gui.FrameIO;
+import org.expeditee.gui.FreeItems;
+import org.expeditee.items.Dot;
+import org.expeditee.items.Item;
+import org.expeditee.items.ItemUtils;
+import org.expeditee.items.Line;
+import org.expeditee.items.Text;
+import org.expeditee.items.UserAppliedPermission;
+import org.expeditee.items.Item.HighlightMode;
+import org.expeditee.items.widgets.Widget;
+import org.expeditee.items.widgets.WidgetCorner;
+import org.expeditee.items.widgets.WidgetEdge;
+
+public class ApolloGestureActions implements GestureListener
+{
+	public enum ApolloGestureType
+	{
+		ADJUST_INITIATION_TIME,
+		ADJUST_VERTICAL_POSITION,
+		CREATE_LINKED_TRACKS,
+		MODULUS_POSITION, // TODO: Think of a better name. cts16
+		TOGGLE_QUALITY_GRAPHICS
+	}
+	
+	private static ApolloGestureActions _instance = null;
+	
+	public static ApolloGestureActions getInstance()
+	{
+		if (_instance == null) {
+			_instance = new ApolloGestureActions();
+		}
+		
+		return _instance;
+	}
+	
+	private HashMap<ApolloGestureType, GestureType> _gestureTypes;
+
+	private HashMap<GestureType, GestureAction> _actions;
+	
+	private ApolloGestureActions()
+	{
+		_gestureTypes = new HashMap<ApolloGestureType, GestureType>();
+		initialiseGestureTypes();
+		_actions = new HashMap<GestureType, GestureAction>();
+		initialiseActions();
+	}
+	
+	@Override
+	public void onGesture(Gesture gesture)
+	{
+		performAction(gesture);
+	}
+	
+	private void setGestureAction(GestureType type, GestureAction action)
+	{
+		if (type == null) return;
+		
+		_actions.put(type, action);
+	}
+	
+	private GestureAction getGestureAction(GestureType type)
+	{
+		if (type == null) return null;
+		
+		return _actions.get(type);
+	}
+	
+	private void performAction(Gesture gesture)
+	{
+		GestureAction action = getGestureAction(gesture.getType());
+		if (action == null) return;
+		action.exec(gesture);
+	}
+	
+	private void initialiseActions()
+	{
+		// Set the ADJUST_INITIATION_TIME action
+		setGestureAction(gestureType(ApolloGestureType.ADJUST_INITIATION_TIME), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				TrackAdjustmentGestureData data = (TrackAdjustmentGestureData) gesture.getData();
+				
+				Widget selectedIW = null;
+				
+				if (data.getCurrentItem() != null) {
+					if (data.getCurrentItem() instanceof WidgetEdge) {
+						selectedIW = ((WidgetEdge) data.getCurrentItem()).getWidgetSource();
+					} else if (data.getCurrentItem() instanceof WidgetCorner) {
+						selectedIW = ((WidgetCorner) data.getCurrentItem()).getWidgetSource();
+					}
+				}
+				
+				if (selectedIW != null) adjustInitiationTime(selectedIW, data.getAdjustment());
+			}
+		});
+		
+		// Set the ADJUST_VERTICAL_POSITION action
+		setGestureAction(gestureType(ApolloGestureType.ADJUST_VERTICAL_POSITION), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				TrackAdjustmentGestureData data = (TrackAdjustmentGestureData) gesture.getData();
+				
+				Widget selectedIW = null;
+				
+				if (data.getCurrentItem() != null) {
+					if (data.getCurrentItem() instanceof WidgetEdge) {
+						selectedIW = ((WidgetEdge) data.getCurrentItem()).getWidgetSource();
+					} else if (data.getCurrentItem() instanceof WidgetCorner) {
+						selectedIW = ((WidgetCorner) data.getCurrentItem()).getWidgetSource();
+					}
+				}
+				
+				if (selectedIW != null) adjustVerticalPosition(selectedIW, data.getAdjustment());
+			}
+		});
+		
+		// Set the CREATE_LINKED_TRACKS action
+		setGestureAction(gestureType(ApolloGestureType.CREATE_LINKED_TRACKS), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				ItemSpecificGestureData data = (ItemSpecificGestureData) gesture.getData();
+				
+				createLinkedTracks(data.getCurrentItem(), data.getCurrentItems());
+			}
+		});
+		
+		// Set the MOD_POSITION action
+		setGestureAction(gestureType(ApolloGestureType.MODULUS_POSITION), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				Frame current = DisplayController.getCurrentFrame();
+				Dimension windowSize = EcosystemManager.getGraphicsManager().getWindowSize();
+				
+				for (Item i : current.getItems()) {
+					Point pos = i.getPosition();
+					pos.x %= windowSize.width;
+					pos.y %= windowSize.height;
+					i.setPosition(pos);
+				}
+			}
+		});
+		
+		// Set the TOGGLE_QUALITY_GRAPHICS action
+		setGestureAction(gestureType(ApolloGestureType.TOGGLE_QUALITY_GRAPHICS), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				ApolloSystem.useQualityGraphics = !ApolloSystem.useQualityGraphics;
+			}
+		});
+		
+		// Set the MOVE_CURSOR action
+		setGestureAction(StandardGestureActions.getInstance().gestureType(StandardGestureType.MOVE_CURSOR), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				mouseMoved(gesture.getData().getPosition());
+			}
+		});
+		
+		// Set the PLACE action
+		setGestureAction(StandardGestureActions.getInstance().gestureType(StandardGestureType.PLACE), new GestureAction()
+		{
+			@Override
+			public void exec(Gesture gesture)
+			{
+				anchorTracks();
+			}
+		});
+	}
+	
+	/** Initialises the set of gesture types. */
+	private void initialiseGestureTypes()
+	{
+		for (ApolloGestureType type : ApolloGestureType.values()) {
+			GestureType gestureType;
+			if ((gestureType = GestureType.register(type.toString())) == null) {
+				gestureType = GestureType.get(type.toString());
+			}
+			_gestureTypes.put(type, gestureType);
+		}
+	}
+	
+	/** Gets the gesture type associated with the given standard type. */
+	public GestureType gestureType(ApolloGestureType type)
+	{
+		if (type == null) return null;
+		
+		return _gestureTypes.get(type);
+	}
+
+	/* TODO: EVERYTHING BELOW HERE IS ONLY TEMPORARILY SITUATED IN THIS CLASS
+	 *  
+	 * The following methods were mostly copy-pasted here from the old ApolloFrameKeyboardActions
+	 * and ApolloFrameMouseActions classes (to enable quick change-over to the new input system).
+	 * Really they should be relocated to more suitable homes based on their function. 
+	 */
+	
+	public static void adjustInitiationTime(Widget track, long adjustment)
+	{
+		if (track instanceof SampledTrack) {
+			adjustInitiationTime((SampledTrack) track, adjustment);
+		} else if (track instanceof LinkedTrack) {
+			adjustInitiationTime((LinkedTrack) track, adjustment);
+		}
+	}
+	
+	public static void adjustInitiationTime(SampledTrack track, long adjustment)
+	{
+		Mutable.Long oldIt = track.getInitiationTimeFromMeta();
+		if (oldIt == null) oldIt = Mutable.createMutableLong(0);
+		track.setInitiationTime(oldIt.value + adjustment);
+	}
+	
+	public static void adjustInitiationTime(LinkedTrack track, long adjustment)
+	{
+		Mutable.Long oldIt = track.getInitiationTimeFromMeta();
+		if (oldIt == null) oldIt = Mutable.createMutableLong(0);
+		track.setInitiationTime(oldIt.value + adjustment);
+	}
+	
+	public static void adjustVerticalPosition(Widget track, long adjustment)
+	{
+		if (track instanceof SampledTrack) {
+			adjustVerticalPosition((SampledTrack) track, adjustment);
+		} else if (track instanceof LinkedTrack) {
+			adjustVerticalPosition((LinkedTrack) track, adjustment);
+		}
+	}
+	
+	public static void adjustVerticalPosition(SampledTrack track, long adjustment)
+	{
+		track.setYPosition(track.getY() + (int) adjustment);
+	}
+	
+	public static void adjustVerticalPosition(LinkedTrack track, long adjustment)
+	{
+		track.setYPosition(track.getY() + (int) adjustment);
+	}
+
+	public static void createLinkedTracks(Item currentItem, Collection<Item> enclosedItems)
+	{
+		if (currentItem == null) {
+
+			if (enclosedItems != null) {
+				
+				Frame current = DisplayController.getCurrentFrame();
+				
+				Collection<Item> toRemove = new LinkedHashSet<Item>(enclosedItems.size());
+				LinkedList<LinkedTrack> enclosedLinkedTracks = new LinkedList<LinkedTrack>();
+				LinkedList<SampledTrack> enclosedTracks = new LinkedList<SampledTrack>();
+				
+				// Get enclosing shape and enclosed tracks
+				for (Item ip : enclosedItems) {
+					if (ip.getParent() != current) continue;
+					
+					if (ip.hasPermission(UserAppliedPermission.full)) {
+						// Only include lines if one of their enpoints are also  being removed
+						if (ip instanceof Line) {
+							Line l = (Line) ip;
+							Item end = l.getEndItem();
+							Item start = l.getStartItem();
+
+							// If one end of a line is being delted, remove the
+							// other end if all its connecting lines are being
+							// delted
+							if (enclosedItems.contains(end)) {
+								if (!enclosedItems.contains(start)
+										&& enclosedItems.containsAll(start.getLines())) {
+									toRemove.add(start);
+								}
+							} else if (enclosedItems.contains(start)) {
+								if (enclosedItems.containsAll(end.getLines())) {
+									toRemove.add(end);
+								}
+							} else {
+								continue;
+							}
+						} else if (ip instanceof WidgetCorner){
+							Widget iw = ((WidgetCorner)ip).getWidgetSource();
+							if (!enclosedTracks.contains(iw) && iw instanceof SampledTrack) {
+								enclosedTracks.add((SampledTrack)iw);
+							} else if (!enclosedLinkedTracks.contains(iw) && iw instanceof LinkedTrack) {
+								enclosedLinkedTracks.add((LinkedTrack)iw);
+							}
+						} else {
+							if ((ip instanceof Line || ip instanceof Dot) && ip.getHighlightMode() == HighlightMode.Enclosed) {
+								toRemove.add(ip);
+								toRemove.addAll(ip.getConnected());
+							}
+						}
+						
+					}
+				} // End searching enclosed items
+				
+				
+				// If there was some enclosed tracks
+				if (current != null && !toRemove.isEmpty() && (!enclosedLinkedTracks.isEmpty() || !enclosedTracks.isEmpty())) {
+
+					// Remove enclosure
+					current.removeAllItems(toRemove);
+					
+					// Determine initiation time of group
+					Mutable.Long initTime = null;
+					Point initiatePosition = null;
+					
+					for (SampledTrack st : enclosedTracks) {
+						
+						if (initTime == null) {
+							initTime = st.getInitiationTimeFromMeta();
+							initiatePosition = st.getPosition();
+						}
+						else if (st.getInitiationTimeFromMeta() != null &&
+								st.getInitiationTimeFromMeta().value < initTime.value) {
+							initTime = st.getInitiationTimeFromMeta();
+							initiatePosition = st.getPosition();
+						}
+					}
+					for (LinkedTrack lt : enclosedLinkedTracks) {
+
+						if (initTime == null) {
+							initTime = lt.getInitiationTimeFromMeta();
+							initiatePosition = lt.getPosition();
+						}
+						else if (lt.getInitiationTimeFromMeta() != null &&
+								lt.getInitiationTimeFromMeta().value < initTime.value) {
+							initTime = lt.getInitiationTimeFromMeta();
+							initiatePosition = lt.getPosition();
+						}
+					}
+					
+					assert(initTime != null);
+					assert(initiatePosition != null);
+					
+					// Creat the link to contain all tracks
+					String name = current.getTitle();
+					if (name == null) name = "Unnamed";
+					name += " group";
+					
+					Text linkSource = new Text(current.getNextItemID());
+					linkSource.addToData(TrackWidgetCommons.META_NAME_TAG + name);
+					linkSource.addToData(TrackWidgetCommons.META_INITIATIONTIME_TAG + initTime);
+					linkSource.setPosition(initiatePosition);
+					linkSource.setParent(current);
+					LinkedTrack linkedVersion = new LinkedTrack(linkSource, null);
+					
+					// Create a new frame to hold the track group
+					Frame newFrame = FrameIO.CreateNewFrame(linkedVersion.getItems().get(0));
+
+					for (SampledTrack st : enclosedTracks) {
+						st.saveAudio(); // Blocking
+						current.removeAllItems(st.getItems());
+						newFrame.addAllItems(st.getItems());
+					}
+					
+					for (LinkedTrack lt : enclosedLinkedTracks) {
+						current.removeAllItems(lt.getItems());
+						newFrame.addAllItems(lt.getItems());
+					}
+					
+					FrameIO.SaveFrame(newFrame);
+					
+					// Link the linked tracks
+					linkedVersion.setLink(newFrame.getName(), null);
+					
+					// Add the new link
+					current.addAllItems(linkedVersion.getItems());
+					
+					// Ensure initiation time is retained to the exact frame... avoiding loss due to resolution
+					linkedVersion.setInitiationTime(initTime.value);
+				}
+			}
+		}
+	}
+	
+	/** The minimum distance from a track widget to auto-align free space items to. */
+	private static final int COARSE_X_PLACEMENT_TOLERANCE = 80;
+
+	private static final int COARSE_Y_PLACEMENT_TOLERANCE = 20; 
+	
+	public void mouseMoved(Point to)
+	{
+		boolean forwareToExpeditee = true;
+		
+		if (isYAxisRestictionOn() && !FreeItems.getInstance().isEmpty()) { 
+
+			// Restrict movement of free items to Y-Axis only
+			forwareToExpeditee = false;
+
+			int smallestY = FreeItems.getInstance().get(0).getY();
+
+			for (Item i : FreeItems.getInstance()) {
+				if (i.getY() < smallestY) smallestY = i.getY();
+			}
+
+			for (Item i : FreeItems.getInstance()) {
+				i.setY(to.getY() + (i.getY() - smallestY));
+			}
+			
+		} else if (isSnapOn() && !FreeItems.getInstance().isEmpty()) { 
+			
+			// Couse movement of free items: Restraining left-most pixel in items
+			// to the closest anchored track widgets x position.
+			
+			Frame currentFrame = DisplayController.getCurrentFrame();
+			if (currentFrame != null) {
+				
+				// Search all anchored track x positions for the current frame
+				List<Widget> widgets = currentFrame.getInteractiveWidgets();
+				
+				int closestXPosition = -1;
+				int closestYPosition = -1;
+				int closestXDistance = -1;
+				int closestYDistance = -1;
+				
+				for (Widget iw : widgets) {
+					
+					if (iw instanceof SampledTrack || iw instanceof LinkedTrack) {
+						
+						// Determine TOP-LEFT Snapping
+						int xDistance = Math.abs(to.getX() - iw.getX());
+						if (closestXDistance < 0 || xDistance < closestXDistance) {
+							closestXDistance = xDistance;
+							closestXPosition = iw.getX();
+						}
+						
+						int yDistance = Math.abs(to.getY() - iw.getY());
+						if (closestYDistance < 0 || yDistance < closestYDistance) {
+							closestYDistance = yDistance;
+							closestYPosition = iw.getY();
+						}
+
+						// Determine BOTTOM-RIGHT Snapping
+						xDistance = Math.abs(to.getX() - (iw.getX() + iw.getWidth()));
+						if (closestXDistance < 0 || xDistance < closestXDistance) {
+							closestXDistance = xDistance;
+							closestXPosition = iw.getX() + iw.getWidth();
+						}
+						
+						yDistance = Math.abs(to.getY() - (iw.getY() + iw.getHeight()));
+						if (closestYDistance < 0 || yDistance < closestYDistance) {
+							closestYDistance = yDistance;
+							closestYPosition = iw.getY() + iw.getHeight();
+						}
+					}
+						
+				}
+				
+				//Determine top-left position of free items
+				int smallestX = FreeItems.getInstance().get(0).getX();
+				int smallestY = FreeItems.getInstance().get(0).getY();
+				for (Item i : FreeItems.getInstance()) {
+					if (i.getX() < smallestX) smallestX = i.getX();
+					if (i.getY() < smallestY) smallestY = i.getY();
+				}
+
+				for (Item i : FreeItems.getInstance()) {
+					
+					int x;
+					int y;
+					
+					if (closestXDistance > 0 && closestXDistance < COARSE_X_PLACEMENT_TOLERANCE) 
+						x = closestXPosition + (i.getX() - smallestX);
+					else 
+						x = to.getX() + (i.getX() - smallestX);
+					
+					if (closestYDistance > 0 && closestYDistance < COARSE_Y_PLACEMENT_TOLERANCE)
+						y = closestYPosition + (i.getY() - smallestY);
+					else 
+						y = to.getY() + (i.getY() - smallestY);
+					
+					i.setPosition(x, y);
+					
+				}
+
+				forwareToExpeditee = false;
+
+			}
+			
+		}
+		
+		// Expeditees frame mouse actions uses an offset and fights over free-item
+		// movement if it listens to the mouse event router... therefore add an extra
+		// layer to avoid this... otherwise auto-aligned items jitter like crazy while
+		// moving the cursus
+		//if (forwareToExpeditee) {
+			//FrameMouseActions.getInstance().mouseMoved(e);
+		//} else {
+			//FrameGraphics.refresh(true);
+		//}
+	}
+
+	/**
+	 * @return
+	 * 		True if the user is restricting movement on the y-axis only
+	 */
+	public static boolean isYAxisRestictionOn()
+	{
+		return 	StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL) &&
+				!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.SHIFT);
+	}
+	
+	public static boolean isSnapOn()
+	{
+		return 	StandardInputEventListeners.kbmStateListener.isKeyDown(Key.SHIFT) &&
+				!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL);
+	}
+	
+	public void anchorTracks() {
+		
+		// Widget -> delta IT time
+		Map<LinkedTrack, Mutable.Long> anchoredLinkedTracks = null;
+		Map<SampledTrack, Mutable.Long> anchoredTracks = null;
+		
+		if (FreeItems.getInstance().size() > 1) {
+			List<Widget> anchoringWidgets = ItemUtils.extractWidgets(FreeItems.getInstance());
+
+			Mutable.Long firstInitTime = null;
+			anchoredLinkedTracks = new HashMap<LinkedTrack, Mutable.Long>();
+			anchoredTracks = new HashMap<SampledTrack, Mutable.Long>();
+			
+			for (Widget iw : anchoringWidgets) {
+				
+				Mutable.Long it = null;
+				
+				if (iw instanceof LinkedTrack) {
+					
+					LinkedTrack lt = (LinkedTrack)iw;
+					it = lt.getInitiationTimeFromMeta();
+					if (it == null) it = Mutable.createMutableLong(0);
+					
+					anchoredLinkedTracks.put(lt, it);
+					
+				} else if (iw instanceof SampledTrack) {
+					
+					SampledTrack st = (SampledTrack)iw;
+					it = st.getInitiationTimeFromMeta();
+					if (it == null) it = Mutable.createMutableLong(0);
+					
+					anchoredTracks.put(st, it);
+				
+				} else continue;
+				
+				if (firstInitTime == null) {
+					firstInitTime = Mutable.createMutableLong(it.value); // Important to create new instance
+				} else if (it.value < firstInitTime.value) {
+					firstInitTime = Mutable.createMutableLong(it.value); // Important to create new instance
+				}
+			}
+			
+			// Should do a accurate anchor with init times properly aligned?
+			if ((anchoredLinkedTracks.size() + anchoredTracks.size()) > 1) {
+				
+				assert(firstInitTime != null);
+				
+				// Then calc all the deltas
+				for (LinkedTrack lt : anchoredLinkedTracks.keySet()) {
+					Mutable.Long it = anchoredLinkedTracks.get(lt);
+					it.value -= firstInitTime.value;
+				}
+				
+				for (SampledTrack st : anchoredTracks.keySet()) {
+					Mutable.Long it = anchoredTracks.get(st);
+					it.value -= firstInitTime.value;
+				}
+
+			} else {
+				anchoredLinkedTracks = null;
+				anchoredTracks = null;
+			}
+		
+		}
+		
+		// If anchored a group of tracks .. adjust initiation times to
+		if (anchoredLinkedTracks != null) {
+			
+			Mutable.Long firstInitTime = null;
+			
+			for (LinkedTrack lt : anchoredLinkedTracks.keySet()) {
+				Mutable.Long it = anchoredLinkedTracks.get(lt);
+				if (it.value == 0) {
+					firstInitTime = lt.getInitiationTimeFromMeta();
+					break;
+				}
+			}
+			if (firstInitTime == null) {
+				for (SampledTrack st : anchoredTracks.keySet()) {
+					Mutable.Long it = anchoredTracks.get(st);
+					if (it.value == 0) {
+						firstInitTime = st.getInitiationTimeFromMeta();
+						break;
+					}
+				}
+			}
+			assert(firstInitTime != null);
+			
+			for (LinkedTrack lt : anchoredLinkedTracks.keySet()) {
+				Mutable.Long it = anchoredLinkedTracks.get(lt);
+				if (it.value == 0) continue;
+				lt.setInitiationTime(firstInitTime.value + it.value);
+			}
+			
+			for (SampledTrack st : anchoredTracks.keySet()) {
+				Mutable.Long it = anchoredTracks.get(st);
+				if (it.value == 0) continue;
+				st.setInitiationTime(firstInitTime.value + it.value);
+			}
+			
+		}
+	}
+}
Index: trunk/src/org/apollo/ApolloKBMGestureTranslator.java
===================================================================
--- trunk/src/org/apollo/ApolloKBMGestureTranslator.java	(revision 1098)
+++ trunk/src/org/apollo/ApolloKBMGestureTranslator.java	(revision 1098)
@@ -0,0 +1,213 @@
+package org.apollo;
+
+import java.util.List;
+
+import org.apollo.ApolloGestureActions.ApolloGestureType;
+import org.apollo.gio.gesture.data.TrackAdjustmentGestureData;
+import org.expeditee.gio.gesture.ExpediteeKBMGestureTranslator;
+import org.expeditee.gio.gesture.Gesture;
+import org.expeditee.gio.gesture.StandardGestureActions.StandardGestureType;
+import org.expeditee.gio.gesture.data.GestureData;
+import org.expeditee.gio.gesture.data.ItemSpecificGestureData;
+import org.expeditee.gio.gesture.data.RefreshGestureData;
+import org.expeditee.gio.input.InputEvent;
+import org.expeditee.gio.input.InputEventToGestureTranslator;
+import org.expeditee.gio.input.InputEventToGestureTranslatorSet;
+import org.expeditee.gio.input.KBMInputEvent;
+import org.expeditee.gio.input.InputEvent.InputType;
+import org.expeditee.gio.input.KBMInputEvent.Key;
+import org.expeditee.gio.input.KBMInputEvent.MouseButton;
+import org.expeditee.gio.input.StandardInputEventListeners;
+
+public class ApolloKBMGestureTranslator extends InputEventToGestureTranslatorSet
+{
+	public static final long TRACK_WIDGET_TIMELINE_ADJUSTMENT = 50;
+	public static final long TRACK_WIDGET_VERTICAL_ADJUSTMENT = 5;
+	
+	public ApolloKBMGestureTranslator()
+	{
+		// Create the list of sub-translators
+		initialiseApolloTranslators();
+	}
+	
+	public void initialiseApolloTranslators()
+	{
+		// Add the CTRL + LEFT/RIGHT -> ADJUST_INITIATION_TIME gesture recogniser
+		addTranslator(new InputEventToGestureTranslator(InputType.KBM)
+		{
+			@Override
+			public String details() { return "CTRL + LEFT/RIGHT -> ADJUST_INITIATION_TIME"; }
+
+			@Override
+			public List<Gesture> onInputEvent(InputEvent event)
+			{
+				// Cast to keyboard/mouse event
+				KBMInputEvent kbmEvent = (KBMInputEvent) event;
+				
+				// Check that ctrl is down
+				if (!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL)) return null;
+				
+				// Calculate the adjustment amount
+				long adjustment;
+				if (kbmEvent.getKeyDown() == Key.LEFT_ARROW) {
+					adjustment = -TRACK_WIDGET_TIMELINE_ADJUSTMENT;
+				} else if (kbmEvent.getKeyDown() == Key.RIGHT_ARROW) {
+					adjustment = TRACK_WIDGET_TIMELINE_ADJUSTMENT;
+				} else {
+					return null;
+				}
+				
+				// Return the gesture
+				return apolloSingle(ApolloGestureType.ADJUST_INITIATION_TIME, new TrackAdjustmentGestureData(adjustment));
+			}
+		});
+		
+		// Add the CTRL + UP/DOWN -> ADJUST_VERTICAL_POSITION gesture recogniser
+		addTranslator(new InputEventToGestureTranslator(InputType.KBM)
+		{
+			@Override
+			public String details() { return "CTRL + UP/DOWN -> ADJUST_VERTICAL_POSITION"; }
+
+			@Override
+			public List<Gesture> onInputEvent(InputEvent event)
+			{
+				// Cast to keyboard/mouse event
+				KBMInputEvent kbmEvent = (KBMInputEvent) event;
+				
+				// Check that ctrl is down
+				if (!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL)) return null;
+				
+				// Calculate the adjustment amount
+				long adjustment;
+				if (kbmEvent.getKeyDown() == Key.UP_ARROW) {
+					adjustment = -TRACK_WIDGET_VERTICAL_ADJUSTMENT;
+				} else if (kbmEvent.getKeyDown() == Key.DOWN_ARROW) {
+					adjustment = TRACK_WIDGET_VERTICAL_ADJUSTMENT;
+				} else {
+					return null;
+				}
+				
+				// Return the gesture
+				return apolloSingle(ApolloGestureType.ADJUST_VERTICAL_POSITION, new TrackAdjustmentGestureData(adjustment));
+			}
+		});
+		
+		// Add the CTRL + SHIFT + F -> MOD_POSITION gesture recogniser
+		addTranslator(new InputEventToGestureTranslator(InputType.KBM)
+		{
+			@Override
+			public String details() { return "CTRL + SHIFT + F -> MOD_POSITION"; }
+
+			@Override
+			public List<Gesture> onInputEvent(InputEvent event)
+			{
+				// Cast to keyboard/mouse event
+				KBMInputEvent kbmEvent = (KBMInputEvent) event;
+				
+				// Check that ctrl is down
+				if (!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL)) return null;
+				
+				// Check that shift is down
+				if (!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.SHIFT)) return null;
+				
+				// Check that F was pressed
+				if (kbmEvent.getKeyDown() != Key.F) return null;
+				
+				// Return the gesture
+				return apolloSingle(ApolloGestureType.MODULUS_POSITION, null);
+			}
+		});
+		
+		// Add the CTRL + L -> CREATE_LINKED_TRACKS gesture recogniser
+		addTranslator(new InputEventToGestureTranslator(InputType.KBM)
+		{
+			@Override
+			public String details() { return "CTRL + L -> CREATE_LINKED_TRACKS"; }
+
+			@Override
+			public List<Gesture> onInputEvent(InputEvent event)
+			{
+				// Cast to keyboard/mouse event
+				KBMInputEvent kbmEvent = (KBMInputEvent) event;
+				
+				// Check that ctrl is down
+				if (!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL)) return null;
+				
+				// Check that L was pressed
+				if (kbmEvent.getKeyDown() != Key.L) return null;
+				
+				// Return the gesture
+				return apolloSingle(ApolloGestureType.CREATE_LINKED_TRACKS, new ItemSpecificGestureData());
+			}
+		});
+		
+		// Add the CTRL + G -> TOGGLE_QUALITY_GRAPHICS gesture recogniser
+		addTranslator(new InputEventToGestureTranslator(InputType.KBM)
+		{
+			@Override
+			public String details() { return "CTRL + G -> TOGGLE_QUALITY_GRAPHICS"; }
+
+			@Override
+			public List<Gesture> onInputEvent(InputEvent event)
+			{
+				// Cast to keyboard/mouse event
+				KBMInputEvent kbmEvent = (KBMInputEvent) event;
+				
+				// Check that ctrl is down
+				if (!StandardInputEventListeners.kbmStateListener.isKeyDown(Key.CTRL)) return null;
+				
+				// Check that G was pressed
+				if (kbmEvent.getKeyDown() != Key.G) return null;
+				
+				// Return the gesture
+				return apolloSingle(ApolloGestureType.TOGGLE_QUALITY_GRAPHICS, null);
+			}
+		});
+		
+		// Add the CTRL -> REFRESH gesture recogniser
+		addTranslator(new InputEventToGestureTranslator(InputType.KBM)
+		{
+			@Override
+			public String details() { return "CTRL -> REFRESH"; }
+
+			@Override
+			public List<Gesture> onInputEvent(InputEvent event)
+			{
+				// Cast to keyboard/mouse event
+				KBMInputEvent kbmEvent = (KBMInputEvent) event;
+				
+				// Check that ctrl was pressed
+				if (kbmEvent.getKeyDown() != Key.CTRL) return null;
+				
+				// Return the gesture
+				return ExpediteeKBMGestureTranslator.standardSingle(StandardGestureType.REFRESH, new RefreshGestureData(false, false));
+			}
+		});
+	}
+	
+	public boolean isKeyDown(Key key)
+	{
+		return StandardInputEventListeners.kbmStateListener.isKeyDown(key);
+	}
+	
+	public boolean isMouseButtonDown(MouseButton button)
+	{
+		return StandardInputEventListeners.kbmStateListener.isMouseButtonDown(button);
+	}
+	
+	public boolean isOnlyMouseButtonDown(MouseButton button)
+	{
+		return StandardInputEventListeners.kbmStateListener.isOnlyMouseButtonDown(button);
+	}
+	
+	public boolean isAnyMouseButtonDown()
+	{
+		return StandardInputEventListeners.kbmStateListener.isAnyMouseButtonDown();
+	}
+	
+	/** Convenience function to create a single standard gesture. */
+	private List<Gesture> apolloSingle(ApolloGestureType type, GestureData data)
+	{
+		return Gesture.single(ApolloGestureActions.getInstance().gestureType(type), data);
+	}
+}
Index: trunk/src/org/expeditee/Util.java
===================================================================
--- trunk/src/org/expeditee/Util.java	(revision 1098)
+++ trunk/src/org/expeditee/Util.java	(revision 1098)
@@ -0,0 +1,252 @@
+package org.expeditee;
+
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.expeditee.stats.Formatter;
+
+/**
+ * Static collection of various helper methods.
+ * 
+ * @author cts16
+ *
+ */
+public class Util {
+	
+	/**
+	 * Using Microsofts commandline convention: Args seperated with white
+	 * spaces. Options with white spaces enclosed with quotes. Args with quotes
+	 * must be double quoted args1 args2=sfasas args3="option with spaces"
+	 * arg""4""
+	 * 
+	 * @param args
+	 *            Null and empty excepted
+	 * @return An array of args. null if none provided
+	 */
+	public static String[] parseArgs(String args) {
+
+		if (args == null)
+			return null;
+
+		args = args.trim();
+		if (args.length() == 0)
+			return null;
+
+		List<String> vargs = new LinkedList<String>();
+		StringBuilder sb = new StringBuilder();
+		boolean quoteOn = false;
+		for (int i = 0; i < args.length(); i++) {
+
+			char c = args.charAt(i);
+			if (c == ' ' && !quoteOn) {
+
+				// Extract arg
+				vargs.add(sb.toString());
+				sb = new StringBuilder();
+
+				// Consume white spaces
+				while (args.charAt(++i) == ' ' && i < args.length()) {
+				}
+				i--;
+
+			} else if (c == '\"') {
+				// If double quoted
+				if (args.length() >= (i + 2) && args.charAt(i + 1) == '\"') {
+
+					sb.append(c); // add escaped
+					i++;
+
+				} else {
+					quoteOn = !quoteOn;
+				}
+
+			} else {
+				sb.append(c);
+			}
+		}
+
+		if (sb.length() > 0)
+			vargs.add(sb.toString());
+
+		if (vargs.size() == 0)
+			return null;
+		else
+			return vargs.toArray(new String[vargs.size()]);
+	}
+
+	/**
+	 * Reverse of parseArgs
+	 * 
+	 * @return Null if args is null or empty / all whitespace
+	 */
+	public static String formatArgs(String[] args) {
+		if (args == null)
+			return null;
+
+		StringBuilder sb = new StringBuilder();
+
+		for (String s : args) {
+			if (s == null)
+				continue;
+
+			// Escape quotes
+			StringBuilder formatted = new StringBuilder(s.replaceAll("\"",
+					"\"\""));
+
+			// Encapsulate spaces
+			int index = formatted.indexOf(" ");
+			if (index >= 0) {
+				formatted.insert(index, "\"");
+				formatted.append('\"');
+			}
+
+			if (sb.length() > 0)
+				sb.append(' ');
+			sb.append(formatted);
+		}
+
+		return sb.length() > 0 ? sb.toString() : null;
+	}
+	
+	/**
+	 * Parses a date from the given string.
+	 * 
+	 * @param dateString
+	 * 		The string to parse.
+	 * 
+	 * @return
+	 * 		The date parsed from the string.
+	 * 
+	 * @throws ParseException
+	 */
+	public static Date parseDate(String dateString) throws ParseException {
+		// Select the best match for a date or time format
+		DateFormat df = null;
+		if (dateString.length() > Formatter.DATE_FORMAT.length()) {
+			df = new SimpleDateFormat(Formatter.DATE_TIME_FORMAT);
+		} else if (dateString.length() <= Formatter.TIME_FORMAT.length()) {
+			df = new SimpleDateFormat(Formatter.TIME_FORMAT);
+		} else {
+			df = new SimpleDateFormat(Formatter.DATE_FORMAT);
+		}
+		Date date = df.parse(dateString);
+		return date;
+	}
+	
+	/**
+	 * Sets all members of the given array to the given value.
+	 * 
+	 * @param arr
+	 * 		The array to initialise.
+	 * 
+	 * @param val
+	 * 		The value to set each element to.
+	 */
+	public static void initialiseBoolArray(boolean[] arr, boolean val)
+	{
+		for (int i = 0; i < arr.length; i++) arr[i] = val;
+	}
+	
+	/** Whether or not the system has been checked to see if the Java version is >= 1.6 */
+	private static boolean _minimum_version6_checked = false;
+	/** Whether or not the Java version running is >= 1.6 */
+	private static boolean _minimum_version6 = false;
+
+	/**
+	 * Checks if the running version of Java is >= 1.6.
+	 * 
+	 * @return
+	 * 		True if the Java version is >= 1.6, false otherwise.
+	 */
+	public static boolean isMinimumVersion6()
+	{
+		// If we haven't checked yet, do so
+		if (!_minimum_version6_checked) {
+			String full_version = System.getProperty("java.version");
+			String[] version_parts = full_version.split("\\.");
+			if (version_parts.length>=2) {
+				String version_str = version_parts[0] + "." + version_parts[1];
+				double version = Double.parseDouble(version_str);
+				if (version >= 1.6) {
+					_minimum_version6 = true;
+				}
+			}
+			
+			_minimum_version6_checked = true;
+		}
+		
+		return _minimum_version6;
+	}
+	
+	/**
+	 * Returns an array of roots to the quadratic equation ax^2 + bx + c = 0.
+	 * Will be null, or contain 1 or 2 values depending on the constants given.
+	 */
+	public static double[] quadraticEquation(double a, double b, double c)
+	{
+		// Calculate the discriminant
+		double discriminant = b * b - 4 * a * c;
+		
+		// See how many roots we have
+		if (discriminant < 0) {
+			return null;
+		} else if (discriminant == 0) {
+			double[] ret = new double[1];
+			ret[0] = -b / (2 * a);
+			return ret;
+		} else {
+			double[] ret = new double[2];
+			ret[0] = (-b + Math.sqrt(discriminant)) / (2 * a);
+			ret[1] = (-b - Math.sqrt(discriminant)) / (2 * a);
+			return ret;
+		}
+	}
+	
+	public static double[] toDoubleArray(float[] floatArray)
+	{
+		if (floatArray == null) return null;
+		
+		double[] ret = new double[floatArray.length];
+		
+		for (int i = 0; i < floatArray.length; i++) {
+			ret[i] = floatArray[i];
+		}
+		
+		return ret;
+	}
+	
+	/** Creates a hash-set from an array. */
+	public static <T> HashSet<T> hashSetFromArray(T[] array)
+	{
+		if (array == null) return null;
+		
+		HashSet<T> ret = new HashSet<T>();
+		for (T element : array) ret.add(element);
+		
+		return ret;
+	}
+	
+	/** Returns the string which is n concatenations of the given character. */
+	public static String nCopiesOf(int n, char character)
+	{
+		if (n < 0) {
+			return null;
+		} else if (n == 0) {
+			return "";
+		} else {
+			return String.join("", Collections.nCopies(n, Character.toString(character)));
+		}
+	}
+	
+	/** Returns the linear interpolation between a and b. */
+	public static float lerp(float a, float b, float t)
+	{
+		return t * (b - a) + a;
+	}
+}
Index: trunk/src/org/expeditee/gui/DisplayController.java
===================================================================
--- trunk/src/org/expeditee/gui/DisplayController.java	(revision 1098)
+++ trunk/src/org/expeditee/gui/DisplayController.java	(revision 1098)
@@ -0,0 +1,1424 @@
+/**
+ *    DisplayIO.java
+ *    Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
+ *
+ *    This program is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 3 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.expeditee.gui;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Stack;
+
+import org.expeditee.core.Clip;
+import org.expeditee.core.Colour;
+import org.expeditee.core.Cursor;
+import org.expeditee.core.DamageAreas;
+import org.expeditee.core.Dimension;
+import org.expeditee.core.EnforcedClipStack.EnforcedClipKey;
+import org.expeditee.core.Image;
+import org.expeditee.core.InOutReference;
+import org.expeditee.core.Line;
+import org.expeditee.core.Point;
+import org.expeditee.core.Stroke;
+import org.expeditee.core.bounds.AxisAlignedBoxBounds;
+import org.expeditee.core.bounds.Bounds;
+import org.expeditee.gio.EcosystemManager;
+import org.expeditee.gio.GraphicsManager;
+import org.expeditee.gio.gesture.StandardGestureActions;
+import org.expeditee.items.Item;
+import org.expeditee.items.ItemParentStateChangedEvent;
+import org.expeditee.items.ItemUtils;
+import org.expeditee.items.Picture;
+import org.expeditee.items.Text;
+import org.expeditee.items.MagneticConstraint.MagneticConstraints;
+import org.expeditee.settings.UserSettings;
+import org.expeditee.stats.SessionStats;
+import org.expeditee.taskmanagement.EntitySaveManager;
+
+/**
+ * Controls the layout of the frames inside the display. 
+ * 
+ * @author jdm18
+ * @author cts16
+ */
+public final class DisplayController {
+	
+	/** Enumeration of the two sides of twin-frames mode. */
+	public static enum TwinFramesSide {
+		LEFT,
+		RIGHT
+	}
+
+	/** Convenience definition of TwinFramesSide.LEFT. */
+	public static final TwinFramesSide LEFT = TwinFramesSide.LEFT;
+	/** Convenience definition of TwinFramesSide.RIGHT. */
+	public static final TwinFramesSide RIGHT = TwinFramesSide.RIGHT;
+
+	/** The side-length of a small cursor (in pixels). */
+	public static final int SMALL_CURSOR_SIZE = 16;
+	/** The side-length of a medium cursor (in pixels). */
+	public static final int MEDIUM_CURSOR_SIZE = 32;
+	/** The side-length of a large cursor (in pixels). */
+	public static final int LARGE_CURSOR_SIZE = 64;
+
+	/** The height of the message bay at program start. */
+	public static final int INITIAL_MESSAGE_BAY_HEIGHT = 105;
+
+	/** The colour to be used to highlight the linked parent item, when the user navigates backwards. */
+	public static final Colour BACK_HIGHLIGHT_COLOR = Colour.MAGENTA;
+	
+	/** The stroke used to draw the separating lines between the display areas. */
+	protected static final Stroke SEPARATOR_STROKE = new Stroke(1);
+	/** The colour used to draw the separating lines between the display areas. */
+	protected static final Colour SEPARATOR_COLOUR = Colour.BLACK;
+    
+	/** The title to display in the Title bar. */
+	public static final String TITLE = "Expeditee";
+	
+	/** The image to use as the window icon. */
+	public static final String ICON_IMAGE = "org/expeditee/assets/icons/expediteeicon128.png";
+
+	/** The current frame being displayed on each side of the window. */
+	private static Frame[] _currentFrames = new Frame[2];
+	
+	/** The transitions to use on each side when changing frame. */
+	private static FrameTransition[] _transitions = new FrameTransition[2];
+
+	/** Maintains the list of frames visited thus-far for back-tracking. */
+	@SuppressWarnings("unchecked")
+	private static Stack<String>[] _visitedFrames = new Stack[2];
+
+	/** TODO: Comment. cts16 */
+	@SuppressWarnings("unchecked")
+	private static Stack<String>[] _backedUpFrames = new Stack[2];
+
+	/** Whether we are currently in twin-frames mode. */
+	private static boolean _twinFramesMode = false;
+	
+	/** Whether we are currently displaying in audience mode. */
+	private static boolean _audienceMode = false;
+	
+	/** Whether we are currently displaying in x-ray mode. */
+	private static boolean _xrayMode = false;
+
+	/** Notified whenever the frame changes. */
+	private static HashSet<DisplayObserver> _displayObservers = new HashSet<DisplayObserver>();
+	
+	/** What type of cursor we are using. */
+	private static Cursor.CursorType _cursorType = Item.DEFAULT_CURSOR;
+	
+	/** The size of the window which this class controls. */
+	private static Dimension _windowSize = null;
+	
+	/** The area in the window where the left frame should be painted in twin-frames mode. */
+	private static AxisAlignedBoxBounds _leftFramePaintArea = null;
+	/** The area in the window where the right frame should be painted in twin-frames mode. */
+	private static AxisAlignedBoxBounds _rightFramePaintArea = null;
+	/** The area in the window where the frame should be painted in single-frame mode. */
+	private static AxisAlignedBoxBounds _framePaintArea = null;
+	/** The area in the window where the message bay should be painted. */
+	private static AxisAlignedBoxBounds _messageBayPaintArea = null;
+	
+	/** The height of the message bay. */
+	private static int _messageBayHeight = INITIAL_MESSAGE_BAY_HEIGHT;
+	/** The percentage of the display width allocated to the left frame. */
+	private static float _twinFramesLeftWidthProportion = 0.5f;
+	
+	
+	/** The damage areas accumulated by item changes. */
+	private static DamageAreas _damagedAreas = new DamageAreas();
+
+	/** The buffered display image for preventing flickering during rendering. */
+	private static Image _refreshBuffer = null;
+	
+	/** Static-only class. */
+	private DisplayController()
+	{
+	}
+
+	/** Initialises the display controller. */
+	public static void Init()
+	{
+		_visitedFrames[0] = new Stack<String>();
+		_visitedFrames[1] = new Stack<String>();
+		_backedUpFrames[0] = new Stack<String>();
+		_backedUpFrames[1] = new Stack<String>();
+		
+		refreshCursor();
+		refreshWindowSize();
+	}
+	
+	/** Notifies observers that the frame has changed. */
+	private static void fireFrameChanged()
+	{
+		for (DisplayObserver observer : _displayObservers) observer.frameChanged();
+	}
+
+	/**
+	 * Adds a DisplayObserver to the display controller. DisplayObserver's are
+	 * notified when frame changes.
+	 * 
+	 * @see #removeDisplayObserver(DisplayObserver)
+	 * 
+	 * @param observer
+	 *            The observer to add
+	 * 
+	 * @throws NullPointerException
+	 *             If observer is null.
+	 */
+	public static void addDisplayObserver(DisplayObserver observer)
+	{
+		if (observer == null) throw new NullPointerException("observer");
+		
+		_displayObservers.add(observer);
+	}
+
+	/**
+	 * Removes a DisplayObserver from the display controller.
+	 * 
+	 * @see #addDisplayObserver(DisplayObserver)
+	 * 
+	 * @param observer
+	 *            The observer to add
+	 * 
+	 * @throws NullPointerException
+	 *             If observer is null.
+	 */
+	public static void removeDisplayObserver(DisplayObserver observer)
+	{
+		if (observer == null) throw new NullPointerException("observer");
+		
+		_displayObservers.remove(observer);
+	}
+
+	/**
+	 * TODO: Comment. cts16
+	 * TODO: Move. Doesn't belong here. cts16
+	 */
+	public static void setTextCursor(Text text, int cursorMovement)
+	{
+		setTextCursor(text, cursorMovement, false, false, false, false);
+	}
+
+	/**
+	 * TODO: Comment. cts16
+	 * TODO: Refactor. Too monolithic. cts16
+	 * TODO: Move. Doesn't belong here. cts16
+	 */
+	public static void setTextCursor(Text text, int cursorMovement,
+			boolean newSize, boolean isShiftDown, boolean isCtrlDown,
+			boolean allowClearSelection)
+	{
+
+		int size = Math.round(text.getSize());
+		
+		if (allowClearSelection && !isShiftDown && text.hasSelection()) text.clearSelection();
+
+		Point newMouse = text.moveCursor(cursorMovement, DisplayController.getFloatMouseX(), EcosystemManager.getInputManager().getCursorPosition().y, isShiftDown, isCtrlDown);
+						
+		if(		isCtrlDown ||
+				(DisplayController.getFloatMouseX() <= newMouse.x && newMouse.x <= DisplayController.getFloatMouseX() + 1) ||
+				(DisplayController.getFloatMouseX() > newMouse.x && cursorMovement == Text.RIGHT))
+		{
+			if(cursorMovement == Text.RIGHT && !MagneticConstraints.getInstance().rightBorderHit(text)) {
+				MagneticConstraints.getInstance().endOfLineHit(text);
+			} else {
+				if(cursorMovement == Text.LEFT && !MagneticConstraints.getInstance().leftBorderHit(text)) {
+					MagneticConstraints.getInstance().startOfLineHit(text);
+				}
+			}
+			newMouse.x = (int) DisplayController.getFloatMouseX();
+			newMouse.y = (int) DisplayController.getFloatMouseY();
+		} else if(cursorMovement == Text.UP && MagneticConstraints.getInstance().topBorderHit(text)) {
+			newMouse.x = (int) DisplayController.getFloatMouseX();
+			newMouse.y = (int) DisplayController.getFloatMouseY();
+		} else if(cursorMovement == Text.DOWN && MagneticConstraints.getInstance().bottomBorderHit(text)) {
+			newMouse.x = (int) DisplayController.getFloatMouseX();
+			newMouse.y = (int) DisplayController.getFloatMouseY();
+		}
+
+		if (!newSize && _cursorType == Item.TEXT_CURSOR) {
+			if (cursorMovement != 0)
+				DisplayController.setCursorPosition(newMouse, false);
+			return;
+		}
+
+		_cursorType = Item.TEXT_CURSOR;
+
+		// Do some stuff to adjust the cursor size based on the font size
+		final int MEDIUM_CURSOR_CUTOFF = 31;
+		final int LARGE_CURSOR_CUTOFF = 62;
+
+		int cursorSize = LARGE_CURSOR_SIZE;
+		int hotspotPos = 0;
+		int start = 0;
+
+		Dimension best_cursor_dim = EcosystemManager.getGraphicsManager().getBestCursorSize(new Dimension(cursorSize,cursorSize));
+		int best_cursor_height = best_cursor_dim.height;
+		
+		if (best_cursor_height < cursorSize) {
+			// not able to provide the size of cursor Expeditee wants to
+			// => lock on to 'best_cursor_height' and use this to generate dependent values
+			cursorSize = best_cursor_height; // OS + Java version dependent: most likely MEDIUM_CURSOR_SIZE
+			if (size < best_cursor_height) {
+				start = cursorSize - size - 1;
+				hotspotPos = cursorSize - (size + 1) / 4;
+			}
+			else {
+				start = size - best_cursor_height;
+				hotspotPos = cursorSize -1;
+			}
+			
+		}
+		else if (size < MEDIUM_CURSOR_CUTOFF) {
+			cursorSize = MEDIUM_CURSOR_SIZE;
+			start = cursorSize - size - 1;
+			hotspotPos = cursorSize - (size + 1) / 4;
+		} else if (size < LARGE_CURSOR_CUTOFF) {
+			hotspotPos = cursorSize - (size - 5) / 4;
+			start = cursorSize - size - 2;
+		} else {
+			int FIXED_CURSOR_MIN = 77;
+			if (size >= FIXED_CURSOR_MIN) {
+				hotspotPos = cursorSize - 2;
+			} else {
+				hotspotPos = size - (FIXED_CURSOR_MIN - cursorSize);
+			}
+		}
+		
+		int[] pixels = new int[cursorSize * cursorSize];
+
+		for (int i = start; i < cursorSize; i++) {
+			pixels[i * cursorSize] = pixels[i * cursorSize + 1] = 0xFF000000;
+		}
+
+		Image image = Image.createImage(cursorSize, cursorSize, pixels);
+		
+		EcosystemManager.getGraphicsManager().setCursor(new Cursor(image, new Point(0, hotspotPos), "textcursor"));
+		
+		if (cursorMovement != Text.NONE) {
+			DisplayController.setCursorPosition(newMouse, false);
+		}
+	}
+
+	/**
+	 * Sets the type of cursor the display should be using
+	 * 
+	 * @param type
+	 *            The type of cursor to display, using constants defined in the
+	 *            Cursor class.
+	 */
+	public static void setCursor(Cursor.CursorType type)
+	{
+		// Avoid flicker when not changing
+		if (type == _cursorType) return;
+
+		_cursorType = type;
+		
+		refreshCursor();
+	}
+
+	/** Gets the type of cursor the display is currently using. */
+	public static Cursor.CursorType getCursor()
+	{
+		return _cursorType;
+	}
+	
+	/** Updates the cursor with the graphics manager. */
+	private static void refreshCursor()
+	{
+		if (_cursorType == Item.HIDDEN_CURSOR || (FreeItems.hasCursor() && _cursorType == Item.DEFAULT_CURSOR)) {
+			Cursor invisibleCursor = Cursor.createInvisibleCursor();
+			EcosystemManager.getGraphicsManager().setCursor(invisibleCursor);
+		} else {
+			EcosystemManager.getGraphicsManager().setCursor(new Cursor(_cursorType));
+		}
+	}
+
+	/**
+	 * Moves the mouse cursor to the given x,y coordinates on the screen
+	 * 
+	 * @param x
+	 *            The x coordinate
+	 * @param y
+	 *            The y coordinate
+	 */
+	public static void setCursorPosition(float x, float y)
+	{
+		setCursorPosition(x, y, true);
+	}
+
+	/** TODO: Comment. cts16 */
+	public static void setCursorPosition(float x, float y, boolean forceArrow)
+	{
+		// Adjust the position to move the mouse to to account for being in
+		// TwinFramesMode
+		if (isTwinFramesOn()) {
+			if (getCurrentSide() == RIGHT) {
+				int middle = getTwinFramesSeparatorX();
+				x += middle;
+			}
+		}
+
+		Point mousePos = EcosystemManager.getInputManager().getCursorPosition();
+		float deltax = x - mousePos.x;
+		float deltay = y - mousePos.y;
+
+		if (FreeItems.hasItemsAttachedToCursor()) {
+			List<Item> toMove = FreeItems.getInstance();
+			for (Item move : toMove) {
+				move.setPosition(move.getX() + deltax, move.getY() + deltay);
+			}
+		}
+
+		// cheat
+		StandardGestureActions.setForceArrow(forceArrow);
+		EcosystemManager.getInputManager().setCursorPosition(new Point(x, y));
+	}
+
+	public static void resetCursorOffset()
+	{
+		StandardGestureActions.resetOffset();
+	}
+
+	/**
+	 * Sets the current cursor position in the current frame
+	 * 
+	 * @param pos
+	 */
+	public static void setCursorPosition(Point pos)
+	{
+		setCursorPosition(pos.x, pos.y);
+	}
+
+	public static void setCursorPosition(Point pos, boolean forceArrow)
+	{
+		setCursorPosition(pos.x, pos.y, forceArrow);
+	}
+
+	/**
+	 * Returns the top item (last added) of the Back-Stack (which is popped off)
+	 * 
+	 * @return The name of the last Frame added to the back-stack
+	 */
+	public static String getLastFrame()
+	{
+		TwinFramesSide side = getCurrentSide();
+		Stack<String> visitedFrames = getVisitedFrames(side);
+
+		if (visitedFrames.size() > 0) {
+			return visitedFrames.pop();
+		} else {
+			return null;
+		}
+	}
+
+	/**
+	 * Adds the given Frame to the back-stack
+	 * 
+	 * @param frame
+	 *            The Frame to add
+	 */
+	public static void addToBack(Frame toAdd)
+	{
+		TwinFramesSide side = getCurrentSide();
+		Stack<String> visitedFrames = getVisitedFrames(side);
+
+		visitedFrames.push(toAdd.getName());
+	}
+
+	public static String removeFromBack()
+	{
+		return getLastFrame();
+	}
+
+	/**
+	 * Returns a 'peek' at the end element on the back-stack of the current
+	 * side. If the back-stack is empty, null is returned.
+	 * 
+	 * @return The name of the most recent Frame added to the back-stack, or
+	 *         null if the back-stack is empty.
+	 */
+	public static String peekFromBackUpStack()
+	{
+		TwinFramesSide side = getCurrentSide();
+		Stack<String> visitedFrames = getVisitedFrames(side);
+
+		// check that the stack is not empty
+		if (visitedFrames.size() > 0) return visitedFrames.peek();
+
+		// if the stack is empty, return null
+		return null;
+	}
+	
+	/** Sets the transition to use when leaving the given frame. */
+	public static void setTransition(Frame frame, FrameTransition transition)
+	{
+		if (frame == null) return;
+		TwinFramesSide side = getSideFrameIsOn(frame);
+		setTransition(side, transition);
+	}
+	
+	/** Sets the transition to use when changing frame on the given side. */
+	private static void setTransition(TwinFramesSide side, FrameTransition transition)
+	{
+		if (side == null) return;
+		
+		_transitions[side.ordinal()] = transition;
+	}
+	
+	/** Gets the transition to use when changing frame on the given side. */
+	private static FrameTransition getTransition(TwinFramesSide side)
+	{
+		if (side == null) return null;
+		
+		return _transitions[side.ordinal()];
+	}
+
+	/**
+	 * TODO: Comment. cts16
+	 * TODO: Refactor. Too monolithic. cts16
+	 */
+	public static void setCurrentFrame(Frame frame, boolean incrementStats)
+	{
+		if (frame == null) return;
+
+		// If one of the sides doesn't have a frame yet, give it this one
+		if (isTwinFramesOn()) {
+			for (TwinFramesSide side : TwinFramesSide.values()) {
+				if (!sideHasFrame(side)) {
+					setFrameOnSide(frame, side);
+					fireFrameChanged();
+					return;
+				}
+			}
+		}
+
+		// if this is already the current frame
+		if (frame == getCurrentFrame()) {
+			requestRefresh(false);
+			MessageBay.displayMessage(frame.getName() + " is already the current frame.");
+			return;
+		}
+		
+		// Update stats
+		if (incrementStats) SessionStats.AccessedFrame();
+
+		// Invalidate free items
+		if (!FreeItems.getInstance().isEmpty() && getCurrentFrame() != null) {
+
+			// Empty free items temporarily so that the old frames buffer is repainted without the free items.
+			ArrayList<Item> tmp = FreeItems.getInstance().clone();
+			FreeItems.getInstance().clear(); // NOTE: This will invalidate all the cleared free items
+			requestRefresh(true);
+			FreeItems.getInstance().addAll(tmp);
+
+		}
+
+		// Changing frames is a Save point for saveable entities:
+		EntitySaveManager.getInstance().saveAll();
+
+		if (_twinFramesMode) {
+			// if the same frame is being shown in both sides, load a fresh
+			// copy from disk
+			if (getOppositeFrame() == frame || getOppositeFrame().hasOverlay(frame)) {
+				FrameIO.SuspendCache();
+				frame = FrameIO.LoadFrame(frame.getName());
+				FrameIO.ResumeCache();
+			}
+
+			// If the frames are the same then the items for the
+			// frame that is just about to hide will still be in view
+			// so only notify items that they are hidden if the
+			// frames differ.
+			if (getCurrentFrame() != null && !bothSidesHaveSameFrame()) {
+				for (Item i : getCurrentFrame().getItems()) {
+					i.onParentStateChanged(new ItemParentStateChangedEvent(getCurrentFrame(), ItemParentStateChangedEvent.EVENT_TYPE_HIDDEN));
+				}
+			}
+			setFrameOnSide(frame, getCurrentSide());
+
+			// BROOK : TODO... overlays and loadable widgets
+			for (Item i : getCurrentFrame().getItems()) {
+				i.onParentStateChanged(new ItemParentStateChangedEvent(getCurrentFrame(), ItemParentStateChangedEvent.EVENT_TYPE_SHOWN));
+			}
+		} else {
+
+			// Notifying items on the frame being hidden that they
+			// are about to be hidden.
+			// ie. Widgets use this method to remove themselves from the JPanel
+			List<Frame> currentOnlyOverlays = new LinkedList<Frame>();
+			List<Frame> nextOnlyOverlays = new LinkedList<Frame>();
+			List<Frame> sharedOverlays = new LinkedList<Frame>();
+
+			// Get all overlayed frames seen by the next frame
+			for (Overlay o : frame.getOverlays()) {
+				if (!nextOnlyOverlays.contains(o.Frame))
+					nextOnlyOverlays.add(o.Frame);
+			}
+
+			// Get all overlayed frames seen by the current frame
+			if (getCurrentFrame() != null) {
+				for (Overlay o : getCurrentFrame().getOverlays()) {
+					if (!currentOnlyOverlays.contains(o.Frame))
+						currentOnlyOverlays.add(o.Frame);
+				}
+			}
+
+			// Extract shared overlays between the current and next frame
+			for (Frame of : currentOnlyOverlays) {
+				if (nextOnlyOverlays.contains(of)) {
+					sharedOverlays.add(of);
+				}
+			}
+
+			// The first set, currentOnlyOverlays, must be notified that they
+			// are hidden
+			Collection<Item> items = new LinkedList<Item>();
+
+			// Notify items that will not be in view any more
+			if (getCurrentFrame() != null) {
+				List<Frame> seen = new LinkedList<Frame>();
+				seen.addAll(sharedOverlays); // Signify that seen all shared
+				// overlays
+				seen.remove(getCurrentFrame()); // must ensure
+				// excluded
+
+				// Get all items seen from the current frame - including all
+				// possible non-shared overlays
+				items = getCurrentFrame().getAllItems();
+				for (Frame f : seen)
+					items.removeAll(f.getAllItems());
+
+				// Notify items that they are hidden
+				for (Item i : items) {
+					i.onParentStateChanged(new ItemParentStateChangedEvent(getCurrentFrame(), ItemParentStateChangedEvent.EVENT_TYPE_HIDDEN));
+				}
+			}
+
+			// Set the new frame
+			setFrameOnSide(frame, getCurrentSide());
+			frame.refreshSize();
+			
+			// Notify items on the frame being displayed that they are in view
+			// ie. widgets use this method to add themselves to the content pane
+			items.clear();
+
+			// Notify overlay items that they are shown
+			for (Item i : frame.getOverlayItems()) {
+				Overlay owner = frame.getOverlayOwner(i);
+				// if (owner == null) i.onParentFameShown(false, 0);
+				// else ...
+				assert (owner != null);
+				i
+						.onParentStateChanged(new ItemParentStateChangedEvent(
+								frame,
+								ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY,
+								owner.permission));
+			}
+
+			for (Item i : frame.getItems()) {
+				i.onParentStateChanged(new ItemParentStateChangedEvent(frame,
+						ItemParentStateChangedEvent.EVENT_TYPE_SHOWN));
+			}
+		}
+		
+		frame.reset();
+		
+		// fix text items
+		ItemUtils.Justify(frame);
+		
+		StandardGestureActions.refreshHighlights();
+		requestRefresh(false);
+		fireFrameChanged();
+	}
+
+	/** Updates the window title bar to show which mode Expeditee is in. */
+	public static void updateTitle()
+	{
+		StringBuffer title = new StringBuffer(TITLE);
+
+		if (isAudienceMode()) {
+			title.append(" - Audience Mode");
+		} else if (isXRayMode()) {
+			title.append(" - X-Ray Mode");
+		} else {
+			title.append(" [").append(SessionStats.getShortStats()).append(']');
+		}
+		
+		EcosystemManager.getGraphicsManager().setWindowTitle(title.toString());
+	}
+	
+	/** Whether the given side has a frame. */
+	public static boolean sideHasFrame(TwinFramesSide side)
+	{
+		return getFrameOnSide(side) != null;
+	}
+
+	/** Gets the side of the twin-frames display that the mouse is over. */
+	public static TwinFramesSide getCurrentSide()
+	{
+		// If the mouse is over the right side of the window and there's a valid frame,
+		// we are on the right side.
+		int mouseX = EcosystemManager.getInputManager().getCursorPosition().x;
+		if (isTwinFramesOn() && mouseX >= getTwinFramesSeparatorX() && sideHasFrame(RIGHT)) {
+			return RIGHT;
+		}
+		
+		// If there's only a right frame, that's the current side
+		if (!sideHasFrame(LEFT) && sideHasFrame(RIGHT)) return RIGHT;
+
+		// In any other case the left side is the current side
+		return LEFT;
+	}
+
+	/** Gets the opposite side to the current side of the twin-frames. */
+	private static TwinFramesSide getOppositeSide()
+	{
+		if (getCurrentSide() == LEFT) return RIGHT;
+
+		return LEFT;
+	}
+
+	/** Returns the side that the given frame is on, or null if it's not on either side. */
+	public static TwinFramesSide getSideFrameIsOn(Frame frame)
+	{
+		// Loop through both sides
+		for (TwinFramesSide side : TwinFramesSide.values()) {
+			if (getFrameOnSide(side) == frame) return side;
+		}
+
+		return null;
+	}
+
+	/** Gets the frame that is on the given side of the display. */
+	public static Frame getFrameOnSide(TwinFramesSide side)
+	{
+		if (side == null) return null;
+		
+		return _currentFrames[side.ordinal()];
+	}
+	
+	/** Returns the frame on the current side of the display. */
+	public static Frame getCurrentFrame()
+	{
+		return getFrameOnSide(getCurrentSide());
+	}
+
+	/** Returns the frame on the opposite side of the display. */
+	public static Frame getOppositeFrame()
+	{
+		return getFrameOnSide(getOppositeSide());
+	}
+
+	/** Gets the two frames being displayed. */
+	public static Frame[] getFrames()
+	{
+		return _currentFrames;
+	}
+
+	/** Gets the x-coordinate of the division between the left and right sides. */
+	public static int getTwinFramesSeparatorX()
+	{
+		return getLeftFramePaintArea().getWidth() + (int) (SEPARATOR_STROKE.thickness / 2);
+	}
+	
+	/** Gets the line that separates the two sides of the twin-frames display. */
+	public static Line getTwinFramesSeparatorLine()
+	{
+		if (!isTwinFramesOn()) return null;
+		
+		int x = getTwinFramesSeparatorX();
+		int bottom = getFramePaintArea().getMaxY();
+		
+		return new Line(x, 0, x, bottom);
+		
+	}
+
+	/** Gets the line that separates the message bay from the frame area. */
+	public static Line getMessageBaySeparatorLine()
+	{
+		// No message bay in audience mode
+		if (isAudienceMode()) return null;
+		
+		int separatorThickness = (int) SEPARATOR_STROKE.thickness;
+		int y = getFramePaintArea().getMaxY() + separatorThickness / 2 + separatorThickness % 2;
+		int right = getMessageBayPaintArea().getMaxX();
+		
+		return new Line(0, y, right, y);
+	}
+
+	/**
+	 * Returns the current mouse X coordinate. This coordinate is relative to
+	 * the left edge of the frame the mouse is in. It takes into account the
+	 * user being in twin frames mode.
+	 * 
+	 * @return The X coordinate of the mouse.
+	 */
+	public static float getFloatMouseX()
+	{
+		return (float) getMouseX();
+	}
+
+
+	/**
+	 * Returns the current mouse X coordinate. This coordinate is relative to
+	 * the left edge of the frame the mouse is in. It takes into account the
+	 * user being in twin frames mode.
+	 * 
+	 * @return The X coordinate of the mouse.
+	 */
+	public static int getMouseX()
+	{
+		return getMousePosition().x;
+	}
+
+	/**
+	 * Returns the current mouse position. This coordinate is relative to
+	 * the upper-left edge of the frame the mouse is in. It takes into account the
+	 * user being in twin frames mode.
+	 * 
+	 * @return The position of the mouse.
+	 */
+	public static Point getMousePosition()
+	{
+		Point mousePos = EcosystemManager.getInputManager().getCursorPosition();
+		
+		if (isTwinFramesOn() && getRightFramePaintArea().contains(mousePos)) {
+			mousePos.x -= getRightFramePaintArea().getMinX();
+		}
+
+		return mousePos;
+	}
+	
+	/**
+	 * Returns the current mouse Y coordinate. This coordinate is relative to
+	 * the top edge of the frame the mouse is in. 
+	 * 
+	 * @return The Y coordinate of the mouse.
+	 */
+	public static float getFloatMouseY()
+	{
+		return (float) getMouseY();
+	}
+	
+	/**
+	 * Returns the current mouse Y coordinate. This coordinate is relative to
+	 * the top edge of the frame the mouse is in. 
+	 * 
+	 * @return The Y coordinate of the mouse.
+	 */
+	public static int getMouseY()
+	{
+		return getMousePosition().y;
+	}
+	
+	/**
+	 * TODO: Comment. cts16
+	 * @return
+	 */
+	public static boolean Back()
+	{
+		TwinFramesSide side = getCurrentSide();
+		Stack<String> visitedFrames = getVisitedFrames(side);
+
+		// there must be a frame to go back to
+		if (visitedFrames.size() < 1) {
+			MessageBay.displayMessageOnce("You are already on the home frame");
+			return false;
+		}
+
+		if (!FrameUtils.LeavingFrame(getCurrentFrame())) {
+			MessageBay.displayMessage("Error navigating back");
+			return false;
+		}
+
+		String oldFrame = getCurrentFrame().getName().toLowerCase();
+
+		// do not get a cached version (in case it is in the other window)
+		if (isTwinFramesOn()) FrameIO.SuspendCache();
+		
+		Frame frame = FrameIO.LoadFrame(removeFromBack());
+		// If the top frame on the backup stack is the current frame go back
+		// again... or if it has been deleted
+		// Recursively backup the stack
+		if (frame == null || frame.equals(getCurrentFrame())) {
+			Back();
+			return false;
+		}
+
+		if (isTwinFramesOn()) {
+			FrameIO.ResumeCache();
+		}
+		getBackedUpFrames(side).push(oldFrame);
+		FrameUtils.DisplayFrame(frame, false, true);
+		StandardGestureActions.setHighlightHold(true);
+
+		for (Item i : frame.getItems()) {
+			if (i.getLink() != null && i.getAbsoluteLink().toLowerCase().equals(oldFrame)) {
+				if (i.getHighlightMode() != Item.HighlightMode.Normal) {
+					i.setHighlightModeAndColour(Item.HighlightMode.Normal,
+							BACK_HIGHLIGHT_COLOR);
+				}
+				// check if its an @f item and if so update the buffer
+				if (i instanceof Picture) {
+					Picture p = (Picture) i;
+					p.refresh();
+				}
+			}
+		}
+		requestRefresh(true);
+		return true;
+	}
+
+	/**
+	 * TODO: Comment. cts16
+	 * @return
+	 */
+	public static boolean Forward()
+	{
+		TwinFramesSide side = getCurrentSide();
+
+		// there must be a frame to go back to
+		if (getBackedUpFrames(side).size() == 0) {
+			return false;
+		}
+
+		if (!FrameUtils.LeavingFrame(getCurrentFrame())) {
+			MessageBay.displayMessage("Error navigating forward");
+			return false;
+		}
+
+		String oldFrame = getCurrentFrame().getName().toLowerCase();
+
+		// do not get a cached version (in case it is in the other window)
+		if (isTwinFramesOn())
+			FrameIO.SuspendCache();
+		Frame frame = FrameIO.LoadFrame(getBackedUpFrames(side).pop());
+		// If the top frame on the backup stack is the current frame go back
+		// again... or if it has been deleted
+		// Recursively backup the stack
+		if (frame == null || frame.equals(getCurrentFrame())) {
+			Forward();
+			return false;
+		}
+
+		if (isTwinFramesOn()) {
+			FrameIO.ResumeCache();
+		}
+		getVisitedFrames(side).push(oldFrame);
+		FrameUtils.DisplayFrame(frame, false, true);
+		requestRefresh(true);
+		return true;
+	}
+
+	/** Toggles the display of frames between TwinFrames mode and Single frame mode. */
+	public static void toggleTwinFrames()
+	{
+		// determine which side is the active side
+		TwinFramesSide opposite = getOppositeSide();
+		_twinFramesMode = !_twinFramesMode;
+
+		// if TwinFrames is being turned on
+		if (_twinFramesMode) {
+			// if this is the first time TwinFrames has been toggled on,
+			// load the user's first frame
+			if (getVisitedFrames(opposite).size() == 0) {
+				FrameIO.SuspendCache();
+				setCurrentFrame(FrameIO.LoadFrame(UserSettings.HomeFrame.get()), true);
+				FrameIO.ResumeCache();
+			} else {
+				// otherwise, restore the frame from the side's back-stack
+				setCurrentFrame(FrameIO.LoadFrame(getVisitedFrames(opposite).pop()), true);
+			}
+
+			// else, TwinFrames is being turned off
+		} else {
+			// add the frame to the back-stack
+			Frame hiding = getOppositeFrame();
+			FrameUtils.LeavingFrame(hiding);
+			getVisitedFrames(opposite).add(hiding.getName());
+			setFrameOnSide(null, opposite);
+			getCurrentFrame().refreshSize();
+		}
+		
+		// Update the sizes of the displayed frames
+		if (getCurrentFrame() != null) getCurrentFrame().refreshSize();
+		if (getOppositeFrame() != null) getOppositeFrame().refreshSize();
+
+		requestRefresh(false);
+	}
+
+	/** Whether the display is currently in twin-frames mode. */
+	public static boolean isTwinFramesOn()
+	{
+		return _twinFramesMode;
+	}
+
+	/** TODO: Comment. cts16 */
+	public static void Reload(TwinFramesSide side)
+	{
+		if (side == null) return;
+
+		FrameIO.SuspendCache();
+		Frame frame = FrameIO.LoadFrame(getFrameOnSide(side).getName());
+		setFrameOnSide(frame, side);
+		FrameIO.ResumeCache();
+	}
+	
+	/**
+	 * Moves the cursor the end of this item.
+	 * 
+	 * @param i
+	 */
+	public static void MoveCursorToEndOfItem(Item i)
+	{
+		setTextCursor((Text) i, Text.END, true, false, false, false);
+	}
+	
+	public static void clearBackedUpFrames()
+	{
+		getBackedUpFrames(getCurrentSide()).clear();
+	}
+
+	/**
+	 * @param secondsDelay
+	 * @param s
+	 * @throws InterruptedException
+	 */
+	public static void typeStringDirect(double secondsDelay, String s) throws InterruptedException
+	{
+		for (int i = 0; i < s.length(); i++) {
+			StandardGestureActions.processChar(s.charAt(i), false);
+			Thread.sleep((int) (secondsDelay * 1000));
+		}
+	}
+
+	public static List<String> getUnmodifiableVisitedList()
+	{
+		return Collections.unmodifiableList(getVisitedFrames(getCurrentSide()));
+	}
+	
+	/** If both sides have the same frame (returns false if both sides have no frame). */
+	public static boolean bothSidesHaveSameFrame()
+	{
+		return (getCurrentFrame() != null && getCurrentFrame() == getOppositeFrame());
+	}
+	
+	/** Sets the given side to the given frame. */
+	private static void setFrameOnSide(Frame frame, TwinFramesSide side)
+	{
+		if (side == null) return;
+		
+		_currentFrames[side.ordinal()] = frame;
+	}
+	
+	/** Gets the stack of visited frames for the given side. */
+	private static Stack<String> getVisitedFrames(TwinFramesSide side)
+	{
+		if (side == null) return null;
+		
+		return _visitedFrames[side.ordinal()];
+	}
+
+	/** Gets the stack of backed-up frames for the given side. */
+	private static Stack<String> getBackedUpFrames(TwinFramesSide side)
+	{
+		if (side == null) return null;
+		
+		return _backedUpFrames[side.ordinal()];
+	}
+
+	/**
+	 * Rotates through normal -> audience -> audience + fullscreen modes and back again.
+	 */
+	public static void rotateAudienceModes()
+	{
+		Frame current = DisplayController.getCurrentFrame();
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+		if (_audienceMode && g.isFullscreen()) {
+			ToggleAudienceMode();
+			g.exitFullscreen();
+		} else if (_audienceMode) {
+			if (g.canGoFullscreen()) {
+				g.goFullscreen();
+			} else {
+				ToggleAudienceMode();
+			}
+		} else {
+			ToggleAudienceMode();
+			ItemUtils.UpdateConnectedToAnnotations(current.getItems());
+			for (Overlay o : current.getOverlays()) {
+				ItemUtils.UpdateConnectedToAnnotations(o.Frame.getItems());
+			}
+			for (Vector v : current.getVectorsDeep()) {
+				ItemUtils.UpdateConnectedToAnnotations(v.Frame.getItems());
+			}
+		}
+	}
+	
+	/**
+	 * If Audience Mode is on this method will toggle it to be off, or
+	 * vice-versa. This results in the Frame being re-parsed and repainted.
+	 */
+	public static void ToggleAudienceMode()
+	{
+		Frame current = DisplayController.getCurrentFrame();
+		
+		// Turn off x-ray mode if it's on
+		if (_xrayMode) ToggleXRayMode();
+	
+		// Toggle audience mode
+		_audienceMode = !_audienceMode;
+
+		refreshPaintAreas();
+		FrameUtils.Parse(current);
+		updateTitle();
+		requestRefresh(false);
+	}
+
+	/**
+	 * If X-Ray Mode is on this method will toggle it to be off, or vice-versa.
+	 * This results in the Frame being re-parsed and repainted.
+	 */
+	public static void ToggleXRayMode()
+	{
+		// Turn off x-ray mode if it is on
+		if (_audienceMode) ToggleAudienceMode();
+
+		_xrayMode = !_xrayMode;
+		
+		getCurrentFrame().parse();
+		getCurrentFrame().refreshSize();
+		updateTitle();
+		StandardGestureActions.refreshHighlights();
+		StandardGestureActions.updateCursor();
+		requestRefresh(false);
+	}
+	
+	/** Whether audience mode is currently on. */
+	public static boolean isAudienceMode()
+	{
+		return _audienceMode;
+	}
+
+	/** Whether x-ray mode is currently on. */
+	public static boolean isXRayMode()
+	{
+		return _xrayMode;
+	}
+	
+	/** Tells the display controller to get the current window size. */
+	public static void refreshWindowSize()
+	{
+		_windowSize = EcosystemManager.getGraphicsManager().getWindowSize();
+		_refreshBuffer = Image.createImage(_windowSize, true);
+		refreshPaintAreas();
+	}
+	
+	/** Recalculates the paint areas for the frames and message bay. */
+	public static void refreshPaintAreas()
+	{
+		// Calculate the width of each frame in twin-frames mode
+		int availableWindowWidth = _windowSize.width - (int) SEPARATOR_STROKE.thickness;
+		int leftFrameWidth = (int) (availableWindowWidth * _twinFramesLeftWidthProportion);
+		int rightFrameWidth = availableWindowWidth - leftFrameWidth;
+		
+		// The height of each frame is the window height, minus the message bay if visible
+		int frameHeight = _windowSize.height;
+		if (!isAudienceMode()) {
+			frameHeight -= _messageBayHeight + (int) SEPARATOR_STROKE.thickness;
+		}
+		
+		int rightFrameX = _windowSize.width - rightFrameWidth;
+		int messageBayY = _windowSize.height - _messageBayHeight;
+		
+		_leftFramePaintArea = new AxisAlignedBoxBounds(0, 0, leftFrameWidth, frameHeight);
+		_rightFramePaintArea = new AxisAlignedBoxBounds(rightFrameX, 0, rightFrameWidth, frameHeight);
+		_framePaintArea = new AxisAlignedBoxBounds(0, 0, _windowSize.width, frameHeight);
+		_messageBayPaintArea = new AxisAlignedBoxBounds(0, messageBayY, _windowSize.width, _messageBayHeight);
+	}
+	
+	public static AxisAlignedBoxBounds getLeftFramePaintArea()
+	{
+		return _leftFramePaintArea;
+	}
+	
+	public static AxisAlignedBoxBounds getRightFramePaintArea()
+	{
+		return _rightFramePaintArea;
+	}
+	
+	public static AxisAlignedBoxBounds getFramePaintArea()
+	{
+		return _framePaintArea;
+	}
+	
+	public static AxisAlignedBoxBounds getMessageBayPaintArea()
+	{
+		return _messageBayPaintArea;
+	}
+
+	/**
+	 * Checks that the item is visible (on current frame && overlays) - if
+	 * visible then damaged area will be re-rendered on the next refresh.
+	 * 
+	 * @param damagedItem
+	 * @param toRepaint
+	 */
+	public static void invalidateItem(Item damagedItem, Bounds toRepaint)
+	{
+		if (toRepaint == null) return;
+		
+		// Only add area to repaint if item is visible...
+		if (ItemUtils.isVisible(damagedItem)) {
+			invalidateArea(AxisAlignedBoxBounds.getEnclosing(toRepaint));
+		} else if (MessageBay.isMessageItem(damagedItem)) {
+			invalidateArea(AxisAlignedBoxBounds.getEnclosing(toRepaint).translate(0, getMessageBayPaintArea().getMinY()));
+		}
+	}
+
+	/**
+	 * The given area will be re-rendered in the next refresh. This is the
+	 * quicker version and is more useful for re-rendering animated areas.
+	 */
+	public static void invalidateArea(AxisAlignedBoxBounds toRepaint)
+	{
+		_damagedAreas.addArea(toRepaint);
+	}
+
+	public static void clearInvalidAreas()
+	{
+		_damagedAreas.clear();
+	}
+	
+	/*
+	 * 
+	 * Thread-safe rendering.
+	 * 
+	 */
+
+	/**
+	 * Redraws the entire window. Shouldn't be called directly, instead use
+	 * requestRefresh(boolean) to ensure no infinite refresh call loops are created.
+	 */
+	private static void refresh(boolean useInvalidation)
+	{
+		// Always get the clip as it clears at the same time
+		Clip clip = _damagedAreas.getClip();
+		
+		// No damaged areas
+		if (useInvalidation && clip.isFullyClipped()) return;
+		
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+		g.pushDrawingSurface(_refreshBuffer);
+		
+		if (isTwinFramesOn()) {
+			Clip leftClip = null;
+			Clip rightClip = null;
+			
+			if (useInvalidation) {
+				leftClip = clip.clone().intersectWith(getLeftFramePaintArea());
+				rightClip = clip.clone().intersectWith(getRightFramePaintArea());
+				if (!rightClip.isFullyClipped()) rightClip = new Clip(rightClip.getBounds().translate(-getRightFramePaintArea().getMinX(), 0));
+			}
+			
+			Image left = null;
+			if (!useInvalidation || !leftClip.isFullyClipped()) {
+				left = FrameGraphics.getFrameImage(getFrameOnSide(LEFT), leftClip, getLeftFramePaintArea().getSize());
+			}
+			
+			Image right = null;
+			if (!useInvalidation || !rightClip.isFullyClipped()) {
+				right = FrameGraphics.getFrameImage(getFrameOnSide(RIGHT), rightClip, getRightFramePaintArea().getSize());
+			}
+
+			paintTwinFrames(left, right);
+		} else {
+			Clip frameClip = null;
+			
+			if (useInvalidation) {
+				frameClip = clip.clone().intersectWith(getFramePaintArea());
+			}
+			
+			Image image = null;
+			if (!useInvalidation || !frameClip.isFullyClipped()) {
+				image = FrameGraphics.getFrameImage(getCurrentFrame(), frameClip, getFramePaintArea().getSize());
+			}
+
+			paintSingleFrame(image);
+		}
+
+		// Paint message bay
+		if (!isAudienceMode()) {
+			Clip messageBayClip = null;
+			
+			if (useInvalidation) {
+				messageBayClip = clip.clone().intersectWith(getMessageBayPaintArea());
+				if (!messageBayClip.isFullyClipped()) messageBayClip = new Clip(messageBayClip.getBounds().translate(0, -getMessageBayPaintArea().getMinY()));
+			}
+			
+			Image image = null;
+			if (!useInvalidation || !messageBayClip.isFullyClipped()) {
+				image = MessageBay.getImage(messageBayClip, getMessageBayPaintArea().getSize());
+			}
+			
+			if (image != null) {
+				g.drawImage(image, getMessageBayPaintArea().getTopLeft(), getMessageBayPaintArea().getSize());
+			}
+		}
+		
+		// Draw any separator lines
+		g.drawLine(getMessageBaySeparatorLine(), SEPARATOR_COLOUR, SEPARATOR_STROKE);
+		g.drawLine(getTwinFramesSeparatorLine(), SEPARATOR_COLOUR, SEPARATOR_STROKE);
+		
+		// Paint any popups
+		if (PopupManager.getInstance() != null) PopupManager.getInstance().paint();
+		
+		g.popDrawingSurface();
+		g.drawImage(_refreshBuffer, Point.ORIGIN);
+	}
+	
+	/** Draws the two frame images to the display and puts the separator line between them. */
+	private static void paintTwinFrames(Image leftFrameImage, Image rightFrameImage)
+	{
+		if (leftFrameImage == null && rightFrameImage == null) return;
+		
+		InOutReference<FrameTransition> leftTransition = new InOutReference<FrameTransition>(getTransition(LEFT));
+		InOutReference<FrameTransition> rightTransition = new InOutReference<FrameTransition>(getTransition(RIGHT));
+		
+		paintFrameIntoArea(leftFrameImage, getLeftFramePaintArea(), leftTransition);
+		paintFrameIntoArea(rightFrameImage, getRightFramePaintArea(), rightTransition);
+		
+		setTransition(LEFT, leftTransition.get());
+		setTransition(RIGHT, rightTransition.get());
+	}
+	
+	/** Draws the single frame image to the screen. */
+	private static void paintSingleFrame(Image frameImage)
+	{
+		if (frameImage == null) return;
+
+		InOutReference<FrameTransition> transition = new InOutReference<FrameTransition>(getTransition(getCurrentSide()));
+		
+		paintFrameIntoArea(frameImage, getFramePaintArea(), transition);
+		
+		setTransition(getCurrentSide(), transition.get());
+	}
+	
+	/** Draws the given frame image into the given area, using a transition if one is provided. */
+	private static void paintFrameIntoArea(Image frameImage, AxisAlignedBoxBounds area, InOutReference<FrameTransition> transition)
+	{
+		if (frameImage == null || area == null) return;
+		
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+		EnforcedClipKey key = g.pushClip(new Clip(area));
+		
+		FrameTransition t = null;
+		if (transition != null) t = transition.get();
+		
+		// Attempt to draw the transition if there is one
+		if (t != null) {
+			if (!t.drawTransition(frameImage, area)) {
+				// If drawing failed, throw the transition away
+				t = null;
+			} else {
+				// Schedule the next frame to be drawn
+				invalidateArea(area);
+				requestRefresh(true);
+			}
+		}
+		
+		// If t == null at this stage, no transition has been drawn, so just draw the image
+		if (t == null) {
+			g.drawImage(frameImage, area.getTopLeft(), area.getSize());
+		}
+		
+		// Discard the transition if drawing failed or it is finished
+		if (t == null || t.isCompleted()) transition.set(null);
+		
+		g.popClip(key);
+	}
+
+	/** Runnable which ensures overlapping refresh requests are joined. */
+	private static RenderRequestMarsheller _requestMarsheller = new RenderRequestMarsheller();
+
+	/**
+	 * If wanting to refresh from another thread - other than the main thread
+	 * that handles the expeditee datamodel (modifying / accessing / rendering).
+	 * Use this method for thread safety.
+	 */
+	public static synchronized void requestRefresh(boolean useInvalidation)
+	{
+		try {
+			_requestMarsheller.enqueue(useInvalidation);
+		} catch (Throwable e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Used for marshelling render requests from foreign threads to the event
+	 * dispatcher thread... (AWT)
+	 * 
+	 * @author Brook Novak
+	 */
+	private static class RenderRequestMarsheller implements Runnable {
+
+		private boolean _useInvalidation = true;
+		private boolean _enqueued = false;
+		private Boolean _requeueWithInvalidation = null;
+		private Object _lock = new Object();
+		
+		/** Enqueues a redraw on the GIO thread, or remembers to do so once the current redraw finishes. */
+		public void enqueue(boolean useInvalidation)
+		{
+			synchronized (_lock) {
+				if (!_enqueued) {
+					_enqueued = true;
+					_useInvalidation = useInvalidation;
+					EcosystemManager.getMiscManager().runOnGIOThread(this);
+				} else if (_requeueWithInvalidation == null || _requeueWithInvalidation == true) {
+					_requeueWithInvalidation = useInvalidation;
+				}
+			}
+		}
+
+		public void run()
+		{
+			try {
+				refresh(_useInvalidation);
+			} catch (Throwable e) {
+				e.printStackTrace();
+			}
+
+			// Do another redraw if we received a new request while doing this one.
+			synchronized (_lock) {
+				if (_requeueWithInvalidation != null) {
+					_useInvalidation = _requeueWithInvalidation.booleanValue();
+					_requeueWithInvalidation = null;
+					EcosystemManager.getMiscManager().runOnGIOThread(this);
+				} else {
+					_enqueued = false;
+				}
+			}
+		}
+	}
+}
Index: trunk/src/org/expeditee/gui/DisplayObserver.java
===================================================================
--- trunk/src/org/expeditee/gui/DisplayObserver.java	(revision 1098)
+++ trunk/src/org/expeditee/gui/DisplayObserver.java	(revision 1098)
@@ -0,0 +1,33 @@
+/**
+ *    DisplayIOObserver.java
+ *    Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
+ *
+ *    This program is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 3 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.expeditee.gui;
+
+/**
+ * An {@link DisplayObserver} can observe the {@link DisplayController} for detecting when
+ * frame changes occur.
+ * 
+ * @author Brook Novak
+ */
+public interface DisplayObserver {
+	
+	/**
+	 * Raised whenever a frame change occurs.
+	 */
+	public void frameChanged();
+}
Index: trunk/src/org/expeditee/gui/FrameTransition.java
===================================================================
--- trunk/src/org/expeditee/gui/FrameTransition.java	(revision 1098)
+++ trunk/src/org/expeditee/gui/FrameTransition.java	(revision 1098)
@@ -0,0 +1,321 @@
+package org.expeditee.gui;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.expeditee.core.Colour;
+import org.expeditee.core.Dimension;
+import org.expeditee.core.Fill;
+import org.expeditee.core.GradientFill;
+import org.expeditee.core.Image;
+import org.expeditee.core.Point;
+import org.expeditee.core.bounds.AxisAlignedBoxBounds;
+import org.expeditee.gio.EcosystemManager;
+import org.expeditee.gio.GraphicsManager;
+import org.expeditee.items.Item;
+
+/**
+ * Manages slide animations between frames
+ * Reflection is used to call these methods, therefore any additions should only need to be added in this class.
+ * No further changes to other code should be required.
+ * 
+ * TODO: Rework above comment. cts16
+ * 
+ * @author cts16
+ */
+public class FrameTransition
+{
+	/** The parameters for transition methods. */
+	private static final Class<?>[] REFLECTION_PARAMS = { Image.class, AxisAlignedBoxBounds.class };
+	
+	/** The height of the drop-shadow below transition frames. */
+	private static final int SHADOW_HEIGHT = 16;
+	
+	/** The colour to use for shadows. */
+	private static final Colour SHADOW_COLOUR = Colour.FromRGBA255(0, 0, 0, 64);
+	
+	/** The default duration for transitions (in milliseconds). */
+	public static final long DEFAULT_TRANSITION_DURATION = 500;
+	
+	/** Stores the image of the frame being transitioned away from. */
+	private Image _fromFrameImage = null;
+	
+	/** Which transition method we are currently using. */
+	private Method _method;
+	
+	/** How long the current transition is (in milliseconds). */
+	private Long _duration = null;
+
+	/** How far through the transition we are (in milliseconds). */
+	private long _completed = 0;
+	
+	/** When we last updated the transition (as returned by System.currentTimeMillis()). */
+	private long _lastUpdateTime = 0;
+	
+	/** Standard constructor. */
+	public FrameTransition(Image fromFrameImage, String method)
+	{
+		_fromFrameImage = fromFrameImage;
+		_method = reflectMethod(method);
+	}
+	
+	/** Whether the transition has been constructed properly. */
+	public boolean isValid()
+	{
+		return _fromFrameImage != null && _method != null;
+	}
+	
+	/** Sets the timing data for this transition to their initial default values. */
+	private void initialiseTiming()
+	{
+		initialiseTiming(DEFAULT_TRANSITION_DURATION);
+	}
+	
+	/** Sets the timing data for this transition to their initial values. */
+	private void initialiseTiming(long duration)
+	{
+		// Check if already initialised
+		if (_duration != null || duration < 0) return;
+		
+		_duration = duration;
+		_completed = 0;
+		_lastUpdateTime = System.currentTimeMillis();
+	}
+	
+	/**
+	 * Updates the timing data for the transition and returns the elapsed
+	 * time since the last update.
+	 */
+	private long updateTiming()
+	{
+		// No need to update if we've finished
+		if (isCompleted()) return 0;
+		
+		long currentTime = System.currentTimeMillis();
+		long deltaTime = currentTime - _lastUpdateTime;
+		_completed += deltaTime;
+		if (_completed > _duration) {
+			long overshoot = _completed - _duration;
+			_completed -= overshoot;
+			currentTime -= overshoot;
+			deltaTime -= overshoot;
+		}
+		_lastUpdateTime = currentTime;
+		return deltaTime;
+	}
+	
+	/** Gets the percentage of the transition that has elapsed. */
+	private double getPercentageComplete()
+	{
+		if (_duration == 0.0) return 1.0;
+		
+		return ((double) _completed) / _duration;
+	}
+	
+	public boolean isCompleted()
+	{
+		return _completed == _duration;
+	}
+	
+	/** Gets the transition method that corresponds to the given string. */
+	private Method reflectMethod(String method)
+	{
+		try {
+			return this.getClass().getDeclaredMethod(method, REFLECTION_PARAMS);
+		} catch (NoSuchMethodException | SecurityException e) {
+			return null;
+		}
+	}
+	
+	/** Draws the selected transition. Returns whether the transition draw completed successfully. */
+	public boolean drawTransition(Image toFrameImage, AxisAlignedBoxBounds area)
+	{
+		// No need to draw if not a valid transition
+		if (!isValid()) return false;
+
+		// Invoke the drawing method
+		try {
+			_method.invoke(this, toFrameImage, area);
+			return true;
+		} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+			System.err.println("An Reflection Exception occurred trying to invoke '" + _method.getName() + "'");
+			e.printStackTrace();
+			return false;
+		}
+	}
+	
+	/*
+	 * 
+	 * Transition methods.
+	 * 
+	 */
+	
+	public void template(Image toImage, AxisAlignedBoxBounds area)
+	{
+		initialiseTiming();
+		updateTiming();
+		
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+	}
+	
+	/** Slides new frame over current from from right to left. */
+	public void CoverFromRight(Image toImage, AxisAlignedBoxBounds area)
+	{
+		initialiseTiming();
+		updateTiming();
+
+		int frameX = area.getMinX() + (int) (area.getWidth() * (1.0 - getPercentageComplete()));
+		Point topLeft = new Point(frameX, 0);
+		Dimension size = area.getSize();
+		
+		EcosystemManager.getGraphicsManager().drawRectangle(topLeft, size, 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+		EcosystemManager.getGraphicsManager().drawImage(toImage, topLeft, size);
+	}
+
+	/** Slides new frame over current from from left to right. */
+	public void CoverFromLeft(Image toImage, AxisAlignedBoxBounds area)
+	{
+		initialiseTiming();
+		updateTiming();
+
+		int frameX = area.getMinX() - (int) (area.getWidth() * (1.0 - getPercentageComplete()));
+		Point topLeft = new Point(frameX, 0);
+		Dimension size = area.getSize();
+		
+		EcosystemManager.getGraphicsManager().drawRectangle(topLeft, size, 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+		EcosystemManager.getGraphicsManager().drawImage(toImage, topLeft, size);
+	}
+
+	/** Another name for CoverFromRight. */
+	public void Swipe(Image toImage, AxisAlignedBoxBounds area)
+	{
+		CoverFromRight(toImage, area);
+	}
+
+	/** Expands the new frame over the current one from the left. */
+	public void WipeFromLeft(Image toImage, AxisAlignedBoxBounds area)
+	{
+		initialiseTiming();
+		updateTiming();
+		
+		int cropWidth = (int) (toImage.getWidth() * getPercentageComplete());
+		Dimension cropSize = new Dimension(cropWidth, toImage.getHeight());
+		int drawWidth = (int) (area.getWidth() * getPercentageComplete());
+		Dimension drawSize = new Dimension(drawWidth, area.getHeight());
+		
+		if (cropWidth == 0 || drawWidth == 0) return;
+		
+		EcosystemManager.getGraphicsManager().drawRectangle(area.getTopLeft(), drawSize, 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+		EcosystemManager.getGraphicsManager().drawImage(toImage, area.getTopLeft(), drawSize, 0.0, Point.ORIGIN, cropSize);
+	}
+
+	/** Expands the new frame over the current one from the right. */
+	public void WipeFromRight(Image toImage, AxisAlignedBoxBounds area)
+	{
+		initialiseTiming();
+		updateTiming();
+		
+		int cropWidth = (int) (toImage.getWidth() * getPercentageComplete());
+		Dimension cropSize = new Dimension(cropWidth, toImage.getHeight());
+		int drawWidth = (int) (area.getWidth() * getPercentageComplete());
+		Dimension drawSize = new Dimension(drawWidth, area.getHeight());
+		int cropX = toImage.getWidth() - cropWidth;
+		Point cropTopLeft = new Point(cropX, 0);
+		int drawX = area.getWidth() - drawWidth;
+		Point drawTopLeft = area.getTopLeft().clone().add(drawX, 0);
+		
+		if (cropWidth == 0 || drawWidth == 0) return;
+		
+		EcosystemManager.getGraphicsManager().drawRectangle(drawTopLeft, drawSize, 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+		EcosystemManager.getGraphicsManager().drawImage(toImage, drawTopLeft, drawSize, 0.0, cropTopLeft, cropSize);
+	}
+		
+	/**
+	 * Drops new frame from top of display. Draws rectangle with gradient
+	 * effect to create illusion of drop shadow.
+	 */
+	public void FallDown(Image toImage, AxisAlignedBoxBounds area)
+	{
+		initialiseTiming();
+		updateTiming();
+		
+		int y = area.getMinY() - (int) (area.getHeight() * (1.0 - getPercentageComplete()));
+		Point drawTopLeft = new Point(area.getMinX(), y);
+		Point shadowTopLeft = drawTopLeft.clone().add(0, area.getHeight());
+		Dimension shadowSize = new Dimension(area.getWidth(), SHADOW_HEIGHT);
+		GradientFill shadowFill = new GradientFill(SHADOW_COLOUR, new Point(0, shadowTopLeft.y), Colour.TRANSPARENT, new Point(0, shadowTopLeft.y + SHADOW_HEIGHT));
+		
+		EcosystemManager.getGraphicsManager().drawRectangle(drawTopLeft, area.getSize(), 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+		EcosystemManager.getGraphicsManager().drawRectangle(shadowTopLeft, shadowSize, 0.0, shadowFill, null, null, null);
+		EcosystemManager.getGraphicsManager().drawImage(toImage, drawTopLeft, area.getSize());
+	}
+
+	/** Fades out to the given colour and then fades in the new frame. */
+	public void FadeIn(Image toImage, AxisAlignedBoxBounds area, Colour colour)
+	{
+		initialiseTiming();
+		updateTiming();
+		
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+		
+		double progress = getPercentageComplete();
+		
+		// Start by fading the overlay colour in
+		if (progress < 0.5) {
+			float alpha = (float) (progress * 2);
+
+			g.drawRectangle(area.getTopLeft(), area.getSize(), 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+			g.drawImage(_fromFrameImage, area.getTopLeft(), area.getSize());
+			g.setCompositeAlpha(alpha);
+			g.drawRectangle(area.getTopLeft(), area.getSize(), 0.0, new Fill(colour), null, null, null);
+		
+		// Then fade the overlay out to reveal the new frame
+		} else {
+			float alpha = 1.0f - (float) ((progress - 0.5) * 2);
+
+			g.drawRectangle(area.getTopLeft(), area.getSize(), 0.0, new Fill(Item.DEFAULT_BACKGROUND), null, null, null);
+			g.drawImage(toImage, area.getTopLeft(), area.getSize());
+			g.setCompositeAlpha(alpha);
+			g.drawRectangle(area.getTopLeft(), area.getSize(), 0.0, new Fill(colour), null, null, null);
+			
+		}
+	}
+	
+	/** Fades out to black and then fades in the new frame. */
+	public void FadeInBlack(Image toImage, AxisAlignedBoxBounds area)
+	{
+		FadeIn(toImage, area, Colour.BLACK);
+	}
+
+	/** Fades out to white and then fades in the new frame. */
+	public void FadeInWhite(Image toImage, AxisAlignedBoxBounds area)
+	{
+		FadeIn(toImage, area, Colour.WHITE);
+	}
+
+	/** Fades the current frame out while the new frame fades in overtop. */
+	public void CrossFade(Image toImage, AxisAlignedBoxBounds area)
+	{ 
+		// Based on: http://stackoverflow.com/questions/20346661/java-fade-in-and-out-of-images
+		// TODO: make use of timer, as this example does, rather than fixed delay
+		
+		initialiseTiming();
+		updateTiming();
+		
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+		
+		float fadeInAlpha = (float) getPercentageComplete();
+		float fadeOutAlpha = 1.0f - fadeInAlpha;
+		
+		// Clear the screen
+		g.clear(Item.DEFAULT_BACKGROUND);
+		
+		// Draw the current frame with decreasing alpha
+		g.setCompositeAlpha(fadeOutAlpha);
+		g.drawImage(_fromFrameImage, area.getTopLeft(), area.getSize());
+		
+		// Draw the in-image with increasing alpha
+		g.setCompositeAlpha(fadeInAlpha);
+		g.drawImage(toImage, area.getTopLeft(), area.getSize());
+	}
+}
Index: trunk/src/org/expeditee/items/widgets/JavaFXSwingWidget.java
===================================================================
--- trunk/src/org/expeditee/items/widgets/JavaFXSwingWidget.java	(revision 1098)
+++ trunk/src/org/expeditee/items/widgets/JavaFXSwingWidget.java	(revision 1098)
@@ -0,0 +1,27 @@
+package org.expeditee.items.widgets;
+
+import javafx.embed.swing.SwingNode;
+
+public class JavaFXSwingWidget extends JavaFXWidget {
+	
+	SwingWidget _baseWidget;
+
+	protected JavaFXSwingWidget(SwingWidget baseWidget)
+	{
+		super(baseWidget.getSource(), new SwingNode(), baseWidget.getMinWidth(), baseWidget.getMaxWidth(), baseWidget.getMinHeight(), baseWidget.getMaxHeight());
+		((SwingNode) _node).setContent(baseWidget._swingComponent);
+		_baseWidget = baseWidget;
+	}
+
+	@Override
+	protected String[] getArgs() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	public SwingWidget getSwingWidget()
+	{
+		return _baseWidget;
+	}
+
+}
Index: trunk/src/org/expeditee/items/widgets/JavaFXWidget.java
===================================================================
--- trunk/src/org/expeditee/items/widgets/JavaFXWidget.java	(revision 1098)
+++ trunk/src/org/expeditee/items/widgets/JavaFXWidget.java	(revision 1098)
@@ -0,0 +1,55 @@
+package org.expeditee.items.widgets;
+
+import org.expeditee.core.Image;
+import org.expeditee.gio.EcosystemManager;
+import org.expeditee.gio.EcosystemManager.Ecosystem;
+import org.expeditee.gio.javafx.JavaFXMiscManager;
+import org.expeditee.items.Text;
+
+import javafx.scene.Group;
+import javafx.scene.Node;
+import javafx.scene.Scene;
+import javafx.scene.SnapshotParameters;
+import javafx.scene.image.WritableImage;
+
+public abstract class JavaFXWidget extends Widget {
+	
+	protected Scene _dummyScene;
+	protected Node _node;
+
+	protected JavaFXWidget(Text source, Node jfxNode, int minWidth, int maxWidth, int minHeight, int maxHeight)
+	{
+		super(source, minWidth, maxWidth, minHeight, maxHeight);
+		_node = jfxNode;
+		_dummyScene = new Scene(new Group(_node));
+		onSizeChanged();
+	}
+	
+	@Override
+	public boolean isSupportedOnEcosystem(Ecosystem type)
+	{
+		return type == Ecosystem.JavaFX;
+	}
+
+	@Override
+	public void paintWidget()
+	{
+		SnapshotParameters params = new SnapshotParameters();
+		WritableImage snapshot = _node.snapshot(params, null);
+		Image image = JavaFXMiscManager.getIfUsingJavaFXImageManager().createImage(snapshot);
+		EcosystemManager.getGraphicsManager().drawImage(image, getPosition());
+	}
+	
+	@Override
+	protected void onMoved()
+	{
+		// Do nothing
+	}
+	
+	@Override
+	protected void onSizeChanged()
+	{
+		_dummyScene.getRoot().resize(getWidth(), getHeight());
+		_node.resize(getWidth(), getHeight());
+	}
+}
Index: trunk/src/org/expeditee/items/widgets/SwingWidget.java
===================================================================
--- trunk/src/org/expeditee/items/widgets/SwingWidget.java	(revision 1098)
+++ trunk/src/org/expeditee/items/widgets/SwingWidget.java	(revision 1098)
@@ -0,0 +1,130 @@
+package org.expeditee.items.widgets;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Graphics2D;
+
+import javax.swing.JComponent;
+
+import org.expeditee.gio.EcosystemManager.Ecosystem;
+import org.expeditee.gio.swing.SwingMiscManager;
+import org.expeditee.items.Text;
+
+public abstract class SwingWidget extends Widget
+{
+	// A flag for signifying whether the swing components are ready to paint.
+	// If the swing components has not been layed out, if they are painted they
+	// will not draw in the correct positions.
+	// Also for setting AWT and Swing -Related drawing options after
+	// construction
+	private boolean _isReadyToPaint = false;
+
+	protected JComponent _swingComponent;
+	
+	protected SwingWidget(Text source, JComponent component, int minWidth, int maxWidth, int minHeight, int maxHeight)
+	{
+		super(source, minWidth, maxWidth, minHeight, maxHeight);
+
+		if (component == null) throw new NullPointerException("component");
+
+		_swingComponent = component;
+		onBoundsChanged();
+	}
+
+	public JComponent getComponent()
+	{
+		return _swingComponent;
+	}
+	
+	@Override
+	protected void onMoved()
+	{
+		// Do nothing
+	}
+	
+	@Override
+	protected void onSizeChanged()
+	{
+    	onBoundsChanged();
+    	layout(_swingComponent);
+	}
+
+	public final void onBoundsChanged()
+	{
+		if (_swingComponent == null) return;
+		
+		if (isFixedSize()) {
+			_swingComponent.setBounds(getX(), getY(), getMaxWidth(), getMaxHeight());
+		} else {
+			_swingComponent.setBounds(getX(), getY(), getWidth(), getHeight());
+		}
+	}
+
+	private void prepareToPaint()
+	{
+		_isReadyToPaint = true;
+		layout(_swingComponent);
+		ignoreAWTPainting(_swingComponent);
+	}
+
+	private void ignoreAWTPainting(Component c)
+	{
+		if (c == null) return;
+		
+		if (c instanceof JComponent) ((JComponent) c).setDoubleBuffered(false);
+		c.setIgnoreRepaint(true);
+
+		if (c instanceof Container) {
+			for (Component child : ((Container) c).getComponents()) {
+				ignoreAWTPainting(child);
+			}
+		}
+	}
+
+	/**
+	 * Due to absolute positioning...
+	 * 
+	 * @param parent
+	 */
+	protected void layout(Component parent)
+	{
+		if (parent == null) return;
+		
+		parent.validate();
+
+		if (parent instanceof Container) {
+			for (Component child : ((Container) parent).getComponents()) {
+				layout(child);
+			}
+		}
+	}
+
+	@Override
+	protected final void paintWidget()
+	{
+		if (!_isReadyToPaint) {
+			prepareToPaint();
+		}
+
+		Graphics2D g = SwingMiscManager.getIfUsingSwingGraphicsManager().getCurrentSurface();
+
+		int x = getX();
+		int y = getY();
+		
+		g.translate(x, y);
+		paintSwingWidget(g);
+		g.translate(-x, -y);
+	}
+	
+	/** Can be overridden to enable custom painting of widgets. */
+	protected void paintSwingWidget(Graphics2D g)
+	{
+		_swingComponent.paint(g);
+	}
+	
+	@Override
+	public boolean isSupportedOnEcosystem(Ecosystem type)
+	{
+		return type == Ecosystem.Swing;
+	}
+}
Index: trunk/src/org/expeditee/items/widgets/Widget.java
===================================================================
--- trunk/src/org/expeditee/items/widgets/Widget.java	(revision 1098)
+++ trunk/src/org/expeditee/items/widgets/Widget.java	(revision 1098)
@@ -0,0 +1,1842 @@
+/**
+ *    InteractiveWidget.java
+ *    Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
+ *
+ *    This program is free software: you can redistribute it and/or modify
+ *    it under the terms of the GNU General Public License as published by
+ *    the Free Software Foundation, either version 3 of the License, or
+ *    (at your option) any later version.
+ *
+ *    This program is distributed in the hope that it will be useful,
+ *    but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *    GNU General Public License for more details.
+ *
+ *    You should have received a copy of the GNU General Public License
+ *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.expeditee.items.widgets;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.expeditee.Util;
+import org.expeditee.actions.Actions;
+import org.expeditee.core.Anchoring;
+import org.expeditee.core.Clip;
+import org.expeditee.core.Colour;
+import org.expeditee.core.Dimension;
+import org.expeditee.core.EcosystemSpecific;
+import org.expeditee.core.Fill;
+import org.expeditee.core.Point;
+import org.expeditee.core.bounds.AxisAlignedBoxBounds;
+import org.expeditee.gio.EcosystemManager;
+import org.expeditee.gio.EcosystemManager.Ecosystem;
+import org.expeditee.gio.GraphicsManager;
+import org.expeditee.gui.DisplayController;
+import org.expeditee.gui.Frame;
+import org.expeditee.gui.FrameIO;
+import org.expeditee.gui.FreeItems;
+import org.expeditee.items.Item;
+import org.expeditee.items.ItemParentStateChangedEvent;
+import org.expeditee.items.ItemUtils;
+import org.expeditee.items.Text;
+
+/**
+ * The bridge between swing space and Expeditee space
+ * 
+ * @author Brook
+ * 
+ */
+public abstract class Widget implements EcosystemSpecific
+{
+	
+	/** The colour to fill the widget area with when not rendering the widget itself (i.e. when picked up). */
+	protected final static Colour FREESPACE_BACKCOLOR = Colour.FromRGB255(100, 100, 100);
+
+	/** The minimum border thickness for widgets. */
+	public final static float DEFAULT_MINIMUM_BORDER_THICKNESS = 1.0f;
+	
+	/* GUIDE:
+	 * d1--l1---d2
+	 * |         |
+	 * l4 | X | l2
+	 * |         |
+	 * d4---l3--d3
+	 */
+
+	/** The top-left corner of the widget. */
+	private WidgetCorner _d1;
+	/** The top-right corner of the widget. */
+	private WidgetCorner _d2;
+	/** The bottom-right corner of the widget. */
+	private WidgetCorner _d3;
+	/** The bottom-left corner of the widget. */
+	private WidgetCorner _d4;
+
+	/** The top edge of the widget. */
+	private WidgetEdge _l1;
+	/** The right edge of the widget. */
+	private WidgetEdge _l2;
+	/** The bottom edge of the widget. */
+	private WidgetEdge _l3;
+	/** The left edge of the widget. */
+	private WidgetEdge _l4;
+
+	/** Used for quickly returning item list. */
+	private List<Item> _expediteeItems;
+
+	// Widget size restrictions
+	/** Minimum width of the widget. */
+	private int _minWidth = 50;
+	/** Minimum height of the widget. */
+	private int _minHeight = 50;
+	/** Maximum width of the widget. */
+	private int _maxWidth = 300;
+	/** Maximum height of the widget. */
+	private int _maxHeight = 300;
+
+	/** The Expeditee item that is used for saving widget state. */
+	protected Text _textRepresentation;
+
+	/** The anchoring of the widget. */
+	protected Anchoring _anchoring = new Anchoring();
+
+	/**
+	 * Creates a InteractiveWidget from a text item.
+	 * 
+	 * @param source
+	 *            Must not be null, first line of text used - which the format
+	 *            must be as follows: "@iw: <<widget_class_name>> [<<width>>] [<<height>>] [: [<<arg1>>] [<<arg2>>]
+	 *            [...]]".
+	 * 
+	 * e.g: "@iw: org.expeditee.items.SampleWidget1 100 20 : 2" creates a
+	 * SampleWidget1 with width = 100 and height = 20 with 1 argument = "2"
+	 * 
+	 * @return An InteractiveWidget instance. Never null.
+	 * 
+	 * @throws NullPointerException
+	 *             if source is null
+	 * 
+	 * @throws IllegalArgumentException
+	 *             if source's text is in the incorrect format or if source's
+	 *             parent is null
+	 * 
+	 * @throws InteractiveWidgetNotAvailableException
+	 *             If the given widget class name in the source text doesn't
+	 *             exist or not an InteractiveWidget or the widget does not
+	 *             supply a valid constructor for creation.
+	 * 
+	 * @throws InteractiveWidgetInitialisationFailedException
+	 *             The sub-constructor failed - depends on the type of widget
+	 *             being instantainiated.
+	 * 
+	 * class names beginning with $, the $ will be replaced with
+	 * "org.expeditee.items."
+	 */
+	public static Widget createWidget(Text source) throws InteractiveWidgetNotAvailableException,
+																	InteractiveWidgetInitialisationFailedException
+	{
+
+		if (source == null) throw new NullPointerException("source");
+		
+		if (source.getParent() == null) throw new IllegalArgumentException("source's parent is null, InteractiveWidget's must be created from Text items with non-null parents");
+
+		String TAG = ItemUtils.GetTag(ItemUtils.TAG_IWIDGET);
+
+		String text = source.getText();
+		if (text == null) {
+			throw new IllegalArgumentException("source does not have any text");
+		}
+
+		text = text.trim();
+
+		// Check starts with the widget tag and separator
+		if (!text.startsWith(TAG + ":")) throw new IllegalArgumentException("Source text must begin with \"" + TAG + ":\"");
+
+		// skip over the '@iw:' preamble
+		text = text.substring(TAG.length() + 1).trim();
+
+		int index = 0;
+		if (text.length() > 0) {
+		    // Having removed @iw:, then next ':' is used for signifying start of arguments
+		    index = text.indexOf(':'); 
+		}
+
+		if (index == 0) {
+		    throw new IllegalArgumentException("Source text must begin with \"" + TAG + "\"");
+		}
+
+		//
+		// Step 1: 
+		//   For an X-rayable text item in the form:
+		//     @iw: <class name> [options] width height : <rest...>
+		//
+		//    the 'core' part of the X-rayable text item
+		//   i.e, the text between the first ':' and the second ':'
+		//  
+		//
+		
+		String tokens_str = (index == -1) ? text : text.substring(0, index);
+
+		String[] tokens = Text.parseArgsApache(tokens_str);
+
+		// make anything starting with a '-' lowercase
+		for (int i=0; i<tokens.length; i++) {
+			if (tokens[i].startsWith("-")) {
+				tokens[i] = tokens[i].toLowerCase();
+			}
+		}
+		
+		// create the command line parser
+		CommandLineParser parser = new GnuParser();
+
+		// create the Options
+		Options options = new Options();
+		options.addOption( "al", "anchorleft",   true, "Anchor the vertical left-hand edge of the interactive widget to the value provided " );
+		options.addOption( "ar", "anchorright",  true, "Anchor the vertical right-hand edge of the interactive widget to the value provided " );
+		options.addOption( "at", "anchortop",    true, "Anchor the vertical top edge of the interactive widget to the value provided " );
+		options.addOption( "ab", "anchorbottom", true, "Anchor the vertical bottom edge of the interactive widget to the value provided " );
+		
+		/*
+		 * Alternative way to do the above, but with more control over how the values are set up and can be used
+		 * 
+		@SuppressWarnings("static-access")
+		Option anchor_left_opt = OptionBuilder.withLongOpt( "anchorleft" )
+				.withDescription( "use <x-pos> as left anchor for the vertical lefthand edge of the interactive widget" )
+				.hasArg()
+				.withArgName("<x-pos>")
+				.create("al");
+         
+		@SuppressWarnings("static-access")
+		Option anchor_right_opt = OptionBuilder.withLongOpt( "anchorright" )
+				.withDescription( "use <x-pos> as right anchor for the vertical righthand edge of the interactive widget" )
+				.hasArg()
+				.withArgName("<x-pos>")
+				.create("ar");
+		
+		
+		@SuppressWarnings("static-access")
+		Option anchor_top_opt = OptionBuilder.withLongOpt( "anchortop" )
+				.withDescription( "use <y-pos> as top anchor for the horizontal top end of the interactive widget" )
+				.hasArg()
+				.withArgName("<x-pos>")
+				.create("at");
+         
+		@SuppressWarnings("static-access")
+		Option anchor_bottom_opt = OptionBuilder.withLongOpt( "anchorbottom" )
+				.withDescription( "use <y-pos> as bottom anchor for the horizontal bottom edge of the interactive widget" )
+				.hasArg()
+				.withArgName("<x-pos>")
+				.create("ab");
+		
+		options.addOption(anchor_left_opt);
+		options.addOption(anchor_right_opt);
+		options.addOption(anchor_top_opt);
+		options.addOption(anchor_bottom_opt);
+		*/
+
+		CommandLine core_line;
+		try {
+		    // parse the command line arguments
+		    core_line = parser.parse( options, tokens );
+		    
+		    // Update tokens to be version with the options removed
+		    tokens = core_line.getArgs();
+		    
+		}
+		catch( ParseException exp ) {
+		    System.err.println( "Unexpected exception:" + exp.getMessage() );
+		    core_line = null;
+		    
+		}
+		
+		HelpFormatter formatter = new HelpFormatter();
+		StringWriter usage_str_writer = new StringWriter();
+	    PrintWriter printWriter = new PrintWriter(usage_str_writer);
+	    
+	    String widget_name = tokens[0];
+	    final String widget_prefix = "org.expeditee.items.widgets";
+	    if (widget_name.startsWith(widget_prefix)) {
+	    	widget_name = widget_name.substring(widget_prefix.length());
+	    }
+	    
+		formatter.printHelp(printWriter, 80, TAG + ":" + widget_name + " [options] width height", null, options, 4, 0, null);
+		//System.out.println(usage_str_writer.toString());
+		
+		float width = -1, height = -1;
+
+		if (tokens.length < 1) {
+			throw new IllegalArgumentException("Missing widget class name in source text");
+		}
+
+		try {
+
+			if (tokens.length >= 2) { // parse optional width
+				width = Integer.parseInt(tokens[1]);
+				width = (width <= 0) ? width = -1 : width;
+			}
+
+			if (tokens.length >= 3) { // parse optional height
+				height = Integer.parseInt(tokens[2]);
+				height = (height <= 0) ? height = -1 : height;
+			}
+
+		} catch (NumberFormatException nfe) {
+			throw new IllegalArgumentException(
+					"Bad width or height given in source text", nfe);
+		}
+
+		if (tokens.length > 3)
+			throw new IllegalArgumentException(
+					"to many arguments given before \":\" in source text");
+
+		String classname = tokens[0];
+		if (classname.charAt(0) == '$'){
+			classname = classname.substring(1);
+		}
+		
+		// Attempt to locate the class using reflection
+		Class<?> iwclass = findIWidgetClass(classname);
+
+		if (iwclass == null) // ensure it exists
+			throw new InteractiveWidgetNotAvailableException(classname
+					+ " does not exist or is not an InteractiveWidget");
+
+		
+		//
+		// Step 2: 
+		//   For an X-rayable text item in the form:
+		//     @iw: <class name> [options] width height : <rest...>
+		//
+		//   Parse the <rest ...> part
+		
+		// Extract out the parameters - if any
+		String[] args = null;
+		if (index > 0) { // index of the first ":"
+			if (text.length()>(index+1)) {
+				String args_str = text.substring(index + 1);
+				
+				 args = Text.parseArgsApache(args_str);
+		
+			}	
+		}
+
+		Widget inst = null;
+		try {
+			// Instantiate the widget - passing the params
+			Class parameterTypes[] = new Class[] { Text.class, String[].class };
+			Constructor ct = iwclass.getConstructor(parameterTypes);
+
+			Object arglist[] = new Object[] { source, args };
+
+			inst = (Widget) ct.newInstance(arglist);
+		} catch (Exception e) {
+			throw new InteractiveWidgetNotAvailableException(
+					"Failed to create instance via reflection: " + e.toString(),
+					e);
+		}
+		
+		// Check that the widget is suitable for the current platform
+		Ecosystem systemType = EcosystemManager.getType();
+		if (!inst.isSupportedOnEcosystem(systemType)) {
+			// Try create a JavaFXSwingWidget if creating a Swing widget in JavaFX
+			if (systemType == Ecosystem.JavaFX && inst.isSupportedOnEcosystem(Ecosystem.Swing)) {
+				inst = new JavaFXSwingWidget((SwingWidget) inst);
+			} else {
+				throw new InteractiveWidgetNotAvailableException(classname + " is not supported while using a " + systemType + " system.");
+			}
+		}
+
+		// Step 3: 
+		//    Set up the size and position of the widget
+
+		// Use default dimensions if not provided (or provided as negative
+		// values)
+		if (width <= 0) {
+			width = inst.getWidth();
+		}
+		if (height <= 0) {
+			height = inst.getHeight();
+		}
+
+		inst.setSize(width, height);
+		
+		// Apply any anchor values supplied in the core part of the @iw item
+		Integer anchor_left   = null;
+		Integer anchor_right  = null;
+		Integer anchor_top    = null;
+		Integer anchor_bottom = null;
+		
+	    if(core_line.hasOption( "anchorleft" ) ) {
+	    	String al_str = core_line.getOptionValue( "anchorleft" );
+	    	
+	    	anchor_left = (int) Float.parseFloat(al_str);
+	    }
+	    
+	    if(core_line.hasOption( "anchorright" ) ) {
+	    	String ar_str = core_line.getOptionValue( "anchorright" );
+	    	
+	    	anchor_right = (int) Float.parseFloat(ar_str);
+	    }
+	    
+	    if(core_line.hasOption( "anchortop" ) ) {
+	    	String at_str = core_line.getOptionValue( "anchortop" );
+	    	
+	    	anchor_top = (int) Float.parseFloat(at_str);
+	    }
+	    
+	    if(core_line.hasOption( "anchorbottom" ) ) {
+	    	String ab_str = core_line.getOptionValue( "anchorbottom" );
+	    	
+	    	anchor_bottom = (int) Float.parseFloat(ab_str);
+	    }
+	    
+	    inst.setAnchorCorners(anchor_left,anchor_right,anchor_top,anchor_bottom);
+	    
+		return inst;
+	}
+
+	/**
+	 * Locates the class from the classname of an InteractiveWidget class
+	 * 
+	 * @param classname
+	 *            The name of the class to search
+	 * @return Null if doesn't exist or not an InteractiveWidget
+	 */
+	private static Class findIWidgetClass(String classname)
+	{
+		if(classname == null)
+			return null;
+		// try just the classname
+		try {
+			Class c = Class.forName(classname); // attempt to find the class
+
+			// If one is found, ensure that it is a descendant of an
+			// InteractiveWidget
+			for (Class superclass = c.getSuperclass(); superclass != null
+					&& superclass != Item.class; superclass = superclass
+					.getSuperclass()) {
+				if (superclass == Widget.class)
+					return c;
+			}
+
+		} catch (ClassNotFoundException e) {
+		}
+		// see if the class is a widget with invalid capitalisation, or missing the widget package prefix
+		if(classname.startsWith(Actions.WIDGET_PACKAGE)) {
+			classname = classname.substring(Actions.WIDGET_PACKAGE.length());
+		}
+		try {
+			Class c = Class.forName(Actions.getClassName(classname)); // attempt to find the class
+
+			// If one is found, ensure that it is a descendant of an
+			// InteractiveWidget
+			for (Class superclass = c.getSuperclass(); superclass != null
+					&& superclass != Item.class; superclass = superclass
+					.getSuperclass()) {
+				if (superclass == Widget.class)
+					return c;
+			}
+
+		} catch (ClassNotFoundException e) {
+		}
+
+		// Doesn't exist or not an InteractiveWidget
+		return null;
+	}
+
+	/**
+	 * Arguments represent the widgets <i>current state</i> state. They are
+	 * used for saving, loading, creating and cloning Special formatting is done
+	 * for you.
+	 * 
+	 * @see #getData()
+	 * 
+	 * @return Can be null for no params.
+	 */
+	protected abstract String[] getArgs();
+
+	/**
+	 * Data represents the widgets <i>current state</i> state. For any state
+	 * information you do not wish to be defined as arguments (e.g. metadata),
+	 * you can set as the widgets source items data.
+	 * 
+	 * The default implementation returns null. Override to make use of.
+	 * 
+	 * @see #getArgs()
+	 * 
+	 * @return Null for for data. Otherwise the data that represent this widgets
+	 *         <i>current state</i>
+	 */
+	protected List<String> getData()
+	{
+		return null;
+	}
+
+	/**
+	 * Constructor
+	 * 
+	 * @param source
+	 *            Must not be null. Neither must it's parent
+	 * 
+	 * @param component
+	 *            Must not be null.
+	 * 
+	 * @param minWidth
+	 *            The min width restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param maxWidth
+	 *            The max width restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param minHeight
+	 *            The min height restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param maxHeight
+	 *            The max height restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @throws NullPointerException
+	 *             If source, component if null.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If source's parent is null. If maxWidth smaller than minWidth
+	 *             and maxWidth larger or equal to zero or if maxHeight smaller
+	 *             than minHeight && maxHeight is larger or equal to zero
+	 * 
+	 */
+	protected Widget(Text source, int minWidth, int maxWidth, int minHeight, int maxHeight)
+	{
+		if (source == null) throw new NullPointerException("source");
+		if (source.getParent() == null) {
+			throw new IllegalArgumentException("source's parent is null, InteractiveWidget's must be created from Text items with non-null parents");
+		}
+		
+		_textRepresentation = source;
+
+		setSizeRestrictions(minWidth, maxWidth, minHeight, maxHeight); // throws IllegalArgumentException's
+
+		int x = source.getX();
+		int y = source.getY();
+		int width = (int) ((_minWidth < 0) ? 10 : _minWidth);
+		int height = (int) ((_minHeight < 0) ? 10 : _minHeight);
+
+		Frame idAllocator = _textRepresentation.getParent();
+
+		// create WidgetCorners
+		_d1 = new WidgetCorner(x, y, idAllocator.getNextItemID(), this);
+		_d2 = new WidgetCorner(x + width, y, idAllocator.getNextItemID(), this);
+		_d3 = new WidgetCorner(x + width, y + height, idAllocator.getNextItemID(), this);
+		_d4 = new WidgetCorner(x, y + height, idAllocator.getNextItemID(), this);
+
+		// create WidgetEdges
+		_l1 = new WidgetEdge(_d1, _d2, idAllocator.getNextItemID(), this);
+		_l2 = new WidgetEdge(_d2, _d3, idAllocator.getNextItemID(), this);
+		_l3 = new WidgetEdge(_d3, _d4, idAllocator.getNextItemID(), this);
+		_l4 = new WidgetEdge(_d4, _d1, idAllocator.getNextItemID(), this);
+
+		Collection<Item> enclist = new ArrayList<Item>(4);
+		enclist.add(_d1);
+		enclist.add(_d2);
+		enclist.add(_d3);
+		enclist.add(_d4);
+		_d1.setEnclosedList(enclist);
+		_d2.setEnclosedList(enclist);
+		_d3.setEnclosedList(enclist);
+		_d4.setEnclosedList(enclist);
+
+		_expediteeItems = new ArrayList<Item>(8); // Note: order important
+		_expediteeItems.add(_d1);
+		_expediteeItems.add(_d2);
+		_expediteeItems.add(_d3);
+		_expediteeItems.add(_d4);
+		_expediteeItems.add(_l1);
+		_expediteeItems.add(_l2);
+		_expediteeItems.add(_l3);
+		_expediteeItems.add(_l4);
+
+		setWidgetEdgeColor(source.getBorderColor());
+		setWidgetEdgeThickness(source.getThickness());
+	}
+
+	/**
+	 * Sets the restrictions - checks values.
+	 * 
+	 * @param minWidth
+	 *            The min width restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param maxWidth
+	 *            The max width restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param minHeight
+	 *            The min height restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param maxHeight
+	 *            The max height restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If maxWidth smaller than minWidth and maxWidth larger or
+	 *             equal to zero or if maxHeight smaller than minHeight &&
+	 *             maxHeight is larger or equal to zero
+	 * 
+	 */
+	private void setSizeRestrictions(int minWidth, int maxWidth, int minHeight, int maxHeight)
+	{
+		_minWidth = minWidth;
+
+		if (maxWidth < _minWidth && maxWidth >= 0) {
+			throw new IllegalArgumentException("maxWidth smaller than the min Width");
+		}
+		_maxWidth = maxWidth;
+
+		_minHeight = minHeight;
+		if (maxHeight < _minHeight && maxHeight >= 0) {
+			throw new IllegalArgumentException("maxHeight smaller than the min Height");
+		}
+		_maxHeight = maxHeight;
+	}
+	
+	public int getMinWidth()
+	{
+		return _minWidth;
+	}
+	
+	public int getMinHeight()
+	{
+		return _minHeight;
+	}
+	
+	public int getMaxWidth()
+	{
+		return _maxWidth;
+	}
+	
+	public int getMaxHeight()
+	{
+		return _maxHeight;
+	}
+
+	/**
+	 * This can be overridden for creating custom copies. The default
+	 * implementation creates a new widget based on the current state of the
+	 * widget (via getArgs).
+	 * 
+	 * @see InteractiveWidget#getArgs().
+	 * 
+	 * @return A copy of this widget.
+	 * 
+	 */
+	public Widget copy() throws InteractiveWidgetNotAvailableException, InteractiveWidgetInitialisationFailedException
+	{
+		Text t = _textRepresentation.copy();
+		String clonedAnnotation = getAnnotationString();
+		t.setText(clonedAnnotation);
+		t.setData(getData());
+		return Widget.createWidget(t);
+	}
+
+	/**
+	 * Notifies widget of delete
+	 */
+	public void onDelete()
+	{
+		// Allocate new ID's
+		Frame parent = getParentFrame();
+		
+		if (parent == null) parent = DisplayController.getCurrentFrame();
+
+		if (parent != null) {
+			for (Item i : _expediteeItems) {
+				i.setID(parent.getNextItemID());
+			}
+		}
+
+		invalidateLink();
+	}
+
+	/**
+	 * Note updates the source text with current state info
+	 * 
+	 * @return The Text item that this widget was created from.
+	 */
+	public Text getSource()
+	{
+		// Build the annotation string such that it represents this widgets
+		// current state
+		String newAnnotation = getAnnotationString();
+
+		// Set the new text
+		_textRepresentation.setText(newAnnotation);
+
+		// Set the data
+		_textRepresentation.setData(getData());
+
+		return _textRepresentation;
+	}
+
+	/**
+	 * @return The current representation for this widget. The representation
+	 *         stores link information, data etc... It is used for saving and
+	 *         loading of the widget. Never null.
+	 * 
+	 */
+	protected Item getCurrentRepresentation()
+	{
+		return _textRepresentation;
+	}
+
+	/**
+	 * @return The Expeditee annotation string.
+	 */
+	protected String getAnnotationString() {
+
+		// Create tag and append classname
+		StringBuilder sb = new StringBuilder(ItemUtils.GetTag(ItemUtils.TAG_IWIDGET));
+		sb.append(':');
+		sb.append(' ');
+		sb.append(getClass().getName());
+
+		if (_anchoring.getLeftAnchor() != null) {
+		    sb.append(" --anchorLeft " + Math.round(_anchoring.getLeftAnchor()));
+		}
+		if (_anchoring.getRightAnchor() != null) {
+		    sb.append(" --anchorRight " + Math.round(_anchoring.getRightAnchor()));
+		}
+
+		if (_anchoring.getTopAnchor() != null) {
+		    sb.append(" --anchorTop " + Math.round(_anchoring.getTopAnchor()));
+		}
+
+		if (_anchoring.getBottomAnchor() != null) {
+		    sb.append(" --anchorBottom " + Math.round(_anchoring.getBottomAnchor()));
+		}
+
+		// Append size information if needed (not an attribute of text items)
+		if (!isFixedSize()) {
+			sb.append(' ');
+			sb.append(getWidth());
+			sb.append(' ');
+			sb.append(getHeight());
+		}
+
+		// Append arguments if any
+		String stateArgs = Util.formatArgs(getArgs());
+		if (stateArgs != null) {
+			sb.append(':');
+			sb.append(stateArgs);
+		}
+
+		return sb.toString();
+	}
+
+	/**
+	 * Sets both the new size as well as the new min/max widget/height
+	 * restrictions.
+	 * 
+	 * @param minWidth
+	 *            The min width restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param maxWidth
+	 *            The max width restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param minHeight
+	 *            The min height restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param maxHeight
+	 *            The max height restriction for the widget. If negative, then
+	 *            there is no restriction.
+	 * 
+	 * @param newWidth
+	 *            Clamped to new restrictions.
+	 * 
+	 * @param newHeight
+	 *            Clamped to new restrictions.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If maxWidth smaller than minWidth and maxWidth larger or
+	 *             equal to zero or if maxHeight smaller than minHeight &&
+	 *             maxHeight is larger or equal to zero
+	 * 
+	 * @see #setSize(float, float)
+	 * 
+	 */
+	public void setSize(int minWidth, int maxWidth, int minHeight, int maxHeight, float newWidth, float newHeight)
+	{
+		setSizeRestrictions(minWidth, maxWidth, minHeight, maxHeight);
+		setSize(newWidth, newHeight);
+	}
+
+	/**
+	 * Clamped to current min/max width/height.
+	 * 
+	 * @param width
+	 *            Clamped to current restrictions.
+	 * @param height
+	 *            Clamped to current restrictions.
+	 * 
+	 * @see #setSize(int, int, int, int, float, float)
+	 */
+	public void setSize(float width, float height)
+	{
+		// If 'width' and 'height' exceed the min/max values for width/height
+		// => clamp to the relevant min/max value 
+		if (width < _minWidth && _minWidth >= 0) {
+			width = _minWidth;
+		} else if (width > _maxWidth && _maxWidth >= 0) {
+			width = _maxWidth;
+		}
+		
+		if (height < _minHeight && _minHeight >= 0) {
+			height = _minHeight;
+		} else if (height > _maxHeight && _maxHeight >= 0) {
+			height = _maxHeight;
+		}
+		
+		// Remember current isFloating() values
+		boolean vfloating[] = new boolean[] { _d1.isFloating(), _d2.isFloating(), _d3.isFloating(), _d4.isFloating() };
+
+		_d1.setFloating(true);
+		_d2.setFloating(true);
+		_d3.setFloating(true);
+		_d4.setFloating(true);
+
+		float xr = _d1.getX() + width;
+		float yb = _d1.getY() + height;
+
+		_d2.setX(xr);
+		_d3.setX(xr);
+		_d3.setY(yb);
+		_d4.setY(yb);
+
+		// Restore isFloating() values
+		_d1.setFloating(vfloating[0]);
+		_d2.setFloating(vfloating[1]);
+		_d3.setFloating(vfloating[2]);
+		_d4.setFloating(vfloating[3]);
+
+		onSizeChanged();
+	}
+
+    public void setAnchorCorners(Integer left, Integer right, Integer top, Integer bottom)
+    {
+    	setAnchorLeft(left);
+    	setAnchorRight(right);
+    	setAnchorTop(top);
+    	setAnchorBottom(bottom);
+    }
+    
+
+	public void setPosition(int x, int y)
+	{
+		if (x == getX() && y == getY()) return;
+
+		// Remember current isFloating() values
+		boolean vfloating[] = new boolean[] { _d1.isFloating(), _d2.isFloating(), _d3.isFloating(), _d4.isFloating() };
+
+		int width = getWidth();
+		int height = getHeight();
+
+		invalidateLink();
+
+		_d1.setFloating(true);
+		_d2.setFloating(true);
+		_d3.setFloating(true);
+		_d4.setFloating(true);
+
+		_d1.setPosition(x, y);
+		_d2.setPosition(x + width, y);
+		_d3.setPosition(x + width, y + height);
+		_d4.setPosition(x, y + height);
+
+		// Restore isFloating() values
+		_d1.setFloating(vfloating[0]);
+		_d2.setFloating(vfloating[1]);
+		_d3.setFloating(vfloating[2]);
+		_d4.setFloating(vfloating[3]);
+
+		invalidateLink();
+
+		onMoved();
+
+	}
+
+	private boolean _settingPositionFlag = false; // used for recursion
+
+	/**
+	 * Updates position of given WidgetCorner to the given (x,y), 
+	 *   and updates related values (connected corners, width and height)
+	 * 
+	 * @param src
+	 * @param x
+	 * @param y
+	 * @return False if need to call super.setPosition
+	 */
+	public boolean setPositions(WidgetCorner src, float x, float y)
+	{
+		if (_settingPositionFlag) return false;
+		
+		_settingPositionFlag = true;
+
+		invalidateLink();
+
+		// Check to see if the widget is fully being picked up
+		boolean isAllPickedUp = (_d1.isFloating() && _d2.isFloating() && _d3.isFloating() && _d4.isFloating());
+
+		// If so, then this will be called one by one ..
+		if (isAllPickedUp) {
+			src.setPosition(x, y);
+		} else {
+
+			float newX = x;
+
+			// Reference:
+			// D1 D2
+			// D3 D4
+
+			//
+			// GUIDE:
+			// d1--l1---d2
+			// |         |
+			// l4 | X | l2
+			// |         |
+			// d4---l3--d3
+			//
+
+			// X Positions
+			if (src == _d1 || src == _d4) {
+
+				// Check min X constraint
+				if (_minWidth >= 0) {
+					if ((_d2.getX() - x) < _minWidth) {
+						newX = _d2.getX() - _minWidth;
+					}
+				}
+				// Check max X constraint
+				if (_maxWidth >= 0) {
+					if ((_d2.getX() - x) > _maxWidth) {
+						newX = _d2.getX() - _maxWidth;
+					}
+				}
+
+				if (!(src == _d4 && _d1.isFloating() && _d4.isFloating()))
+					_d1.setX(newX);
+				if (!(src == _d1 && _d4.isFloating() && _d1.isFloating()))
+					_d4.setX(newX);
+
+			} else if (src == _d2 || src == _d3) {
+
+				// Check min X constraint
+				if (_minWidth >= 0) {
+					if ((x - _d1.getX()) < _minWidth) {
+						newX = _d1.getX() + _minWidth;
+					}
+				}
+				// Check max X constraint
+				if (_maxWidth >= 0) {
+					if ((x - _d1.getX()) > _maxWidth) {
+						newX = _d1.getX() + _maxWidth;
+					}
+				}
+
+				if (!(src == _d3 && _d2.isFloating() && _d3.isFloating()))
+					_d2.setX(newX);
+				if (!(src == _d2 && _d3.isFloating() && _d2.isFloating()))
+					_d3.setX(newX);
+			}
+
+			float newY = y;
+
+			// Y Positions
+			if (src == _d1 || src == _d2) {
+
+				// Check min Y constraint
+				if (_minHeight >= 0) {
+					if ((_d4.getY() - y) < _minHeight) {
+						newY = _d4.getY() - _minHeight;
+					}
+				}
+				// Check max Y constraint
+				if (_maxHeight >= 0) {
+					if ((_d4.getY() - y) > _maxHeight) {
+						newY = _d4.getY() - _maxHeight;
+					}
+				}
+
+				if (!(src == _d2 && _d1.isFloating() && _d2.isFloating()))
+					_d1.setY(newY);
+				if (!(src == _d1 && _d2.isFloating() && _d1.isFloating()))
+					_d2.setY(newY);
+
+			} else if (src == _d3 || src == _d4) {
+
+				// Check min Y constraint
+				if (_minHeight >= 0) {
+					if ((y - _d1.getY()) < _minHeight) {
+						newY = _d1.getY() + _minHeight;
+					}
+				}
+				// Check max Y constraint
+				if (_maxHeight >= 0) {
+					if ((y - _d1.getY()) > _maxHeight) {
+						newY = _d1.getY() + _maxHeight;
+					}
+				}
+
+				if (!(src == _d4 && _d3.isFloating() && _d4.isFloating()))
+					_d3.setY(newY);
+				if (!(src == _d3 && _d4.isFloating() && _d3.isFloating()))
+					_d4.setY(newY);
+			}
+		}
+
+		// Update source text position so position is remembered from loading
+		float newTextX = getX();
+		float newTextY = getY();
+		if (_textRepresentation.getX() != newTextX || _textRepresentation.getY() != newTextY) {
+			_textRepresentation.setPosition(newTextX, newTextY);
+		}
+
+		_settingPositionFlag = false;
+
+		invalidateLink();
+
+		onMoved();
+		onSizeChanged();
+
+		return true;
+	}
+
+	public int getX()
+	{
+		return Math.min(_d1.getX(), _d2.getX());
+	}
+
+	public int getY()
+	{
+		return Math.min(_d1.getY(), _d4.getY());
+	}
+
+	public int getWidth()
+	{
+		return Math.abs(_d2.getX() - _d1.getX());
+	}
+
+	public int getHeight()
+	{
+		return Math.abs(_d4.getY() - _d1.getY());
+	}
+	
+	public Point getPosition()
+	{
+		return new Point(getX(), getY());
+	}
+
+	public Dimension getSize()
+	{
+		return new Dimension(getWidth(), getHeight());
+	}
+	
+	/**
+	 * The order of the items in the list is as specified: _d1 _d2 _d3 _d4 _l1
+	 * _l2 _l3 _l4
+	 * 
+	 * @return All of the Expeditee items that form the boundaries of this
+	 *         widget in an unmodifiable list
+	 */
+	public List<Item> getItems()
+	{
+		return Collections.unmodifiableList(_expediteeItems);
+	}
+
+	public final void onParentStateChanged(ItemParentStateChangedEvent e)
+	{
+		switch (e.getEventType()) {
+			case ItemParentStateChangedEvent.EVENT_TYPE_REMOVED:
+			case ItemParentStateChangedEvent.EVENT_TYPE_REMOVED_VIA_OVERLAY:
+			case ItemParentStateChangedEvent.EVENT_TYPE_HIDDEN:
+				EcosystemManager.removeInteractiveWidget(this);
+				break;
+	
+			case ItemParentStateChangedEvent.EVENT_TYPE_ADDED:
+			case ItemParentStateChangedEvent.EVENT_TYPE_ADDED_VIA_OVERLAY:
+			case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN:
+			case ItemParentStateChangedEvent.EVENT_TYPE_SHOWN_VIA_OVERLAY:
+				EcosystemManager.addInteractiveWidget(this);
+				break;
+		}
+
+		DisplayController.invalidateItem(_d1, getBounds());
+
+		// Forward filtered event to upper classes...
+		onParentStateChanged(e.getEventType());
+	}
+
+	/**
+	 * Override to make use of. Internally this is reported once by all corners,
+	 * but is filtered out so that this method is invoked once per event.
+	 * 
+	 * @param eventType
+	 *            The {@link ItemParentStateChangedEvent#getEventType()} that
+	 *            occured.
+	 * 
+	 */
+	protected void onParentStateChanged(int eventType)
+	{
+	}
+
+	/**
+	 * @return True if at least one corner is floating
+	 */
+	public boolean isFloating()
+	{
+		return _d1.isFloating() || _d2.isFloating() || _d3.isFloating() || _d4.isFloating();
+	}
+
+	public boolean areCornersFullyAnchored()
+	{
+		return _d1.getParent() != null && _d2.getParent() != null && _d3.getParent() != null && _d4.getParent() != null;
+	}
+
+	/**
+	 * 
+	 * @return The current bounds for this widget. Never null.
+	 */
+	public AxisAlignedBoxBounds getBounds()
+	{
+		return new AxisAlignedBoxBounds(getX(), getY(), getWidth(), getHeight());
+	}
+
+	protected void paintLink()
+	{
+		// If this widget is linked .. then draw the link icon
+		if (_textRepresentation.getLink() != null || _textRepresentation.hasAction()) {
+			_textRepresentation.paintLinkGraphic(getLinkX(), getLinkY());
+		}
+
+	}
+
+	private int getLinkX()
+	{
+		return getX() - Item.LEFT_MARGIN;
+	}
+
+	private int getLinkY()
+	{
+		return getY() + (getHeight() / 2);
+	}
+
+	/** Invoked whenever the widget is to be repainted in free space. */
+	protected void paintInFreeSpace()
+	{
+		GraphicsManager g = EcosystemManager.getGraphicsManager();
+		g.drawRectangle(new Point(getX(), getY()), new Dimension(getWidth(), getHeight()), 0.0, new Fill(FREESPACE_BACKCOLOR), null, null, null);
+	}
+	
+	public final void paint()
+	{
+		paintWidget();
+		paintLink();
+	}
+	
+	/** Should be overridden by native widgets to draw themselves. */
+	protected abstract void paintWidget();
+
+	/**
+	 * Called from the widgets corners: Whenever one of the corners are invoked
+	 * for a refill of the enclosed area.
+	 * 
+	 * If the widget is floating (e.g. currently picked up / rubberbanding) then
+	 * a shaded area is drawn instead of the actual widget so the manipulation
+	 * of the widget is as smooth as possible.
+	 * 
+	 * @param g
+	 * @param notifier
+	 */
+	void paintFill()
+	{
+		//if (_swingComponent.getParent() == null) {
+			// Note that frames with @f may want to paint the widgets so do not
+			// paint over the widget interface in these cases: must only
+			// paint if an object is floating
+			if (isFloating()) {
+				paintInFreeSpace();
+				paintLink();
+			}
+		//}
+	}
+
+	/**
+	 * @return True if this widget cannot be resized in either directions
+	 */
+	public boolean isFixedSize()
+	{
+		return this._minHeight == this._maxHeight &&
+				this._minWidth == this._maxWidth &&
+				this._minHeight >= 0 &&
+				this._minWidth >= 0;
+	}
+
+	/**
+	 * Removes this widget from the parent frame or free space.
+	 * 
+	 * @return True if removed from a parent frame. Thus a parent changed event
+	 *         will be invoked.
+	 * 
+	 * False if removed purely from free space.
+	 */
+	protected boolean removeSelf()
+	{
+		Frame parent = getParentFrame();
+
+		if (parent != null) {
+			parent.removeAllItems(_expediteeItems);
+		}
+
+		FreeItems.getInstance().removeAll(_expediteeItems);
+
+		return (parent != null);
+	}
+
+	/**
+	 * @return The parent frame. Null if has none. Note: Based on corners
+	 *         parents.
+	 */
+	public Frame getParentFrame()
+	{
+		Frame parent = null;
+		if (_d1.getParent() != null) {
+			parent = _d1.getParent();
+		} else if (_d2.getParent() != null) {
+			parent = _d2.getParent();
+		} else if (_d3.getParent() != null) {
+			parent = _d3.getParent();
+		} else if (_d4.getParent() != null) {
+			parent = _d4.getParent();
+		}
+		
+		return parent;
+	}
+
+	protected void invalidateSelf()
+	{
+		AxisAlignedBoxBounds dirty = new AxisAlignedBoxBounds(getX(), getY(), getWidth(), getHeight());
+		DisplayController.invalidateArea(dirty);
+		invalidateLink();
+	}
+
+	/**
+	 * Invalidates the link for this widget - if it has one.
+	 */
+	protected void invalidateLink()
+	{
+		if (_textRepresentation.getLink() != null || _textRepresentation.hasAction()) {
+			AxisAlignedBoxBounds linkArea = _textRepresentation.getLinkDrawArea(getLinkX(), getLinkY());
+			DisplayController.invalidateArea(linkArea);
+		}
+	}
+
+	/**
+	 * @see ItemUtils#isVisible(Item)
+	 * 
+	 * @return True if this widget is visible from the current frame. Considers
+	 *         overlays and vectors.
+	 * 
+	 */
+	public boolean isVisible()
+	{
+		return ItemUtils.isVisible(_d1);
+	}
+
+	/**
+	 * Invoked whenever the widget have moved. Can override.
+	 * 
+	 */
+	protected abstract void onMoved();
+
+	/**
+	 * Invoked whenever the widget have moved. Can override.
+	 * 
+	 */
+	protected abstract void onSizeChanged();
+
+	/**
+	 * Override to have a custom min border thickness for your widget.
+	 * 
+	 * @see #DEFAULT_MINIMUM_BORDER_THICKNESS
+	 * 
+	 * @return The minimum border thickness. Should be larger or equal to zero.
+	 * 
+	 */
+	public float getMinimumBorderThickness()
+	{
+		return DEFAULT_MINIMUM_BORDER_THICKNESS;
+	}
+
+	/**
+	 * Looks fors a dataline in the current representation of the widget.
+	 * 
+	 * @see #getCurrentRepresentation
+	 * @see #getStrippedDataInt(String, int)
+	 * @see #getStrippedDataLong(String, long)
+	 * 
+	 * @param tag
+	 *            The prefix of a dataline that will be matched. Must be larger
+	 *            than zero and not null.
+	 * 
+	 * @return The <i>first</i> dataline that matched the prefix - without the
+	 *         prefix. Null if their was no data that matched the given prefix.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If tag is null.
+	 * 
+	 * @throws NullPointerException
+	 *             If tag is empty.
+	 */
+	protected String getStrippedDataString(String tag)
+	{
+		if (tag == null) throw new NullPointerException("tag");
+		if (tag.length() == 0) throw new IllegalArgumentException("tag is empty");
+
+		if (getCurrentRepresentation().getData() != null) {
+			for (String str : getCurrentRepresentation().getData()) {
+				if (str != null && str.startsWith(tag) && str.length() > tag.length()) {
+					return str.substring(tag.length());
+				}
+			}
+		}
+		return null;
+	}
+
+	/**
+	 * Looks fors a dataline in the current representation of the widget.
+	 * 
+	 * @see #getCurrentRepresentation
+	 * @see #getStrippedDataString(String)
+	 * @see #getStrippedDataLong(String, long)
+	 * 
+	 * @param tag
+	 *            The prefix of a dataline that will be matched. Must be larger
+	 *            the zero and not null.
+	 * 
+	 * @param defaultValue
+	 *            The default value if the tag does not exist or contains
+	 *            invalid data.
+	 * 
+	 * @return The <i>first</i> dataline that matched the prefix - parsed as an
+	 *         int (after the prefix). defaultValue if their was no data that
+	 *         matched the given prefix or the data was invalid.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If tag is null.
+	 * 
+	 * @throws NullPointerException
+	 *             If tag is empty.
+	 * 
+	 */
+	protected Integer getStrippedDataInt(String tag, Integer defaultValue)
+	{
+		String strippedStr = getStrippedDataString(tag);
+
+		if (strippedStr != null) {
+			strippedStr = strippedStr.trim();
+			if (strippedStr.length() > 0) {
+				try {
+					return Integer.parseInt(strippedStr);
+				} catch (NumberFormatException e) { /* Consume */
+				}
+			}
+		}
+
+		return defaultValue;
+	}
+	
+	
+
+	/**
+	 * Looks for a dataline in the current representation of the widget.
+	 * 
+	 * @see #getCurrentRepresentation
+	 * @see #getStrippedDataString(String)
+	 * @see #getStrippedDataInt(String, int)
+	 * 
+	 * @param tag
+	 *            The prefix of a dataline that will be matched. Must be larger
+	 *            the zero and not null.
+	 * 
+	 * @param defaultValue
+	 *            The default value if the tag does not exist or contains
+	 *            invalid data.
+	 * 
+	 * @return The <i>first</i> dataline that matched the prefix - parsed as a
+	 *         long (after the prefix). defaultValue if their was no data that
+	 *         matched the given prefix or the data was invalid.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If tag is null.
+	 * 
+	 * @throws NullPointerException
+	 *             If tag is empty.
+	 * 
+	 */
+	protected Long getStrippedDataLong(String tag, Long defaultValue)
+	{
+		String strippedStr = getStrippedDataString(tag);
+
+		if (strippedStr != null) {
+			strippedStr = strippedStr.trim();
+			if (strippedStr.length() > 0) {
+				try {
+					return Long.parseLong(strippedStr);
+				} catch (NumberFormatException e) { /* Consume */
+				}
+			}
+		}
+
+		return defaultValue;
+	}
+
+	/**
+	 * Looks for a data-line in the current representation of the widget.
+	 * 
+	 * @see #getCurrentRepresentation
+	 * @see #getStrippedDataString(String)
+	 * @see #getStrippedDataLong(String, long)
+	 * 
+	 * @param tag
+	 *            The prefix of a data-line that will be matched. Must be larger
+	 *            the zero and not null.
+	 * 
+	 * @param defaultValue
+	 *            The default value if the tag does not exist or contains
+	 *            invalid data.
+	 * 
+	 * @return The <i>first</i> data-line that matched the prefix - if
+	 *         case insensitive match is 'true' then return true, otherwise
+	 *         false. defaultValue if their was no data that
+	 *         matched the given prefix or the data was invalid.
+	 *         
+	 * @throws IllegalArgumentException
+	 *             If tag is null.
+	 * 
+	 * @throws NullPointerException
+	 *             If tag is empty.
+	 * 
+	 */
+	protected Boolean getStrippedDataBool(String tag, Boolean defaultValue) {
+
+		String strippedStr = getStrippedDataString(tag);
+
+		if (strippedStr != null) {
+			strippedStr = strippedStr.trim();
+			if (strippedStr.length() > 0) {
+				return strippedStr.equalsIgnoreCase("true") ? true : false;
+			}
+		}
+
+		return defaultValue;
+	}
+	
+	
+	/**
+	 * All data is removed that is prefixed with the given tag.
+	 * 
+	 * @param tag
+	 *            The prefix of the data lines to remove. Must be larger the
+	 *            zero and not null.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If tag is null.
+	 * 
+	 * @throws NullPointerException
+	 *             If tag is empty.
+	 * 
+	 */
+	protected void removeData(String tag)
+	{
+		updateData(tag, null);
+	}
+
+	// TODO: Ambiguous name. Refactor. cts16
+	protected void addDataIfCaseInsensitiveNotExists(String tag)
+	{
+		if (tag == null) throw new NullPointerException("tag");
+		
+		List<String> data = getCurrentRepresentation().getData();
+		
+		if (data == null) {
+			data = new LinkedList<String>();
+		}
+		
+		for (String s : data) {
+			if (s != null && s.equalsIgnoreCase(tag)) {
+				return;
+			}
+		}
+		
+		data.add(tag);
+		getCurrentRepresentation().setData(data);
+	}
+
+	
+	/**
+	 * Updates the data with a given tag. All data is removed that is prefixed
+	 * with the given tag. Then a new line is added (if not null).
+	 * 
+	 * Note that passing newData with null is the equivelant of removing tag
+	 * lines.
+	 * 
+	 * @param tag
+	 *            The prefix of the data lines to remove. Must be larger the
+	 *            zero and not null.
+	 * 
+	 * @param newData
+	 *            The new line to add. Can be null - for not adding anything.
+	 * 
+	 * @throws IllegalArgumentException
+	 *             If tag is null.
+	 * 
+	 * @throws NullPointerException
+	 *             If tag is empty.
+	 * 
+	 * @see #removeData(String)
+	 * 
+	 */
+	protected void updateData(String tag, String newData)
+	{
+		if (tag == null)
+			throw new NullPointerException("tag");
+		else if (tag.length() == 0)
+			throw new IllegalArgumentException("tag is empty");
+
+		// Get current data
+		List<String> data = getCurrentRepresentation().getData();
+
+		if (data != null) {
+			for (int i = 0; i < data.size(); i++) {
+				String str = data.get(i);
+				if (str != null && str.startsWith(tag)) {
+					data.remove(i);
+				}
+			}
+		}
+
+		if (newData != null) {
+			if (data != null)
+				data.add(newData);
+			else {
+				data = new LinkedList<String>();
+				data.add(newData);
+				getCurrentRepresentation().setData(data);
+
+			}
+		}
+	}
+	
+	public boolean containsData(String str) {
+		assert(str != null);
+		if (getCurrentRepresentation().getData() != null) 
+			return getCurrentRepresentation().getData().contains(str);
+		return false;
+	}
+	
+	public boolean containsDataTrimmedIgnoreCase(String str) {
+		assert(str != null);
+		if (getCurrentRepresentation().getData() != null) {
+			for (String data : getCurrentRepresentation().getData()) {
+				if (data != null && data.trim().equalsIgnoreCase(str)) {
+					return true;
+				}
+			}
+		}
+			
+		return false;
+	}
+
+	/**
+	 * Sets the link for this widget.
+	 * 
+	 * @param link
+	 *          The new frame link. Can be null (for no link)
+	 * 
+	 * @param linker
+	 * 			The text item creating the link. Null if not created from
+	 * 			a text item.
+	 */
+	public void setLink(String link, Text linker)
+	{
+		// Make sure the link is redrawn when a link is added
+		if (link == null) invalidateLink();
+		getSource().setLink(link);
+		if (link != null) invalidateLink();
+	}
+
+	public void setBackgroundColor(Colour c)
+	{
+		getSource().setBackgroundColor(c);
+	}
+
+	/**
+	 * @return The link for this widget. Null if none.
+	 */
+	public String getLink()
+	{
+		return _textRepresentation.getLink();
+	}
+
+	/**
+	 * <b>Note:</b> That if the widget has no parent (e.g. the widget is a
+	 * free-item) then the absolute link returned will be for the frameset of
+	 * the current frame.
+	 * 
+	 * @return The absolute link for this item. Null if there is no link, or if
+	 *         there is no parent for this widget and the current frame is
+	 *         unavailable.
+	 * 
+	 */
+	public String getAbsoluteLink()
+	{
+		// Note: cannot return the source absolute link since it does not have
+		// a parent ... thus must manually format link
+
+		String link = getLink();
+
+		if (link == null || link.length() == 0)
+			return null;
+
+		if (FrameIO.isPositiveInteger(link)) { // relative - convert to
+												// absolute
+
+			// Get the frameset of this item
+			Frame parent = getParentFrame();
+			if (parent == null)
+				parent = DisplayController.getCurrentFrame();
+			if (parent == null)
+				return null;
+
+			String framesetName = parent.getFramesetName();
+
+			if (framesetName == null)
+				return null;
+
+			return framesetName + link;
+
+		} else if (FrameIO.isValidFrameName(link)) { // already absolute
+			return link;
+		}
+
+		return null;
+	}
+	
+	/**
+	 * Sets the border color for the widget.
+	 * That is, for the source (so it is remembered) and also for all the
+	 * corners/edges.
+	 * 
+	 * @param c
+	 * 		The color to set.
+	 */
+	public void setWidgetEdgeColor(Colour c)
+	{
+		// Indirectly invokes setSourceBorderColor accordingly
+		for (Item i : _expediteeItems) i.setColor(c);
+	}
+	
+	/**
+	 * Sets the thickness of the widget edge.
+	 * 
+	 * @see Item#setThickness(float)
+	 * 
+	 * @param thickness
+	 * 		The new thickness to set.
+	 */
+	public void setWidgetEdgeThickness(float thickness) {
+		_l1.setThickness(thickness, true);
+		//for (Item i : _expediteeItems) i.setThickness(thickness);
+//		 Above indirectly invokes setSourceThickness accordingly
+	}
+	
+	/**
+	 * Override to dis-allow widget thickness manipulation from the user.
+	 * @return
+	 */
+	public boolean isWidgetEdgeThicknessAdjustable() {
+		return true;
+	}
+
+	// TODO: Maybe rename setSource* ..  to update* ... These should actually be friendly!
+	public void setSourceColor(Colour c) {
+		_textRepresentation.setColor(c);
+	}
+
+	public void setSourceBorderColor(Colour c) {
+		_textRepresentation.setBorderColor(c);
+	}
+
+	public void setSourceFillColor(Colour c) {
+		_textRepresentation.setFillColor(c);
+	}
+
+	public void setSourceThickness(float newThickness, boolean setConnected) {
+ 		_textRepresentation.setThickness(newThickness, setConnected);
+	}
+
+	public void setSourceData(List<String> data) {
+		_textRepresentation.setData(data);
+	}
+
+	protected Point getOrigin() {
+		return _d1.getPosition(); // NOTE FROM BROOK: This flips around ... the origin can be any point 
+	}
+
+	protected Item getFirstCorner() {
+		return _d1;
+	}
+
+	public void setAnchorLeft(Integer anchor)
+	{
+		_anchoring.setLeftAnchor(anchor);
+		// Anchor left-edge corners (dots) as well
+		_d1.setAnchorCornerX(anchor,null); 
+		_d4.setAnchorCornerX(anchor,null); 
+
+		if (anchor != null) {
+		    setPositions(_d1, anchor, _d1.getY());
+		    invalidateSelf();
+		}
+		
+		// Move X-rayable item as well
+		getCurrentRepresentation().setAnchorLeft(anchor);
+	}
+
+	public void setAnchorRight(Integer anchor) {
+		_anchoring.setRightAnchor(anchor);
+		// Anchor right-edge corners (dots) as well
+		_d2.setAnchorCornerX(null,anchor); // right
+		_d3.setAnchorCornerX(null,anchor); // right
+
+		if (anchor != null) {
+			setPositions(_d2, DisplayController.getFramePaintArea().getWidth() - anchor, _d2.getY());
+			invalidateSelf();
+		}
+		
+		if (_anchoring.getLeftAnchor() == null) {
+			// Prefer having the X-rayable item at anchorLeft position (if defined) over moving to anchorRight
+			getCurrentRepresentation().setAnchorRight(anchor);
+		}
+	}
+	
+	public void setAnchorTop(Integer anchor) {
+		_anchoring.setTopAnchor(anchor);
+		// Anchor top-edge corners (dots) as well
+		_d1.setAnchorCornerY(anchor,null);
+		_d2.setAnchorCornerY(anchor,null); 
+		
+		if (anchor != null) {
+		    setPositions(_d2, _d2.getX(), anchor);
+		    invalidateSelf();
+		}
+    	
+		// Move X-rayable item as well
+		getCurrentRepresentation().setAnchorTop(anchor);
+	}
+
+	public void setAnchorBottom(Integer anchor) {
+		_anchoring.setBottomAnchor(anchor);
+		// Anchor bottom-edge corners (dots) as well
+		_d3.setAnchorCornerY(null,anchor); 
+		_d4.setAnchorCornerY(null,anchor); 
+		
+		if (anchor != null) {
+		    setPositions(_d3, _d3.getX(), DisplayController.getFramePaintArea().getHeight()  - anchor);
+		    invalidateSelf();
+		}
+		
+		if (_anchoring.getTopAnchor() == null) {
+		    // Prefer having the X-rayable item at anchorTop position (if defined) over moving to anchorBottom
+			getCurrentRepresentation().setAnchorBottom(anchor);
+		}
+	}
+
+
+	public boolean isAnchored() {
+	    return (isAnchoredX()) || (isAnchoredY());
+	}
+
+	public boolean isAnchoredX() {
+		return _anchoring.isXAnchored();
+	}
+
+	public boolean isAnchoredY() {
+		return _anchoring.isYAnchored();
+	}
+	
+	/**
+	 * Call from expeditee for representing the name of the item.
+	 * Override to return custom name.
+	 * 
+	 * Note: Used for the new frame title when creating links for widgets.
+	 * 
+	 * @return
+	 * 		The name representing this widget
+	 */
+	public String getName() {
+		return this.toString();
+	}
+	
+	/**
+	 * Event called when the widget is left clicked while there are items attached to the FreeItems buffer.
+	 * Used to enable expeditee like text-widget interaction for left mouse clicks.
+	 * @return true if event was handled (no pass through), otherwise false.
+	 */
+	public boolean ItemsLeftClickDropped() {
+		return false;
+	}
+	
+	/**
+	 * Event called when the widget is middle clicked while there are items attached to the FreeItems buffer.
+	 * Used to enable expeditee like text-widget interaction for middle mouse clicks.
+	 * @return true if event was handled (no pass through), otherwise false.
+	 */
+	public boolean ItemsMiddleClickDropped() {
+		return false;
+	}
+	
+	/**
+	 * Event called when the widget is left clicked while there are items attached to the FreeItems buffer.
+	 * Used to enable expeditee like text-widget interaction for right mouse clicks
+	 * @return true if event was handled (no pass through), otherwise false.
+	 */
+	public boolean ItemsRightClickDropped() {
+		return false;
+	}
+	
+	/** Gets the clip area for this widget. */
+	public Clip getClip()
+	{
+		Clip clip = new Clip(getBounds());
+		return clip;
+	}
+}
