[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool FinalMoveTool.java, 1.22, 1.23
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2007-09-07 12:37:43
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29277/src/net/sourceforge/bprocessor/gl/tool Modified Files: FinalMoveTool.java Log Message: Introduced Vector Move Index: FinalMoveTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/FinalMoveTool.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** FinalMoveTool.java 7 Sep 2007 10:52:23 -0000 1.22 --- FinalMoveTool.java 7 Sep 2007 12:37:45 -0000 1.23 *************** *** 45,49 **** private Collection<Vertex> vertices; ! private MoveHandle handle; --- 45,49 ---- private Collection<Vertex> vertices; ! private Mover mover; *************** *** 58,65 **** /** * Move Handle * */ ! public class MoveHandle { private Collection<Vertex> vertices; private Map<Vertex, Vertex> originals; --- 58,120 ---- /** + * Mover interface + * + */ + public interface Mover { + /** + * Move + * @param delta distance + */ + public void move(Vertex delta); + + /** + * Revert + */ + public void revert(); + } + + /** + * Vector Move + * + */ + public class VectorMove implements Mover { + private Collection<Vertex> vertices; + private Map<Vertex, Vertex> originals; + + /** + * VectorMove + * @param vertices Collection of vertices to move + */ + public VectorMove(Collection<Vertex> vertices) { + this.vertices = vertices; + originals = new HashMap(); + for (Vertex current : vertices) { + originals.put(current, current.copy()); + } + } + + /** {@inheritDoc} */ + public void move(Vertex delta) { + for (Vertex current : vertices) { + Vertex original = originals.get(current); + current.set(original.add(delta)); + } + } + + /** {@inheritDoc} */ + public void revert() { + for (Vertex current : vertices) { + Vertex original = originals.get(current); + current.set(original); + } + } + + } + + /** * Move Handle * */ ! public class SlidingMove implements Mover { private Collection<Vertex> vertices; private Map<Vertex, Vertex> originals; *************** *** 119,123 **** * @param vertices Collection of vertices to move */ ! public MoveHandle(Collection<Vertex> vertices) { this.vertices = vertices; originals = new HashMap(); --- 174,178 ---- * @param vertices Collection of vertices to move */ ! public SlidingMove(Collection<Vertex> vertices) { this.vertices = vertices; originals = new HashMap(); *************** *** 129,134 **** } /** ! * Move ! * @param delta Vector distance to move */ public void move(Vertex delta) { --- 184,188 ---- } /** ! * {@inheritDoc} */ public void move(Vertex delta) { *************** *** 157,161 **** /** ! * Revert to original position */ public void revert() { --- 211,215 ---- /** ! * {@inheritDoc} */ public void revert() { *************** *** 191,195 **** private void move(Vertex delta) { ! handle.move(delta); } --- 245,249 ---- private void move(Vertex delta) { ! mover.move(delta); } *************** *** 262,286 **** geometrics = new LinkedList(); if (Selection.primary().isEmpty()) { ! geometrics.add((Geometric) target); } else { geometrics.addAll(Selection.primary()); } ! copy = e.isAltDown(); ! if (copy) { ! mesh = new Mesh(geometrics); ! mesh = mesh.copy(new HashMap()); ! geometrics = mesh.geometrics(); ! Project.getInstance().getActiveSpace().addProtected(geometrics); ! } ! vertices = Geometry.collect(geometrics); ! handle = new MoveHandle(vertices); ! ! affected = getAffected(geometrics); ! current = findIntersection(e); ! start = current.copy(); ! updateFeedback(); ! setTip(secondClickTip()); } else { Geometric geometric = affected.iterator().next(); --- 316,346 ---- geometrics = new LinkedList(); if (Selection.primary().isEmpty()) { ! if (target != null) { ! geometrics.add((Geometric) target); ! } } else { geometrics.addAll(Selection.primary()); } ! if (!geometrics.isEmpty()) { ! copy = e.isAltDown(); ! if (copy) { ! mesh = new Mesh(geometrics); ! mesh = mesh.copy(new HashMap()); ! geometrics = mesh.geometrics(); ! Project.getInstance().getActiveSpace().addProtected(geometrics); ! } ! vertices = Geometry.collect(geometrics); ! mover = new SlidingMove(vertices); ! ! affected = getAffected(geometrics); ! current = findIntersection(e); ! start = current.copy(); ! updateFeedback(); ! setTip(secondClickTip()); ! } else { ! geometrics = null; ! } } else { Geometric geometric = affected.iterator().next(); *************** *** 297,300 **** --- 357,362 ---- moved(e); } + + System.out.println("geometrics = " + geometrics); } *************** *** 337,341 **** public void cleanUp() { if (start != null) { ! handle.revert(); } super.cleanUp(); --- 399,403 ---- public void cleanUp() { if (start != null) { ! mover.revert(); } super.cleanUp(); *************** *** 348,352 **** affected = null; copy = false; ! handle = null; } --- 410,414 ---- affected = null; copy = false; ! mover = null; } |