Exemplo n.º 1
0
 private FigureElement findFigureElement(int x, int y) {
   Point2D p = new Point2D.Float((float) x, (float) y);
   for (Iterator i = canvas.members(); i.hasNext(); ) {
     FigureElement fe = (FigureElement) i.next();
     if (fe.contains(p)) return fe;
   }
   return null;
 }
Exemplo n.º 2
0
 public void mouseDragged(MouseEvent e) {
   int x = e.getX(), y = e.getY(), dx = lastX - x, dy = lastY - y;
   lastX = x;
   lastY = y;
   if (first == null) {
     Line line = addLine(point1, new Point(x, y));
     if (line != null) {
       canvas.add(line.getP2());
       first = line.getP2();
       canvas.add(line);
     }
   } else {
     first.move(-dx, -dy);
   }
   repaint();
 }