Jelajahi Sumber

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 7 tahun lalu
induk
melakukan
3ee7bedaa3

TEMPAT SAMPAH
assignments/a2/.gradle/4.7/fileHashes/fileHashes.bin


TEMPAT SAMPAH
assignments/a2/.gradle/4.7/fileHashes/fileHashes.lock


TEMPAT SAMPAH
assignments/a2/.gradle/4.7/taskHistory/taskHistory.bin


TEMPAT SAMPAH
assignments/a2/.gradle/4.7/taskHistory/taskHistory.lock


TEMPAT SAMPAH
assignments/a2/.gradle/buildOutputCleanup/buildOutputCleanup.lock


TEMPAT SAMPAH
assignments/a2/build/classes/java/main/Model.class


TEMPAT SAMPAH
assignments/a2/build/classes/java/main/Thingy.class


TEMPAT SAMPAH
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()
   {