/*
 *    Debrief - the Open Source Maritime Analysis Application
 *    http://debrief.info
 *
 *    (C) 2000-2014, PlanetMayo Ltd
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the Eclipse Public License v1.0
 *    (http://www.eclipse.org/legal/epl-v10.html)
 *
 *    This library 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. 
 */
package Debrief.Wrappers;

import java.awt.Color;

import MWC.GUI.Plottable;
import MWC.GUI.Shapes.PlainShape;
import MWC.GenericData.HiResDate;

public class DynamicShapeWrapper extends ShapeWrapper
{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String _theTrackName;

	public DynamicShapeWrapper(String label, PlainShape theShape, Color theColor,
			HiResDate theDate, String name)
	{
		super(label, theShape, theColor, theDate);
		_theTrackName = name;
	}

	public String getTrackName()
	{
		return _theTrackName;
	}

	public void setTrackName(String theTrackName)
	{
		this._theTrackName = theTrackName;
	}
	
	/** override the default sort order (name), since
	 * we wish to sort by DTG
	 */
	public int compareTo(Plottable o)
	{
		final DynamicShapeWrapper sw = (DynamicShapeWrapper) o;
		return this.getStartDTG().compareTo(sw.getStartDTG());
	}
	

}

@@ -1287,22 +1287,102 @@
 %09%7B%0A%09
-%09
+  
 final 
-Dynamic
+int res;%0A%09  // is this other item a shape?%0A%09  if(o instanceof ShapeWrapper)%0A%09  %7B%0A%09    
 Shap
@@ -1395,20 +1395,16 @@
 er s
-w = (Dynamic
+hape = (
 Shap
@@ -1421,34 +1421,284 @@
 o;%0A%09
-%09return this.getStartDTG()
+    HiResDate myStart = this.getStartDTG();%0A%09    // do I know my date?%0A%09    if(myStart != null)%0A%09    %7B%0A%09      HiResDate hisStart = shape.getStartDTG();%0A%09      %0A%09      // do we know his date?%0A%09      if(hisStart != null)%0A%09      %7B%0A%09        // compare dates%0A%09        res = myStart
 .com
@@ -1705,17 +1705,20 @@
 pareTo(s
-w
+hape
 .getStar
@@ -1726,16 +1726,301 @@
 DTG());%0A
+%09      %7D%0A%09      else%0A%09      %7B%0A%09        // put me first%0A%09        res = -1;%0A%09      %7D%0A%09      %0A%09    %7D%0A%09    else%0A%09    %7B%0A%09      // compare names%0A%09      res = this.getName().compareTo(o.getName());%0A%09    %7D%0A%09  %7D%0A%09  else%0A%09  %7B%0A%09    res = this.getName().compareTo(o.getName());%0A%09  %7D%0A%09%09return res;%0A
 %09%7D%0A%09%0A%0A%7D%0A

Improve quality of compareTo method