Thread: [Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/tool AbstractTool.java,1.46,1.47 ToolFactor
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2006-01-06 15:36:23
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25160/src/net/sourceforge/bprocessor/gl/tool Modified Files: AbstractTool.java ToolFactory.java SelectTool.java Log Message: Selection refactored. Selection is now a special observable collection. Views responds to changed in the selection. Index: ToolFactory.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/ToolFactory.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ToolFactory.java 20 Dec 2005 15:43:36 -0000 1.22 --- ToolFactory.java 6 Jan 2006 15:36:14 -0000 1.23 *************** *** 9,13 **** import net.sourceforge.bprocessor.gl.GLView; import net.sourceforge.bprocessor.gui.Toolbar; - import net.sourceforge.bprocessor.kernel.notification.Notifier; import java.net.URL; --- 9,12 ---- *************** *** 123,128 **** fly = new CameraFlyTool(glv, flyCursor); walk = new CameraWalkTool(glv, walkCursor); - - Notifier.getInstance().addListener(select); } --- 122,125 ---- Index: SelectTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/SelectTool.java,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** SelectTool.java 29 Dec 2005 15:06:48 -0000 1.48 --- SelectTool.java 6 Jan 2006 15:36:14 -0000 1.49 *************** *** 10,18 **** import net.sourceforge.bprocessor.gl.model.ClippingPlane; - import net.sourceforge.bprocessor.kernel.notification.Notification; - import net.sourceforge.bprocessor.kernel.notification.NotificationListener; - import net.sourceforge.bprocessor.kernel.notification.Notifier; - - import net.sourceforge.bprocessor.model.Edge; import net.sourceforge.bprocessor.model.Project; --- 10,13 ---- *************** *** 40,44 **** * The selecttool */ ! public class SelectTool extends AbstractTool implements NotificationListener { /** The logger */ private static Logger log = Logger.getLogger(SelectTool.class); --- 35,39 ---- * The selecttool */ ! public class SelectTool extends AbstractTool { /** The logger */ private static Logger log = Logger.getLogger(SelectTool.class); *************** *** 306,324 **** */ private void select(Object obj) { ! if (obj instanceof Vertex) { ! Vertex v = (Vertex)obj; ! Notification n = new Notification(Notification.VERTEX_SELECTED, v.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (obj instanceof Surface) { ! Surface surface = (Surface)obj; ! Notification n = new Notification(Notification.SURFACE_SELECTED, surface.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (obj instanceof Edge) { ! Edge edge = (Edge)obj; ! Notification n = new Notification(Notification.EDGE_SELECTED, edge.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (obj instanceof ClippingPlane) { ! selection.add(obj); ! } } --- 301,305 ---- */ private void select(Object obj) { ! selection.add(obj); } *************** *** 328,349 **** */ private void deselect(Object obj) { ! if (obj instanceof Vertex) { ! Vertex v = (Vertex)obj; ! Notification n = new Notification(Notification.VERTEX_DESELECTED, v.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (obj instanceof Surface) { ! Surface surface = (Surface)obj; ! Notification n = new Notification(Notification.SURFACE_DESELECTED, surface.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (obj instanceof Edge) { ! Edge edge = (Edge)obj; ! Notification n = new Notification(Notification.EDGE_DESELECTED, edge.getId()); ! Notifier.getInstance().sendNotification(n); ! } else if (obj instanceof ClippingPlane) { ! log.info("Clip selected"); ! if (selection.contains(obj)) { ! selection.remove(obj); ! } ! } } --- 309,313 ---- */ private void deselect(Object obj) { ! selection.remove(obj); } *************** *** 368,385 **** if (selected instanceof Surface) { Surface selectedSurface = (Surface)selected; - selection.remove(selectedSurface); deleteSurface(selectedSurface); } else if (selected instanceof Edge) { Edge selectedEdge = (Edge)selected; - selection.remove(selectedEdge); deleteEdge(selectedEdge); } else if (selected instanceof Vertex) { - selection.remove(selected); deleteVertex((Vertex) selected); } else if (selected instanceof ClippingPlane) { - selection.remove(selected); glv.getView().removeClippingPlane((ClippingPlane)selected); } } glv.getView().makeTarget(null); glv.repaint(); --- 332,346 ---- if (selected instanceof Surface) { Surface selectedSurface = (Surface)selected; deleteSurface(selectedSurface); } else if (selected instanceof Edge) { Edge selectedEdge = (Edge)selected; deleteEdge(selectedEdge); } else if (selected instanceof Vertex) { deleteVertex((Vertex) selected); } else if (selected instanceof ClippingPlane) { glv.getView().removeClippingPlane((ClippingPlane)selected); } } + selection.clear(); glv.getView().makeTarget(null); glv.repaint(); *************** *** 387,494 **** super.keyPressed(e); } - } - - /** - * Handle a notification - * @param n The notification - */ - public void handleNotification(Notification n) { - if (n.getType().equals(Notification.VERTEX_SELECTED)) { - Vertex o = Project.getInstance().findVertexById(n.getObject()); - if (!selection.contains(o)) { - selection.add(o); - } - } else if (n.getType().equals(Notification.VERTEX_DESELECTED)) { - Vertex o = Project.getInstance().findVertexById(n.getObject()); - if (selection.contains(o)) { - selection.remove(o); - } - } else if (n.getType().equals(Notification.EDGE_SELECTED)) { - Edge o = Project.getInstance().findEdgeById(n.getObject()); - if (!selection.contains(o)) { - selection.add(o); - } - } else if (n.getType().equals(Notification.EDGE_DESELECTED)) { - Edge o = Project.getInstance().findEdgeById(n.getObject()); - if (selection.contains(o)) { - selection.remove(o); - } - } else if (n.getType().equals(Notification.SURFACE_SELECTED)) { - Surface o = Project.getInstance().findSurfaceById(n.getObject()); - if (!selection.contains(o)) { - selection.add(o); - } - } else if (n.getType().equals(Notification.SURFACE_DESELECTED)) { - Surface o = Project.getInstance().findSurfaceById(n.getObject()); - if (selection.contains(o)) { - selection.remove(o); - } - } else if (n.getType().equals(Notification.FUNCTIONAL_SPACE_SELECTED)) { - Space fs = - Project.getInstance().findFunctionalSpaceById(n.getObject()); - Set s = fs.getSurfaces(); - Iterator it = s.iterator(); - while (it.hasNext()) { - Surface surface = (Surface)it.next(); - if (!selection.contains(surface)) { - selection.add(surface); - } - } - } else if (n.getType().equals(Notification.FUNCTIONAL_SPACE_DESELECTED)) { - Space fs = - Project.getInstance().findFunctionalSpaceById(n.getObject()); - Set s = fs.getSurfaces(); - Iterator it = s.iterator(); - while (it.hasNext()) { - Surface surface = (Surface)it.next(); - if (selection.contains(surface)) { - selection.remove(surface); - } - } - } else if (n.getType().equals(Notification.CONSTRUCTION_SPACE_SELECTED)) { - Space cs = - Project.getInstance().findConstructionSpaceById(n.getObject()); - Set s = cs.getSurfaces(); - Iterator it = s.iterator(); - while (it.hasNext()) { - Surface surface = (Surface)it.next(); - if (!selection.contains(surface)) { - selection.add(surface); - } - } - } else if (n.getType().equals(Notification.CONSTRUCTION_SPACE_DESELECTED)) { - Space cs = - Project.getInstance().findConstructionSpaceById(n.getObject()); - Set s = cs.getSurfaces(); - Iterator it = s.iterator(); - while (it.hasNext()) { - Surface surface = (Surface)it.next(); - if (selection.contains(surface)) { - selection.remove(surface); - } - } - } - glv.repaint(); } - - /** - * Should the listener handle this notification - * @param type The notification type - * @return Returns true on SELECTED events; otherwise false - */ - public boolean isNotificationEnabled(String type) { - if (type.equals(Notification.VERTEX_SELECTED) || - type.equals(Notification.VERTEX_DESELECTED) || - type.equals(Notification.EDGE_SELECTED) || - type.equals(Notification.EDGE_DESELECTED) || - type.equals(Notification.SURFACE_SELECTED) || - type.equals(Notification.SURFACE_DESELECTED) || - type.equals(Notification.FUNCTIONAL_SPACE_SELECTED) || - type.equals(Notification.FUNCTIONAL_SPACE_DESELECTED) || - type.equals(Notification.CONSTRUCTION_SPACE_SELECTED) || - type.equals(Notification.CONSTRUCTION_SPACE_DESELECTED)) { - return true; - } - return false; - } } --- 348,351 ---- Index: AbstractTool.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/tool/AbstractTool.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** AbstractTool.java 4 Jan 2006 14:29:50 -0000 1.46 --- AbstractTool.java 6 Jan 2006 15:36:14 -0000 1.47 *************** *** 11,14 **** --- 11,15 ---- import net.sourceforge.bprocessor.model.Plane; import net.sourceforge.bprocessor.model.Project; + import net.sourceforge.bprocessor.model.Selection; import net.sourceforge.bprocessor.model.Surface; import net.sourceforge.bprocessor.model.Vertex; *************** *** 29,33 **** import java.util.Set; import java.util.Collection; - import java.util.HashSet; import org.apache.log4j.Logger; --- 30,33 ---- *************** *** 79,83 **** static { ! selection = new HashSet(); } --- 79,83 ---- static { ! selection = Selection.primary(); } |