Explorar o código

trying to add fast forwards and resetting of canvas when starting partway through. right now, going back then forwards again doesn't work properly. lines aren't redrawn from the last thing to be erased, but the first i believe

tsdedhar %!s(int64=6) %!d(string=hai) anos
pai
achega
3ee7bedaa3

BIN=BIN
assignments/a2/.gradle/4.7/fileHashes/fileHashes.bin


BIN=BIN
assignments/a2/.gradle/4.7/fileHashes/fileHashes.lock


BIN=BIN
assignments/a2/.gradle/4.7/taskHistory/taskHistory.bin


BIN=BIN
assignments/a2/.gradle/4.7/taskHistory/taskHistory.lock


BIN=BIN
assignments/a2/.gradle/buildOutputCleanup/buildOutputCleanup.lock


BIN=BIN
assignments/a2/build/classes/java/main/Model.class


BIN=BIN
assignments/a2/build/classes/java/main/Thingy.class


BIN=BIN
assignments/a2/build/libs/a2-1.0-SNAPSHOT.jar


+ 21 - 0
assignments/a2/src/main/java/Model.java

@@ -31,6 +31,22 @@ public class Model extends Observable
   
   public void newThingy(int x, int y)
   {
+    if (totalLen != totalVisibleLen)
+    {
+      // resize curthingy to it's visible length
+      ArrayList<Point> temp = (ArrayList<Point>)curThingy.getPoints().subList(0, curThingy.getVisibleLen());
+      curThingy.setPoints(temp);
+      //curThingy.points.addAll(temp);
+      // reset total length to total visible length
+      totalLen = totalVisibleLen;
+      // delete extra nodes in thingies
+      int start = thingies.indexOf(curThingy);
+      for (int i = start + 1; i < thingies.size(); i++)
+      {
+        thingies.remove(i);
+      }
+    }
+
     curThingy = new Thingy(curColour, curThiccness);
     thingies.add(curThingy);
     curThingy.addPoint(x, y);
@@ -181,6 +197,11 @@ class Thingy
   {
     return points;
   }
+
+  public void setPoints(ArrayList a)
+  {
+    points = a;
+  }
   
   public Color getColour()
   {