/** Trims all steps after endFrame. */ protected void trimSteps() { // return if trimming not needed VideoClip clip = trackerPanel.getPlayer().getVideoClip(); int n = clip.getFrameCount() - 1; int end = getEndFrame() == Integer.MAX_VALUE ? n : getEndFrame(); while (end > getStartFrame() && !clip.includesFrame(end)) { end--; } if (end >= lastValidFrame) return; int trimCount = (tracePtsPerStep * (lastValidFrame - end)) / clip.getStepSize(); ParticleModel[] models = getModels(); for (ParticleModel next : models) { // create smaller trace arrays and copy existing points into them next.locked = false; int traceLength = next.traceX.length - trimCount; if (traceLength < 0) return; // trap for error during closing next.prevX = next.traceX; next.prevY = next.traceY; next.traceX = new double[traceLength]; next.traceY = new double[traceLength]; System.arraycopy(next.prevX, 0, next.traceX, 0, traceLength); System.arraycopy(next.prevY, 0, next.traceY, 0, traceLength); // reduce number of steps next.steps.setLength(end + 1); // refresh derivatives next.updateDerivatives(end - 2, lastValidFrame - end + 2); // restore state restoreState(end); next.support.firePropertyChange("steps", null, null); // $NON-NLS-1$ next.locked = true; } lastValidFrame = end; repaint(); // trackerPanel.repaint(); }