primitive methods for getting current undo/redo state and comparing with another...
authorjprocter <Jim Procter>
Tue, 25 Sep 2007 09:28:38 +0000 (09:28 +0000)
committerjprocter <Jim Procter>
Tue, 25 Sep 2007 09:28:38 +0000 (09:28 +0000)
src/jalview/gui/AlignViewport.java

index eb5ef20..41341d0 100755 (executable)
@@ -1871,6 +1871,38 @@ public class AlignViewport
       viscontigs = colSel.getVisibleContigs(start, end);
       return viscontigs;
     }
-
-
+    /**
+     * get hash of undo and redo list for the alignment
+     * @return long[] { historyList.hashCode, redoList.hashCode };
+     */
+    public long[] getUndoRedoHash()
+    {
+      if (historyList==null || redoList==null)
+        return new long[] { -1, -1};
+      return new long[] { historyList.hashCode(), this.redoList.hashCode() };
+    }
+    /**
+     * test if a particular set of hashcodes are different to the hashcodes for the undo and redo list.
+     * @param undoredo the stored set of hashcodes as returned by getUndoRedoHash
+     * @return true if the hashcodes differ (ie the alignment has been edited) or the stored hashcode array differs in size
+     */
+    public boolean isUndoRedoHashModified(long[] undoredo)
+    {
+      if (undoredo==null)
+      {
+        return true;
+      }
+      long[] cstate = getUndoRedoHash();
+      if (cstate.length!=undoredo.length)
+      {  return true; }
+      
+      for (int i=0; i<cstate.length; i++)
+      {
+        if (cstate[i]!=undoredo[i])
+        {
+          return true;
+        }
+      }
+      return false;
+    }
 }