[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view ViewFactory.java,1.1,1.2
Status: Pre-Alpha
Brought to you by:
henryml
From: rimestad <rim...@us...> - 2005-08-05 11:04:52
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv947 Modified Files: ViewFactory.java Log Message: added construction of change view buttons Index: ViewFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/ViewFactory.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ViewFactory.java 26 Jul 2005 12:44:58 -0000 1.1 --- ViewFactory.java 5 Aug 2005 11:04:17 -0000 1.2 *************** *** 8,11 **** --- 8,20 ---- import net.sourceforge.bprocessor.kernel.notification.Notifier; + import net.sourceforge.bprocessor.gui.Toolbar; + import net.sourceforge.bprocessor.gl.GLView; + + import java.awt.event.ActionEvent; + import java.net.URL; + import javax.swing.AbstractAction; + import javax.swing.Action; + import javax.swing.ImageIcon; + import javax.swing.JButton; import org.apache.log4j.Logger; *************** *** 34,43 **** /** * Constructor */ ! private ViewFactory() { ! view3D = new View3D(); ! viewXY = new ViewXY(); ! viewXZ = new ViewXZ(); ! viewYZ = new ViewYZ(); Notifier n = Notifier.getInstance(); --- 43,53 ---- /** * Constructor + * @param glv The GLView */ ! private ViewFactory(GLView glv) { ! view3D = new View3D(glv); ! viewXY = new ViewXY(glv); ! viewXZ = new ViewXZ(glv); ! viewYZ = new ViewYZ(glv); Notifier n = Notifier.getInstance(); *************** *** 46,58 **** n.addListener(viewXZ); n.addListener(viewYZ); } /** * Get the factory * @return The factory */ ! public static synchronized ViewFactory getFactory() { if (factory == null) { ! factory = new ViewFactory(); } return factory; --- 56,79 ---- n.addListener(viewXZ); n.addListener(viewYZ); + + Toolbar tb = Toolbar.getInstance(); + JButton but = tb.registerAction(new View3DAction(glv)); + but.setToolTipText("3D view"); + but = tb.registerAction(new ViewxzAction(glv)); + but.setToolTipText("xz-plane"); + but = tb.registerAction(new ViewxyAction(glv)); + but.setToolTipText("xy-plane"); + but = tb.registerAction(new ViewyzAction(glv)); + but.setToolTipText("yz-plane"); } /** * Get the factory + * @param glv The GLView * @return The factory */ ! public static synchronized ViewFactory getFactory(GLView glv) { if (factory == null) { ! factory = new ViewFactory(glv); } return factory; *************** *** 86,88 **** --- 107,220 ---- } } + + /** + * The viewxy inner class + */ + class ViewxyAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ViewxyAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("xyicon.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.changeView(View.VIEW_XY); + } + } + + /** + * The viewxz inner class + */ + class ViewxzAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ViewxzAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("xzicon.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.changeView(View.VIEW_XZ); + } + } + /** + * The viewyz inner class + */ + class ViewyzAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + ViewyzAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("yzicon.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.changeView(View.VIEW_YZ); + } + } + + /** + * The view3D inner class + */ + class View3DAction extends AbstractAction { + /** The GLView */ + private GLView glv = null; + + /** + * Constructor + * @param glv TheGLView + */ + View3DAction(GLView glv) { + this.glv = glv; + ClassLoader cl = Thread.currentThread().getContextClassLoader(); + URL url = cl.getResource("3dicon.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.changeView(View.VIEW_3D); + } + } } |