Exemplo n.º 1
0
  /**
   * Reimplementación del método mouseReleased de Behavior.
   *
   * @param e MouseEvent
   * @throws BehaviorException Excepción lanzada cuando el Behavior.
   */
  public void mouseReleased(MouseEvent e) throws BehaviorException {
    super.mouseReleased(e);
    dragged = false;
    if (getLayoutControl().getFirstPoint() == null) return;
    Point2D p1;
    Point2D p2;
    Point pScreen = getLayoutControl().getLastPoint();

    AffineTransform at = getLayoutControl().getAT();

    p1 = FLayoutUtilities.toSheetPoint(getLayoutControl().getFirstPoint(), at);
    p2 = FLayoutUtilities.toSheetPoint(pScreen, at);

    if (e.getButton() == MouseEvent.BUTTON1) {
      //	Fijamos el nuevo extent
      Rectangle2D.Double r = new Rectangle2D.Double();
      r.setFrameFromDiagonal(p1, p2);

      Rectangle2D rectPixel = new Rectangle();
      rectPixel.setFrameFromDiagonal(getLayoutControl().getFirstPoint(), pScreen);

      RectangleEvent event = new RectangleEvent(r, e, rectPixel);
      listener.rectangle(event);
    }
  }
Exemplo n.º 2
0
 /**
  * Reimplementación del método mousePressed de Behavior.
  *
  * @param e MouseEvent
  * @throws BehaviorException
  */
 public void mousePressed(MouseEvent e) throws BehaviorException {
   super.mousePressed(e);
   if (listener.cancelDrawing()) {
     // getLayout().cancelDrawing();
   }
   getLayoutControl().repaint();
 }