Пример #1
0
 public void mouseReleased(MouseEvent e) {
   if (e.isPopupTrigger()) {
     showPopup(e);
     return;
   }
   cpoint = null;
   repainter.requestRepaint();
 }
Пример #2
0
 public void mouseDragged(MouseEvent e) {
   Point p = e.getPoint();
   if (cpoint != null) {
     cpoint.set(p.x, p.y);
   } else if (shape instanceof Vector) {
     int xoff = p.x - mousePressPoint.x;
     int yoff = p.y - mousePressPoint.y;
     Vector v = (Vector) shape;
     Pt loc = v.getLocation();
     v.setLocation(loc.x + xoff, loc.y + yoff);
     repainter.requestRepaint();
   }
   mousePressPoint = p;
 }
Пример #3
0
 private void showPopup(MouseEvent e) {
   Point point = e.getPoint();
   List<Primitive> l = stack.getPrimitives();
   Rectangle2D.Double scratch = new Rectangle2D.Double(0, 0, 0, 0);
   List<Primitive> shapes = new ArrayList<Primitive>();
   List<Vector> vectors = new ArrayList<Vector>();
   Primitive topMost = null;
   for (Primitive p : l) {
     if (p instanceof Vector) {
       Vector vector = (Vector) p;
       Shape shape = vector.toShape();
       System.err.println(shape);
       if (shape.contains(point.x, point.y)) {
         topMost = vector;
         shapes.add(vector);
         vectors.add(vector);
       }
     } else if (p instanceof Volume) {
       Volume volume = (Volume) p;
       volume.getBounds(scratch);
       System.err.println(p);
       if (scratch.contains(point.x, point.y)) {
         topMost = volume;
         shapes.add(volume);
       }
     }
   }
   if (!shapes.isEmpty()) {
     assert topMost != null;
     JPopupMenu menu = new JPopupMenu();
     menu.add(new FrontBackAction(true, topMost, stack));
     menu.add(new FrontBackAction(false, topMost, stack));
     menu.add(new CSGAction(UNION, vectors, stack));
     menu.add(new CSGAction(INTERSECTION, vectors, stack));
     menu.add(new CSGAction(SUBTRACTION, vectors, stack));
     menu.add(new CSGAction(XOR, vectors, stack));
     menu.show(repainter.getDialogParent(), point.x, point.y);
   }
 }
Пример #4
0
 public void changed(ControlPoint pt) {
   repainter.requestRepaint();
 }
Пример #5
0
 private void setSelectedControlPoint(ControlPoint cpoint) {
   this.cpoint = cpoint;
   repainter.requestRepaint();
 }
Пример #6
0
 public void attachRepainter(Repainter repainter) {
   this.repainter = repainter;
   if (layer != null) {
     repainter.requestRepaint(layer.getBounds());
   }
 }