Пример #1
0
  public static void mouseClicked(MouseEvent e) {
    GUI.closeAllMenus();
    if (e.getButton() == MouseEvent.BUTTON1) {
      switch (GUI.getCursor()
          .getName()) // if((this.getCursor().getName().equals("mano")) && (e.getButton() ==
      // MouseEvent.BUTTON1))
      {
        case "mano":
          if (seleccionado == null) {
            GUI.showSelectionMenu(e);
          } else {
            seleccionado.setState(Element.AVAILABLE);
            ;
            seleccionado.paint(panel.getGraphics());
            seleccionado = null;
          }

          break;
        case "lapiz":
          if ((seleccionado != null) && (seleccionado.getState() == Element.GETTINGPOINTS)) {
            System.out.println("desde1");
            seleccionado.setLast(e.getPoint());
            repaint();
          } else {
            GUI.showFigureMenu(e);
          }
          break;
      }
    }
  }
Пример #2
0
 public static void mouseMoved(MouseEvent e) {
   if (seleccionado != null) {
     switch (seleccionado.getState()) {
       case Element.MOVING:
         seleccionado.move(e.getX(), e.getY());
         break;
       case Element.ROTATING:
         seleccionado.rotate(e.getPoint());
         break;
       case Element.GETTINGPOINTS:
         Point lastPoint = seleccionado.getLast();
         Graphics g = panel.getGraphics();
         g.drawLine(lastPoint.x, lastPoint.y, e.getX(), e.getY() + 30);
         // repaint();
         break;
     }
     repaint();
   }
 }
Пример #3
0
 // Agrega un elemento a la lista de Elementos sobre el Lienzo.
 public static void addElement(Element e) {
   createAction(Action.CREATE, 0, e);
   elements.add(e);
   e.getArea();
 }