Package net.sf.arianne.marboard.client.gui.drawingtool

Source Code of net.sf.arianne.marboard.client.gui.drawingtool.ShapePickerDrawingTool

package net.sf.arianne.marboard.client.gui.drawingtool;

import java.awt.event.MouseEvent;

import net.sf.arianne.marboard.client.entity.shape.Shape;
import net.sf.arianne.marboard.client.gui.BoardState;
import net.sf.arianne.marboard.client.gui.DrawingTool;
import net.sf.arianne.marboard.client.gui.component.DrawingArea;

import org.apache.log4j.Logger;

/**
* Picks the shape at the mouse pointer
*
* @author hendrik
*/
public class ShapePickerDrawingTool implements DrawingTool {
  private static Logger logger = Logger.getLogger(ShapePickerDrawingTool.class);
 
  private DrawingArea board;

  /**
   * creates a new ShapePickerDrawingTool
   *
   * @param board DrawingArea
   */
  public ShapePickerDrawingTool(DrawingArea board) {
    this.board = board;
  }

  /**
   * picks the shape at the position the mouse pointer is clicked
   *
   * @param boardState state of the board
   * @param event MouseEvent
   */
  public void handleMouseEvent(BoardState boardState, MouseEvent event) {
    Shape shape = this.board.pickShape(event.getX(), event.getY());
    if (shape != null) {
      logger.info(shape.getRPObject());
    }
  }

  /**
   * ignored because picking a shape is a one click operation
   */
  public void reset() {
    // ignore
  }

  /**
   * ignored because picking a shape is a one click operation
   */
  public void handleMouseMovement(BoardState boardState, MouseEvent event) {
    // ignore
  }

}
TOP

Related Classes of net.sf.arianne.marboard.client.gui.drawingtool.ShapePickerDrawingTool

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.