Procházet zdrojové kódy

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 před 6 roky
rodič
revize
3ee7bedaa3

binární
assignments/a2/.gradle/4.7/fileHashes/fileHashes.bin


binární
assignments/a2/.gradle/4.7/fileHashes/fileHashes.lock


binární
assignments/a2/.gradle/4.7/taskHistory/taskHistory.bin


binární
assignments/a2/.gradle/4.7/taskHistory/taskHistory.lock


binární
assignments/a2/.gradle/buildOutputCleanup/buildOutputCleanup.lock


binární
assignments/a2/build/classes/java/main/Model.class


binární
assignments/a2/build/classes/java/main/Thingy.class


binární
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()
   {