[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool EraserTool.java,NONE,1.1 Tool.java,1.1
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-02-03 14:53:30
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1867/src/net/sourceforge/bprocessor/gl/tool Modified Files: Tool.java ToolFactory.java Added Files: EraserTool.java Log Message: Eraser Tool implemented (erases lines) Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** ToolFactory.java 1 Feb 2006 10:04:28 -0000 1.28 --- ToolFactory.java 3 Feb 2006 14:53:19 -0000 1.29 *************** *** 48,51 **** --- 48,54 ---- /** pencil tool */ private PencilTool pencil; + + /** eraser tool */ + private EraserTool eraser; /** pencil tool */ *************** *** 75,78 **** --- 78,84 ---- /** The pencil button */ private JToggleButton pencilBut; + + /** The eraser button */ + private JToggleButton eraserBut; /** The move button */ *************** *** 133,136 **** --- 139,148 ---- bg.add(pencilBut); pencilBut.setToolTipText("Pencil"); + + eraserBut = tb.registerAction(new EraserAction(glv)); + bg.add(eraserBut); + eraserBut.setToolTipText("Eraser"); + + moveBut = tb.registerAction(new MoveAction(glv)); bg.add(moveBut); *************** *** 162,165 **** --- 174,178 ---- select = new SpaceTool(glv, null); pencil = new PencilTool(glv, pencilcursor); + eraser = new EraserTool(glv, pencilcursor); move = new MoveTool(glv, pencilcursor); rotation = new RotationTool(glv, pencilcursor); *************** *** 240,243 **** --- 253,259 ---- tmBut.setSelected(true); currentTool = tapeMeasure; + } else if (i == Tool.ERASER_TOOL) { + eraserBut.setSelected(true); + currentTool = eraser; } else { log.error("[get] No such tool " + i); *************** *** 482,485 **** --- 498,533 ---- /** + * EraserAction + */ + class EraserAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** The mouse cursor */ + private Cursor cursor; + + /** + * Constructor + * @param glv TheGLView + */ + EraserAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("Biconeraser.gif"); + ImageIcon im = new ImageIcon(url); + putValue(Action.SMALL_ICON, im); + } + + /** + * Called when the button is pressed + * @param e The ActionEvent + */ + public void actionPerformed(ActionEvent e) { + glv.changeTool(Tool.ERASER_TOOL); + } + } + + + /** * The clipping action inner class */ --- NEW FILE: EraserTool.java --- //--------------------------------------------------------------------------------- // $Id: EraserTool.java,v 1.1 2006/02/03 14:53:19 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 net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Project; /** * EraserTool */ public class EraserTool extends SelectTool { /** * Constructor fo EraserTool * @param glv The GLView * @param cursor The Cursor */ public EraserTool(GLView glv, Cursor cursor) { super(glv, cursor); } /** * Invoked when the mouse cursor has been moved * @param e The MouseEvent object */ protected void moved(MouseEvent e) { findTarget(e); if (target instanceof Edge) { glv.getView().makeTarget(target); } else { glv.getView().makeTarget(null); } } /** * Invoked when a mouse button has been pressed on a component. * @param e The MouseEvent object */ protected void pressed(MouseEvent e) { findTarget(e); if (target instanceof Edge) { Project.getInstance().delete((Edge) target); } else { glv.getView().makeTarget(null); } } /** * Invoked when a mouse button has dragged with button down. * @param e The MouseEvent object */ protected void dragged(MouseEvent e) { } } Index: Tool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/Tool.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** Tool.java 27 Jan 2006 11:43:37 -0000 1.17 --- Tool.java 3 Feb 2006 14:53:17 -0000 1.18 *************** *** 40,43 **** --- 40,45 ---- /** The Rotation tool */ public static final int ROTATION_TOOL = 9; + /** The Eraser tool */ + public static final int ERASER_TOOL = 10; /** |