Пример #1
0
 public void mousePressed(MouseEvent e) {
   if (m_positionMotionListener == null) return;
   m_draggedFrom = getSquareForEvent(e);
   if (m_positionMotionListener.allowDrag(m_position, m_draggedFrom)) {
     m_draggedStone = m_position.getStone(m_draggedFrom);
     m_draggedX = e.getX();
     m_draggedY = e.getY();
     m_draggedPartnerSqi = m_positionMotionListener.getPartnerSqi(m_position, m_draggedFrom);
     // TODO mark m_draggedPartnerSqi
     repaint();
   } else {
     m_positionMotionListener.squareClicked(m_position, m_draggedFrom, e);
     m_draggedFrom = Chess.NO_SQUARE;
   }
 }
Пример #2
0
 public void mouseReleased(MouseEvent e) {
   if (m_positionMotionListener == null) return;
   if (m_draggedFrom != Chess.NO_SQUARE) {
     int draggedTo = getSquareForEvent(e);
     if (draggedTo != Chess.NO_SQUARE) {
       if (m_draggedFrom == draggedTo) {
         if (m_draggedPartnerSqi != Chess.NO_SQUARE) {
           m_positionMotionListener.dragged(m_position, m_draggedFrom, m_draggedPartnerSqi, e);
         } else {
           m_positionMotionListener.squareClicked(m_position, m_draggedFrom, e);
         }
       } else {
         m_positionMotionListener.dragged(m_position, m_draggedFrom, draggedTo, e);
       }
     }
     m_draggedFrom = Chess.NO_SQUARE;
     m_draggedStone = Chess.NO_STONE;
     // TODO unmark m_draggedPartnerSqi
     repaint();
   }
 }