Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ConstructorTool.java, 1.1, 1.2 Abstra
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-07-17 09:08:46
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv4883/src/net/sourceforge/bprocessor/gl/tool Modified Files: ConstructorTool.java AbstractPencil.java Log Message: ConstructorTool now also creates vectors Index: ConstructorTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ConstructorTool.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ConstructorTool.java 6 Jul 2006 13:13:50 -0000 1.1 --- ConstructorTool.java 17 Jul 2006 09:08:42 -0000 1.2 *************** *** 10,15 **** --- 10,20 ---- import java.awt.Cursor; import java.awt.event.MouseEvent; + import java.util.LinkedList; + import java.util.List; import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gl.model.Intersection; + import net.sourceforge.bprocessor.model.Edge; + import net.sourceforge.bprocessor.model.Line; import net.sourceforge.bprocessor.model.Point; import net.sourceforge.bprocessor.model.Project; *************** *** 21,24 **** --- 26,41 ---- public class ConstructorTool extends AbstractPencil { + /** P1 */ + private Intersection p1; + + /** P2 */ + private Intersection p2; + + /** P3 */ + private Intersection p3; + + /** P4 */ + private Intersection p4; + /** * Constructor for ConstructorTool *************** *** 41,44 **** --- 58,99 ---- /** + * Insert a line defined by p1 and p2 + * @param p1 Vertex + * @param p2 Vertex + */ + protected void insertLine(Vertex p1, Vertex p2) { + Line line = new Line(p1, p2.minus(p1)); + Project.getInstance().getActiveSpace().add(line); + Project.getInstance().changed(Project.getInstance()); + } + + /** + * Update Constructors + */ + protected void updateConstructors() { + List constructors = new LinkedList(); + List points = new LinkedList(); + List excluded = new LinkedList(); + if (p1 != null) { + points.add(p1.vertex()); + if (p2 != null) { + Edge edge = new Edge(p1.vertex(), p2.vertex()); + edge.setConstructor(true); + constructors.add(edge); + points.add(p2.vertex()); + } + if (current != null) { + Edge edge = new Edge(p1.vertex(), current.vertex()); + edge.setConstructor(true); + constructors.add(edge); + } + } + excluded.addAll(constructors); + points(points); + constructors(constructors); + excluded(excluded); + } + + /** * @param e MouseEvent */ *************** *** 55,66 **** */ protected void pressed(MouseEvent e) { ! if (start == null) { ! start = current; } else { ! if (start.vertex().equalEps(current.vertex())) { ! insertPoint(current.vertex()); ! start = null; } } } --- 110,131 ---- */ protected void pressed(MouseEvent e) { ! if (p1 == null) { ! p1 = current; } else { ! if (p1.vertex().equalEps(current.vertex())) { ! if (p2 == null) { ! insertPoint(current.vertex()); ! } else { ! insertLine(p1.vertex(), p2.vertex()); ! } ! p1 = null; ! p2 = null; ! } else { ! if (p2 == null) { ! p2 = current; ! } } } + updateConstructors(); } Index: AbstractPencil.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractPencil.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** AbstractPencil.java 10 Jul 2006 15:29:23 -0000 1.37 --- AbstractPencil.java 17 Jul 2006 09:08:42 -0000 1.38 *************** *** 54,57 **** --- 54,60 ---- protected Collection constructors = new HashSet(); + /** Vertices */ + protected Collection points = new HashSet(); + /** The aligning elements */ protected Collection aligners = new HashSet(); *************** *** 336,339 **** --- 339,376 ---- /** + * Show Points + */ + protected void showPoints() { + Iterator iter = points.iterator(); + while (iter.hasNext()) { + Vertex current = (Vertex) iter.next(); + glv.getView().addTempVertex(current); + } + } + + /** + * Hide Points + */ + protected void hidePoints() { + Iterator iter = points.iterator(); + while (iter.hasNext()) { + Vertex current = (Vertex) iter.next(); + glv.getView().removeTempVertex(current); + } + } + + /** + * Supply points + * @param feed Collection of points + */ + protected void points(Collection feed) { + hidePoints(); + points.clear(); + points.addAll(feed); + showPoints(); + } + + + /** * Test if an edge is parrallel with an axiz (x, y or z) * @param edge The edge to test |