Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool Protractor.java,NONE,1.1 Tool.java,1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-03-22 11:42:47
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2749/src/net/sourceforge/bprocessor/gl/tool Modified Files: Tool.java ToolFactory.java Added Files: Protractor.java Log Message: Protractor implemented Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** ToolFactory.java 16 Mar 2006 20:01:47 -0000 1.38 --- ToolFactory.java 22 Mar 2006 11:42:44 -0000 1.39 *************** *** 94,97 **** --- 94,100 ---- private TapeMeasureTool tapeMeasure; + /** Protractor tool */ + private Protractor protractor; + /** The previous tool */ private Tool previousTool; *************** *** 172,175 **** --- 175,179 ---- clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasureTool(glv, pencilcursor); + protractor = new Protractor(glv, pencilcursor); camera = new CameraTool(glv, rotationCursor); fly = new CameraFlyTool(glv, flyCursor); *************** *** 193,196 **** --- 197,201 ---- tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, "Bicontapemes.gif", "Tape Measure"); + this.registerTool(Tool.PROTRACTOR_TOOL, protractor, "Biconprotractor.gif", "Protractor"); tb.addSeparator(); --- NEW FILE: Protractor.java --- //--------------------------------------------------------------------------------- // $Id: Protractor.java,v 1.1 2006/03/22 11:42:44 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.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.Project; import net.sourceforge.bprocessor.model.Vertex; /** * Protractor */ public class Protractor extends AbstractPencil { /** Current intersection */ private Intersection current; /** Start */ private Intersection start; /** angling */ private boolean angling; /** * Constructor * @param glv GLView * @param cursor Cursor */ public Protractor(GLView glv, Cursor cursor) { super(glv, cursor); } /** * Create a constructor * @param start From * @param end To * @return Edge */ protected Edge createConstructor(Vertex start, Vertex end) { Vertex vector = current.vertex().minus(start); vector.scale(50 / vector.length()); Vertex from = start.minus(vector); Vertex to = start.add(vector); Edge edge = new Edge(from, to); edge.setConstructor(true); return edge; } /** * Update feedback * */ protected void updateFeedback() { if (start != null) { List edges = new LinkedList(); Edge edge; if (angling) { edge = createConstructor(start.vertex(), current.vertex()); } else { edge = new Edge(start.vertex(), current.vertex()); edge.setConstructor(true); } edges.add(edge); feedback(edges); } else { feedback(new LinkedList()); } makeTarget(current); } /** * @param e MouseEven */ protected void moved(MouseEvent e) { current = findIntersection(e); if (current != null) { updateFeedback(); } } /** * @param e MouseEven */ protected void pressed(MouseEvent e) { if (start == null) { start = current; } else { if (angling) { Edge edge = createConstructor(start.vertex(), current.vertex()); Project.getInstance().add(edge.getFrom()); Project.getInstance().add(edge.getTo()); Project.getInstance().add(edge); Project.getInstance().checkpoint(); start = null; angling = false; } else { angling = true; } } updateFeedback(); } /** * @param e MouseEven */ protected void dragged(MouseEvent e) { } /** * @param e MouseEven */ protected void released(MouseEvent e) { } } Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** Tool.java 15 Mar 2006 10:36:28 -0000 1.20 --- Tool.java 22 Mar 2006 11:42:44 -0000 1.21 *************** *** 46,49 **** --- 46,51 ---- /** The Rect tool */ public static final int RECT_TOOL = 12; + /** The Protractor tool */ + public static final int PROTRACTOR_TOOL = 13; /** |