Index: trunk/src/org/expeditee/io/flowlayout/XGroupItem.java
===================================================================
--- trunk/src/org/expeditee/io/flowlayout/XGroupItem.java	(revision 976)
+++ trunk/src/org/expeditee/io/flowlayout/XGroupItem.java	(revision 1102)
@@ -19,7 +19,4 @@
 package org.expeditee.io.flowlayout;
 
-import java.awt.Point;
-import java.awt.Polygon;
-import java.awt.Rectangle;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -31,4 +28,7 @@
 import java.util.List;
 
+import org.expeditee.core.Point;
+import org.expeditee.core.bounds.AxisAlignedBoxBounds;
+import org.expeditee.core.bounds.PolygonBounds;
 import org.expeditee.gui.Frame;
 import org.expeditee.gui.FrameUtils;
@@ -110,6 +110,5 @@
 	}
 
-	public XGroupItem(Frame frame, List<Item> y_ordered_items,
-			Polygon enclosing_polygon) {
+	public XGroupItem(Frame frame, List<Item> y_ordered_items, PolygonBounds enclosing_polygon) {
 		this.frame = frame;
 		this.out_of_flow = FlowType.in_flow;
@@ -124,5 +123,5 @@
 		}
 
-		Rectangle enclosing_bounding_rect = enclosing_polygon.getBounds();
+		AxisAlignedBoxBounds enclosing_bounding_rect = AxisAlignedBoxBounds.getEnclosing(enclosing_polygon);
 		initSpanArray(enclosing_bounding_rect);
 
@@ -134,6 +133,5 @@
 		remaining_item_list = new ArrayList<Item>();
 
-		separateYOverlappingItems(frame, y_ordered_items, enclosing_polygon,
-				raw_text_item_list, grouped_item_list, remaining_item_list);
+		separateYOverlappingItems(frame, y_ordered_items, enclosing_polygon, raw_text_item_list, grouped_item_list, remaining_item_list);
 
 		// Step 2: Add in the raw-text items
@@ -161,5 +159,6 @@
 	}
 
-	protected XGroupItem(XGroupItem imprint, Rectangle copy_to_bounding_rect) {
+	protected XGroupItem(XGroupItem imprint, AxisAlignedBoxBounds copy_to_bounding_rect)
+	{
 		super();
 
@@ -192,5 +191,5 @@
 												// straight away?
 
-		this.bounding_rect = new Rectangle(copy_to_bounding_rect); // deep copy
+		this.bounding_rect = new AxisAlignedBoxBounds(copy_to_bounding_rect); // deep copy
 																	// to be on
 																	// the safe
@@ -198,5 +197,5 @@
 	}
 
-	protected void initSpanArray(Rectangle bounding_rect) {
+	protected void initSpanArray(AxisAlignedBoxBounds bounding_rect) {
 		this.bounding_rect = bounding_rect;
 
@@ -533,6 +532,5 @@
 							// to make it appear where the start of the arrow is
 
-							Rectangle start_rect = start_item.getArea()
-									.getBounds();
+							AxisAlignedBoxBounds start_rect = start_item.getBoundingBox();
 
 							XGroupItem xgroup_item_shallow_copy = new XGroupItem(
@@ -630,6 +628,6 @@
 	 * @return
 	 */
-	public Collection<Item> getItemsInNestedEnclosure(Item given_item,
-			AreaPolygon outer_polygon) {
+	public Collection<Item> getItemsInNestedEnclosure(Item given_item, PolygonBounds outer_polygon)
+	{
 		Collection<Item> sameEnclosure = null;
 		Collection<Item> seen = new HashSet<Item>();
@@ -649,5 +647,5 @@
 				seen.addAll(i_enclosing_dots);
 
-				Polygon i_polygon = new Polygon();
+				PolygonBounds i_polygon = new PolygonBounds();
 				for (int di = 0; di < i_enclosing_dots.size(); di++) {
 					Item d = i_enclosing_dots.get(di);
@@ -684,5 +682,5 @@
 
 	public void separateYOverlappingItems(Frame frame, List<Item> item_list,
-			Polygon enclosing_polygon, List<Text> raw_text_item_list,
+			PolygonBounds enclosing_polygon, List<Text> raw_text_item_list,
 			List<XGroupItem> grouped_item_list, List<Item> remaining_item_list) {
 		final List<Item> origonal_item_list = new ArrayList<Item>(item_list);
@@ -692,7 +690,7 @@
 		// of lines/polylines/polygons
 
-		AreaPolygon area_enclosing_polygon = new AreaPolygon(enclosing_polygon);
-
-		List<AreaPolygon> area_enclosed_polygon_list = new ArrayList<AreaPolygon>();
+		PolygonBounds area_enclosing_polygon = new PolygonBounds(enclosing_polygon);
+
+		List<PolygonBounds> area_enclosed_polygon_list = new ArrayList<PolygonBounds>();
 
 		while (item_list.size() > 0) {
@@ -724,6 +722,5 @@
 								.remove(0); // shift
 
-						Polygon enclosed_polygon = enclosure_item
-								.getEnclosedShape();
+						PolygonBounds enclosed_polygon = enclosure_item.getEnclosedShape();
 
 						if (enclosed_polygon != null) {
@@ -739,8 +736,6 @@
 							// group)
 
-							AreaPolygon area_enclosed_polygon = new AreaPolygon(
-									enclosed_polygon);
-							area_enclosed_polygon_list
-									.add(area_enclosed_polygon);
+							PolygonBounds area_enclosed_polygon = new PolygonBounds(enclosed_polygon);
+							area_enclosed_polygon_list.add(area_enclosed_polygon);
 
 							item_list.remove(enclosure_item);
@@ -763,10 +758,7 @@
 							while (item_iterator.hasNext()) {
 								Item item_to_check = item_iterator.next();
-								Point pt_to_check = new Point(
-										item_to_check.getX(),
-										item_to_check.getY());
-
-								if (area_enclosed_polygon
-										.isPerimeterPoint(pt_to_check)) {
+								Point pt_to_check = new Point(item_to_check.getX(), item_to_check.getY());
+
+								if (area_enclosed_polygon.isVertex(pt_to_check)) {
 									items_on_perimeter.add(item_to_check);
 								}
@@ -801,7 +793,7 @@
 		// Sort areas, smallest to largest
 		Collections.sort(area_enclosed_polygon_list,
-				new Comparator<AreaPolygon>() {
-
-					public int compare(AreaPolygon ap1, AreaPolygon ap2) {
+				new Comparator<PolygonBounds>() {
+
+					public int compare(PolygonBounds ap1, PolygonBounds ap2) {
 						Double ap1_area = ap1.getArea();
 						Double ap2_area = ap2.getArea();
@@ -817,9 +809,9 @@
 			// ri = remove index pos
 
-			AreaPolygon rpoly = area_enclosed_polygon_list.get(ri);
+			PolygonBounds rpoly = area_enclosed_polygon_list.get(ri);
 
 			for (int ci = ri + 1; ci < area_enclosed_polygon_list.size(); ci++) {
 				// ci = check index pos
-				AreaPolygon cpoly = area_enclosed_polygon_list.get(ci);
+				PolygonBounds cpoly = area_enclosed_polygon_list.get(ci);
 				if (rpoly.completelyContains(cpoly)) {
 					area_enclosed_polygon_list.remove(ci);
@@ -837,8 +829,7 @@
 		// recursive call below
 
-		for (AreaPolygon area_polygon : area_enclosed_polygon_list) {
-
-			Collection<Item> enclosed_items = FrameUtils.getItemsEnclosedBy(
-					frame, area_polygon);
+		for (PolygonBounds area_polygon : area_enclosed_polygon_list) {
+
+			Collection<Item> enclosed_items = FrameUtils.getItemsEnclosedBy(frame, area_polygon);
 			List<Item> enclosed_item_list = new ArrayList<Item>(enclosed_items);
 
@@ -849,5 +840,5 @@
 				// Filter out enclosed-items points that are part of the
 				// polygon's perimeter
-				if (area_polygon.isPerimeterPoint(enclosed_item.getPosition())) {
+				if (area_polygon.isVertex(enclosed_item.getPosition())) {
 					enclosed_item_list.remove(i);
 					// Don't include items the user hasn't asked us to.
@@ -863,6 +854,5 @@
 			// Recursively work on the identified sub-group
 
-			XGroupItem xgroup_item = new XGroupItem(frame, enclosed_item_list,
-					area_polygon);
+			XGroupItem xgroup_item = new XGroupItem(frame, enclosed_item_list, area_polygon);
 
 			grouped_item_list.add(xgroup_item);
