1 18 package org.apache.batik.apps.svgbrowser; 19 20 import java.awt.geom.AffineTransform ; 21 import java.util.ArrayList ; 22 import java.util.List ; 23 24 30 public class TransformHistory { 31 32 35 protected List transforms = new ArrayList (); 36 37 40 protected int position = -1; 41 42 46 public void back() { 47 position -= 2; 48 } 49 50 53 public boolean canGoBack() { 54 return position > 0; 55 } 56 57 61 public void forward() { 62 } 63 64 67 public boolean canGoForward() { 68 return position < transforms.size() - 1; 69 } 70 71 74 public AffineTransform currentTransform() { 75 return (AffineTransform )transforms.get(position + 1); 76 } 77 78 81 public void update(AffineTransform at) { 82 if (position < -1) { 83 position = -1; 84 } 85 if (++position < transforms.size()) { 86 if (!transforms.get(position).equals(at)) { 87 transforms = transforms.subList(0, position + 1); 88 } 89 transforms.set(position, at); 90 } else { 91 transforms.add(at); 92 } 93 } 94 } 95 | Popular Tags |