[Bprocessor-commit] gl/src/net/sourceforge/bprocessor/gl/view PopupMenu.java, 1.50, 1.51
Status: Pre-Alpha
Brought to you by:
henryml
From: Michael L. <he...@us...> - 2011-04-13 08:14:52
|
Update of /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view In directory vz-cvs-2.sog:/tmp/cvs-serv29985/src/net/sourceforge/bprocessor/gl/view Modified Files: PopupMenu.java Log Message: Index: PopupMenu.java =================================================================== RCS file: /cvsroot/bprocessor/gl/src/net/sourceforge/bprocessor/gl/view/PopupMenu.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** PopupMenu.java 1 Dec 2010 11:52:26 -0000 1.50 --- PopupMenu.java 13 Apr 2011 08:14:49 -0000 1.51 *************** *** 58,63 **** import net.sourceforge.bprocessor.model.Command.BoundingSphere; import net.sourceforge.bprocessor.model.modellor.Modellor; - import net.sourceforge.bprocessor.model.plugin.FacadePackage; - import net.sourceforge.bprocessor.model.plugin.NetCommand; import org.apache.log4j.Logger; --- 58,61 ---- *************** *** 71,74 **** --- 69,73 ---- private static final boolean CHECKS = false; + private static final boolean EXPERIMENTAL = false; private Editor editor; *************** *** 243,246 **** --- 242,270 ---- } + + class CommandAction extends AbstractAction { + private Class<? extends Command> clarse; + private Space target; + + public CommandAction(Space target, Class<? extends Command> clarse) { + super(clarse.getSimpleName()); + this.target = target; + this.clarse = clarse; + } + public void actionPerformed(ActionEvent e) { + try { + Command command = Command.attach(target, clarse); + Space owner = target.getOwner(); + owner.add(command); + AttributeView.instance().display(command); + Project.getInstance().checkpoint(); + Project.getInstance().changed(); + } catch (Exception e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + /** * A popup generator for a collection of space *************** *** 310,316 **** if (s.size() == 1) { // Some options do only apply to one space ! Space sp = (Space)s.iterator().next(); ! AbstractAction edit = new SpaceMenuAction(sp, "Edit") { public void actionPerformed(ActionEvent arg0) { space.edit(); --- 334,340 ---- if (s.size() == 1) { // Some options do only apply to one space ! Space target = (Space) s.iterator().next(); ! AbstractAction edit = new SpaceMenuAction(target, "Edit") { public void actionPerformed(ActionEvent arg0) { space.edit(); *************** *** 319,323 **** menu.add(edit); { ! AbstractAction action = new SpaceMenuAction(sp, "Simplify") { public void actionPerformed(ActionEvent event) { space.reduce(); --- 343,347 ---- menu.add(edit); { ! AbstractAction action = new SpaceMenuAction(target, "Simplify") { public void actionPerformed(ActionEvent event) { space.reduce(); *************** *** 329,333 **** } { ! AbstractAction action = new SpaceMenuAction(sp, "Clear") { public void actionPerformed(ActionEvent event) { space.clear(); --- 353,357 ---- } { ! AbstractAction action = new SpaceMenuAction(target, "Clear") { public void actionPerformed(ActionEvent event) { space.clear(); *************** *** 338,412 **** menu.add(action); } ! ! ! { ! AbstractAction action = new SpaceMenuAction(sp, "Subdivide...") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Subdivide(space); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Frame..") { ! public void actionPerformed(ActionEvent event) { ! NetCommand command = new FacadePackage.Frame(); ! command.initialize(space); ! AttributeView.instance().display(command); ! space.getOwner().add(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Facade..") { ! public void actionPerformed(ActionEvent event) { ! // Command command = new Facade(space); ! // AttributeView.instance().display(command); ! // space.getOwner().add(command); ! // Project.getInstance().changed(); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Hyperbolic Paraboloid..") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Hyperbolicparaboloid(space); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Uniform Nonrational B-Spline..") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.UniformNonrationalBSpline(space); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Nonuniform Nonrational B-Spline..") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.NonuniformNonrationalBSpline(space); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Offset..") { ! public void actionPerformed(ActionEvent event) { ! Command command = new Command.Layer(space); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Normals") { public void actionPerformed(ActionEvent event) { Space union = Space.createConstructionSpace("Normals"); --- 362,367 ---- menu.add(action); } ! if (CHECKS) { ! AbstractAction action = new SpaceMenuAction(target, "Normals") { public void actionPerformed(ActionEvent event) { Space union = Space.createConstructionSpace("Normals"); *************** *** 428,433 **** menu.add(action); } { ! AbstractAction action = new SpaceMenuAction(sp, "Make Component") { public void actionPerformed(ActionEvent event) { CoordinateSystem system = space.getHandle(); --- 383,389 ---- menu.add(action); } + { ! AbstractAction action = new SpaceMenuAction(target, "Make Component") { public void actionPerformed(ActionEvent event) { CoordinateSystem system = space.getHandle(); *************** *** 446,469 **** } { ! AbstractAction action = new SpaceMenuAction(sp, "Tesselate") { ! public void actionPerformed(ActionEvent event) { ! Collection<Surface> surfaces = new LinkedList(space.getEnvelope()); ! for (Surface current : surfaces) { ! editor.getView().tesselate(current); ! } ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Export") { ! public void actionPerformed(ActionEvent event) { ! space.export(System.out); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Orient") { public void actionPerformed(ActionEvent event) { List<Surface> surfaces = new LinkedList(space.getEnvelope()); --- 402,406 ---- } { ! AbstractAction action = new SpaceMenuAction(target, "Orient") { public void actionPerformed(ActionEvent event) { List<Surface> surfaces = new LinkedList(space.getEnvelope()); *************** *** 474,487 **** menu.add(action); } - - AbstractAction item = new SpaceMenuAction(sp, "Consistency Check") { - public void actionPerformed(ActionEvent arg0) { - space.verify(); - } - }; - menu.add(item); - if (CHECKS) { ! AbstractAction check = new SpaceMenuAction(sp, "Consistency Check") { public void actionPerformed(ActionEvent arg0) { space.check(); --- 411,416 ---- menu.add(action); } if (CHECKS) { ! AbstractAction check = new SpaceMenuAction(target, "Consistency Check") { public void actionPerformed(ActionEvent arg0) { space.check(); *************** *** 489,493 **** }; menu.add(check); ! AbstractAction modCheck = new SpaceMenuAction(sp, "Modellor Check") { public void actionPerformed(ActionEvent arg0) { log.info(space.getModellor()); --- 418,422 ---- }; menu.add(check); ! AbstractAction modCheck = new SpaceMenuAction(target, "Modellor Check") { public void actionPerformed(ActionEvent arg0) { log.info(space.getModellor()); *************** *** 495,514 **** }; menu.add(modCheck); } ! { ! AbstractAction action = new SpaceMenuAction(sp, "Print Classification") { ! public void actionPerformed(ActionEvent event) { ! Classification classification = space.getClassification(); ! System.out.println("id " + classification.getFullId(space)); ! ClassificationType type = space.getClassificationType(); ! System.out.println("type " + type.getIndex()); } ! }; ! menu.add(action); } for (Modellor current : Modellor.getRegisteredModellors()) { if (current.application() == Modellor.DETAIL) { ! AbstractAction action = new ModellorAction(current, sp) { public void actionPerformed(ActionEvent e) { System.out.println("detail " + modellor); --- 424,456 ---- }; menu.add(modCheck); + { + AbstractAction action = new SpaceMenuAction(target, "Print Classification") { + public void actionPerformed(ActionEvent event) { + Classification classification = space.getClassification(); + System.out.println("id " + classification.getFullId(space)); + ClassificationType type = space.getClassificationType(); + System.out.println("type " + type.getIndex()); + } + }; + menu.add(action); + } } ! ! if (target.isNet()) { ! ! { ! JMenu submenu = new JMenu("Attach"); ! for (Class<? extends Command> current : Command.getCommands()) { ! AbstractAction action = new CommandAction(target, current); ! submenu.add(action); } ! menu.add(submenu); ! } } + for (Modellor current : Modellor.getRegisteredModellors()) { if (current.application() == Modellor.DETAIL) { ! AbstractAction action = new ModellorAction(current, target) { public void actionPerformed(ActionEvent e) { System.out.println("detail " + modellor); *************** *** 527,531 **** while (iter.hasNext()) { Modellor m = (Modellor)iter.next(); ! AbstractAction modellor = new ModellorMenuAction(sp, m); mm.add(modellor); } --- 469,473 ---- while (iter.hasNext()) { Modellor m = (Modellor)iter.next(); ! AbstractAction modellor = new ModellorMenuAction(target, m); mm.add(modellor); } *************** *** 574,593 **** }; menu.add(delete); - AbstractAction allConnected = new GeometricMenuAction(arguments, "All Connected") { - public void actionPerformed(ActionEvent arg0) { - Collection<Geometric> geometrics = - Geometric.connected(new LinkedList(entities), true); - Selection.primary().set(geometrics); - } - }; - menu.add(allConnected); - - AbstractAction simplify = new GeometricMenuAction(arguments, "Simplify Geometry") { - public void actionPerformed(ActionEvent arg0) { - Geometry.simplifyGeometry(entities); - } - }; - menu.add(simplify); - { AbstractAction action = new GeometricMenuAction(arguments, "Make Union") { --- 516,519 ---- *************** *** 650,794 **** menu.add(action); } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Align Axes") { ! public void actionPerformed(ActionEvent event) { ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! Project.getInstance().setActiveCoordinateSystem(CoordinateSystem.systemFor(geometric)); ! Project.getInstance().changed(); ! Project.getInstance().checkpoint(); ! } ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Scale...") { ! public void actionPerformed(ActionEvent event) { ! Set<Vertex> vertices = Geometric.collect(entities); ! Vertex center = null; ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! if (geometric instanceof Constructor) { ! Constructor constructor = (Constructor) geometric; ! center = constructor.getOrigin(); } - } ! if (center == null) { ! center = Vertex.center(vertices); ! } ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system = system.copy(); ! system.setOrigin(center); ! Command command = new Command.Scale(vertices, system); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Translate...") { ! public void actionPerformed(ActionEvent event) { ! Set<Vertex> vertices = Geometric.collect(entities); ! Vertex center = null; ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! if (geometric instanceof Constructor) { ! Constructor constructor = (Constructor) geometric; ! center = constructor.getOrigin(); } - } ! if (center == null) { ! center = Vertex.center(vertices); ! } ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system = system.copy(); ! system.setOrigin(center); ! Command command = new Command.Translate(vertices, system); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Rotate...") { ! public void actionPerformed(ActionEvent event) { ! Set<Vertex> vertices = Geometric.collect(entities); ! Vertex center = null; ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! if (geometric instanceof Constructor) { ! Constructor constructor = (Constructor) geometric; ! center = constructor.getOrigin(); } - } ! if (center == null) { ! center = Vertex.center(vertices); ! } ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system = system.copy(); ! system.setOrigin(center); ! Command command = new Command.Rotate(vertices, system); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Transform In") { ! public void actionPerformed(ActionEvent event) { ! List<Vertex> vertices = new ArrayList(Geometric.collect(entities)); ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system.unTranslateIt(vertices); ! for (Vertex current : vertices) { ! current.update(); } ! Project.getInstance().changed(); ! Project.getInstance().checkpoint(); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Transform Out") { ! public void actionPerformed(ActionEvent event) { ! List<Vertex> vertices = new ArrayList(Geometric.collect(entities)); ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system.translateIt(vertices); ! for (Vertex current : vertices) { ! current.update(); } ! Project.getInstance().changed(); ! Project.getInstance().checkpoint(); ! } ! }; ! menu.add(action); ! } ! { { ! AbstractAction action = new GeometricMenuAction(arguments, "New Property...") { public void actionPerformed(ActionEvent event) { ! Geometric geometric = entities.iterator().next(); ! Command command = new Command.PropertyCommand(geometric); ! AttributeView.instance().display(command); } }; menu.add(action); } ! } return menu; --- 576,707 ---- menu.add(action); } ! if (EXPERIMENTAL) { ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Scale...") { ! public void actionPerformed(ActionEvent event) { ! Set<Vertex> vertices = Geometric.collect(entities); ! Vertex center = null; ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! if (geometric instanceof Constructor) { ! Constructor constructor = (Constructor) geometric; ! center = constructor.getOrigin(); ! } } ! if (center == null) { ! center = Vertex.center(vertices); ! } ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system = system.copy(); ! system.setOrigin(center); ! Command command = new Command.Scale(vertices, system); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Translate...") { ! public void actionPerformed(ActionEvent event) { ! Set<Vertex> vertices = Geometric.collect(entities); ! Vertex center = null; ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! if (geometric instanceof Constructor) { ! Constructor constructor = (Constructor) geometric; ! center = constructor.getOrigin(); ! } } ! if (center == null) { ! center = Vertex.center(vertices); ! } ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system = system.copy(); ! system.setOrigin(center); ! Command command = new Command.Translate(vertices, system); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Rotate...") { ! public void actionPerformed(ActionEvent event) { ! Set<Vertex> vertices = Geometric.collect(entities); ! Vertex center = null; ! if (entities.size() == 1) { ! Geometric geometric = entities.iterator().next(); ! if (geometric instanceof Constructor) { ! Constructor constructor = (Constructor) geometric; ! center = constructor.getOrigin(); ! } } ! if (center == null) { ! center = Vertex.center(vertices); ! } ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system = system.copy(); ! system.setOrigin(center); ! Command command = new Command.Rotate(vertices, system); ! AttributeView.instance().display(command); } ! }; ! menu.add(action); ! } ! ! { ! AbstractAction action = new GeometricMenuAction(arguments, "Transform In") { ! public void actionPerformed(ActionEvent event) { ! List<Vertex> vertices = new ArrayList(Geometric.collect(entities)); ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system.unTranslateIt(vertices); ! for (Vertex current : vertices) { ! current.update(); ! } ! Project.getInstance().changed(); ! Project.getInstance().checkpoint(); } ! }; ! menu.add(action); ! } { ! AbstractAction action = new GeometricMenuAction(arguments, "Transform Out") { public void actionPerformed(ActionEvent event) { ! List<Vertex> vertices = new ArrayList(Geometric.collect(entities)); ! CoordinateSystem system = Project.getInstance().getActiveCoordinateSystem(); ! system.translateIt(vertices); ! for (Vertex current : vertices) { ! current.update(); ! } ! Project.getInstance().changed(); ! Project.getInstance().checkpoint(); } }; menu.add(action); } ! } ! { ! AbstractAction action = new GeometricMenuAction(arguments, "New Property...") { ! public void actionPerformed(ActionEvent event) { ! Geometric geometric = entities.iterator().next(); ! Command command = new Command.PropertyCommand(geometric); ! AttributeView.instance().display(command); ! } ! }; ! menu.add(action); } return menu; |