Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ArcTool.java,NONE,1.1 Tool.java,1.18,1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-03-14 23:36:33
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3024/src/net/sourceforge/bprocessor/gl/tool Modified Files: Tool.java ToolFactory.java Added Files: ArcTool.java Log Message: Started the arc tool --- NEW FILE: ArcTool.java --- //--------------------------------------------------------------------------------- // $Id: ArcTool.java,v 1.1 2006/03/14 23:36:28 henryml Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gl.tool; import java.awt.Cursor; import java.awt.event.MouseEvent; import java.util.Collection; import java.util.HashSet; import java.util.Iterator; import java.util.LinkedList; import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gl.model.Intersection; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Plane; /** * ArcTool * */ public class ArcTool extends AbstractTool { /** Feedback elements */ private Collection elements = new HashSet(); /** Current intersection */ private Intersection current; /** Start */ private Intersection start; /** End */ private Intersection end; /** * Show feedback */ protected void showFeedback() { Iterator iter = elements.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); glv.getView().addTempEdge(current); } } /** * Hide feedback */ protected void hideFeedback() { Iterator iter = elements.iterator(); while (iter.hasNext()) { Edge current = (Edge) iter.next(); glv.getView().removeTempEdge(current); } } /** * Give feedback * @param feed Collection of edges */ protected void feedback(Collection feed) { hideFeedback(); elements.clear(); elements.addAll(feed); showFeedback(); } /** * Constructor * @param glv GLView * @param cursor Cursor */ public ArcTool(GLView glv, Cursor cursor) { super(glv, cursor); } /** * @param e MouseEvent */ protected void moved(MouseEvent e) { current = (Intersection) glv.getView().getObjectAtPoint(e.getX(), e.getY(), new HashSet(), true, new Plane(0, 0, 1, 0)); if (current != null) { if (start != null) { if (end != null) { Edge e1 = new Edge(start.vertex(), current.vertex()); Edge e2 = new Edge(current.vertex(), end.vertex()); Collection edges = new LinkedList(); edges.add(e1); edges.add(e2); feedback(edges); } else { Edge edge = new Edge(start.vertex(), current.vertex()); Collection edges = new LinkedList(); edges.add(edge); feedback(edges); } } } } /** * @param e MouseEvent */ protected void pressed(MouseEvent e) { if (start == null) { start = current; } else { if (end == null) { end = current; } else { feedback(new LinkedList()); start = null; end = null; } } } /** * @param e MouseEvent */ protected void dragged(MouseEvent e) { } /** * @param e MouseEvent */ protected void released(MouseEvent e) { } } Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** ToolFactory.java 13 Mar 2006 22:04:11 -0000 1.35 --- ToolFactory.java 14 Mar 2006 23:36:28 -0000 1.36 *************** *** 72,75 **** --- 72,78 ---- /** eraser tool */ private EraserTool eraser; + + /** arc tool */ + private ArcTool arc; /** pencil tool */ *************** *** 159,162 **** --- 162,166 ---- pencil = new PencilTool(glv, pencilcursor); eraser = new EraserTool(glv, pencilcursor); + arc = new ArcTool(glv, pencilcursor); move = new MoveTool(glv, pencilcursor); rotation = new RotationTool(glv, pencilcursor); *************** *** 174,177 **** --- 178,182 ---- pencilBut = this.registerTool(Tool.PENCIL_TOOL, pencil, "Biconpentool.gif", "Pencil"); eraserBut = this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); + this.registerTool(Tool.ARC_TOOL, arc, "Biconarc.gif", "Arc"); moveBut = this.registerTool(Tool.MOVE_TOOL, move, "Biconmovetool.gif", "Move"); moveBut.addMouseListener(new MoveButtonMouseListener(moveBut)); Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** Tool.java 3 Feb 2006 14:53:17 -0000 1.18 --- Tool.java 14 Mar 2006 23:36:28 -0000 1.19 *************** *** 42,45 **** --- 42,47 ---- /** The Eraser tool */ public static final int ERASER_TOOL = 10; + /** The Eraser tool */ + public static final int ARC_TOOL = 11; /** |