[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool ToolFactory.java,1.1,1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-08-05 10:52:43
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30218 Modified Files: ToolFactory.java Log Message: Added adding of buttons for tools and initial construction of all tools Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ToolFactory.java 26 Jul 2005 12:37:23 -0000 1.1 --- ToolFactory.java 5 Aug 2005 10:52:31 -0000 1.2 *************** *** 8,11 **** --- 8,20 ---- import net.sourceforge.bprocessor.gl.GLView; + import net.sourceforge.bprocessor.gui.Toolbar; + import net.sourceforge.bprocessor.kernel.notification.Notifier; + + import java.net.URL; + import java.awt.event.ActionEvent; + import javax.swing.AbstractAction; + import javax.swing.Action; + import javax.swing.ImageIcon; + import javax.swing.JButton; import org.apache.log4j.Logger; *************** *** 22,29 **** /** draw tool */ ! private Tool draw; /** select tool */ ! private Tool select; /** --- 31,44 ---- /** draw tool */ ! private DrawTool draw; /** select tool */ ! private SelectTool select; ! ! /** move tool */ ! private MoveTool move; ! ! /** extrusion tool */ ! private ExtrusionTool extrusion; /** *************** *** 34,37 **** --- 49,66 ---- draw = new DrawTool(glv); select = new SelectTool(glv); + move = new MoveTool(glv); + extrusion = new ExtrusionTool(glv); + + Toolbar tb = Toolbar.getInstance(); + JButton but = tb.registerAction(new SelectAction(glv)); + but.setToolTipText("Select"); + but = tb.registerAction(new DrawAction(glv)); + but.setToolTipText("Draw"); + but = tb.registerAction(new MoveAction(glv)); + but.setToolTipText("Move"); + but = tb.registerAction(new ExtrudeAction(glv)); + but.setToolTipText("Extrude"); + + Notifier.getInstance().addListener(select); } *************** *** 66,69 **** --- 95,102 ---- } else if (i == Tool.DRAW_TOOL) { return draw; + } else if (i == Tool.MOVE_TOOL) { + return move; + } else if (i == Tool.EXTRUSION_TOOL) { + return extrusion; } else { log.error("[get] No such tool " + i); *************** *** 71,73 **** --- 104,218 ---- } } + + /** + * The select action inner class + */ + class SelectAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + SelectAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("selecticon.png"); + 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.SELECT_TOOL); + } + } + + /** + * The draw action inner class + */ + class DrawAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + DrawAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("drawicon.png"); + 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.DRAW_TOOL); + } + } + + /** + * The move action inner class + */ + class MoveAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + MoveAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("moveicon.png"); + 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.MOVE_TOOL); + } + } + + /** + * The extrude action inner class + */ + class ExtrudeAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ExtrudeAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("extrudeicon.png"); + 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.EXTRUSION_TOOL); + } + } } |