Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool RelationTool.java, NONE, 1.1 Tool.jav
Status: Pre-Alpha
Brought to you by:
henryml
|
From: rimestad <rim...@us...> - 2007-02-06 17:30:26
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv890/src/net/sourceforge/bprocessor/gl/tool Modified Files: Tool.java ToolFactory.java Added Files: RelationTool.java Log Message: reordered the toolbottons added and relation tool --- NEW FILE: RelationTool.java --- //--------------------------------------------------------------------------------- // $Id: RelationTool.java,v 1.1 2007/02/06 17:30:17 rimestad 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.ArrayList; import java.util.List; import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gui.GUI; import net.sourceforge.bprocessor.model.Constructor; import net.sourceforge.bprocessor.model.Geometric; import net.sourceforge.bprocessor.model.Edge; /** * Tool for creating relations between constructors and geometry * */ public class RelationTool extends AbstractPencil { private Constructor constructor; private Edge edge; /** * Constructor for Pencil * @param glv GLView * @param cursor Cursor */ public RelationTool(GLView glv, Cursor cursor) { super(glv, cursor); } /** * Update feedback */ private void updateFeedback() { if (constructor != null) { if (edge != null) { edge.setTo(current.vertex()); } else { // make new feedback edge = new Edge(constructor.center(), current.vertex()); edge.setStrippled(true); List<Edge> es = new ArrayList<Edge>(1); es.add(edge); feedback(es); } } } /** * {@inheritDoc} */ protected void moved(MouseEvent e) { //First find intersection current = findIntersection(e); //Then find targer object findTarget(e, elements); glv.getView().makeTarget(target); if (current != null) { updateFeedback(); } } /** * {@inheritDoc} */ protected void pressed(MouseEvent e) { onVertex(); moved(e); } /** * {@inheritDoc} */ public void cleanUp() { active = false; super.cleanUp(); edge = null; constructor = null; } /** * Current vertex is pressed */ public void onVertex() { if (constructor == null) { if (target != null) { if (target instanceof Constructor) { constructor = (Constructor) target; start = current; active = true; } else { GUI.getInstance().alert("Have to start by selecting a Constructor"); } } else { GUI.getInstance().alert("Have to start by selecting a Constructor"); } } else { if (target != null && target != constructor) { if (target instanceof Geometric) { Geometric g = (Geometric) target; constructor.connect(g); cleanUp(); } else { GUI.getInstance().alert("The socondly chosen object were not a geometric object"); } } } updateFeedback(); glv.repaint(); } } Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.73 retrieving revision 1.74 diff -C2 -d -r1.73 -r1.74 *** ToolFactory.java 20 Jan 2007 21:24:56 -0000 1.73 --- ToolFactory.java 6 Feb 2007 17:30:17 -0000 1.74 *************** *** 152,155 **** --- 152,158 ---- /** The alternative rect tool button */ private JToggleButton altRectBut; + + /** The tool for binding constructors and geometry together */ + private RelationTool relation; /** *************** *** 193,196 **** --- 196,200 ---- clipplane = new ClipplaneTool(glv, pencilcursor); tapeMeasure = new TapeMeasure(glv, pencilcursor); + relation = new RelationTool(glv, pencilcursor); camera = new CameraTool(glv, rotationCursor); fly = new CameraFlyTool(glv, flyCursor); *************** *** 207,212 **** pencilBut.setMnemonic(KeyEvent.VK_W); this.registerTool(Tool.ALT_PENCIL_TOOL, penciltool, "Biconpentool2.gif", "Pencil"); - eraserBut = this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); - eraserBut.setMnemonic(KeyEvent.VK_A); JToggleButton rect = this.registerTool(Tool.ALT_RECT_TOOL, altRect, "Biconaltrect.gif", "Rectangle"); --- 211,214 ---- *************** *** 214,217 **** --- 216,222 ---- JToggleButton arcb = this.registerTool(Tool.ARC_TOOL, arc, "Barc.gif", "Arc"); arcb.setMnemonic(KeyEvent.VK_Z); + offBut = this.registerTool(Tool.OFFSET_TOOL, offset, "Biconoffset.gif", "Offset"); + eraserBut = this.registerTool(Tool.ERASER_TOOL, eraser, "Biconeraser.gif", "Eraser"); + eraserBut.setMnemonic(KeyEvent.VK_A); tb.addSeparator(3); extrudeBut = registerTool(Tool.EXTRUSION_TOOL, extrude, "Biconextrudetool.gif", "Extrude"); *************** *** 223,233 **** tb.addSeparator(3); tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, ! "Bicontapemes.gif", "Tape Measure"); ! this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); ! offBut = this.registerTool(Tool.OFFSET_TOOL, offset, "Biconoffset.gif", "Offset"); ! clipBut = this.registerTool(Tool.CLIP_TOOL, clipplane, ! "Bclip.gif", "Clipping"); ! tb.addSeparator(3); --- 228,234 ---- tb.addSeparator(3); tmBut = this.registerTool(Tool.TAPE_MEASURE_TOOL, tapeMeasure, ! "Bicontapemes.gif", "Tape Measure"); this.registerTool(Tool.CONSTRUCTOR_TOOL, constructor, "Biconconstructor.gif", "Constructor"); ! this.registerTool(Tool.RELATION_TOOL, relation, "chaintool.gif", "Create relation"); tb.addSeparator(3); *************** *** 265,269 **** tb.addSeparator(10); ! Action orthoAction = new ToolAction(glv, 0, "Borto.gif") { public void actionPerformed(ActionEvent agr0) { --- 266,271 ---- tb.addSeparator(10); ! clipBut = this.registerTool(Tool.CLIP_TOOL, clipplane, ! "Bclip.gif", "Clipping"); Action orthoAction = new ToolAction(glv, 0, "Borto.gif") { public void actionPerformed(ActionEvent agr0) { Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** Tool.java 30 Nov 2006 22:03:41 -0000 1.27 --- Tool.java 6 Feb 2007 17:30:17 -0000 1.28 *************** *** 60,63 **** --- 60,65 ---- /** the alternative pecnil tool */ public static final int ALT_PENCIL_TOOL = 19; + /** the tool for creating relation between elements */ + public static final int RELATION_TOOL = 20; /** |