@Override public void mouseDragged(MouseEvent e){
  int x=e.getX();
  int y=e.getY();
  if (selecting_area) {
    if (shaping_selection) {
      int dx=(x - origin_x) / 4;
      int dy=(y - origin_y) / 4;
      if (shaping_action == CursorSelectionPosition.INSIDE || shaping_action == CursorSelectionPosition.W_SIDE || shaping_action == CursorSelectionPosition.NW_CORNER || shaping_action == CursorSelectionPosition.SW_CORNER)       selection_start_x=(int)(ssx + dx / zoom_level);
      if (shaping_action == CursorSelectionPosition.INSIDE || shaping_action == CursorSelectionPosition.N_SIDE || shaping_action == CursorSelectionPosition.NW_CORNER || shaping_action == CursorSelectionPosition.NE_CORNER)       selection_start_z=(int)(ssz + dy / zoom_level);
      if (shaping_action == CursorSelectionPosition.INSIDE || shaping_action == CursorSelectionPosition.E_SIDE || shaping_action == CursorSelectionPosition.NE_CORNER || shaping_action == CursorSelectionPosition.SE_CORNER)       selection_end_x=(int)(sex + dx / zoom_level);
      if (shaping_action == CursorSelectionPosition.INSIDE || shaping_action == CursorSelectionPosition.S_SIDE || shaping_action == CursorSelectionPosition.SW_CORNER || shaping_action == CursorSelectionPosition.SE_CORNER)       selection_end_z=(int)(sez + dy / zoom_level);
      repaint();
      return;
    }
    selection_end_x=(int)Math.floor((e.getX() / zoom_level - shift_x) / 4);
    selection_end_z=(int)Math.floor((e.getY() / zoom_level - shift_y) / 4);
    if (selectchunks) {
      if (selection_start_x % 16 != 0) {
        selection_start_x=Math.round(selection_start_x / 16) * 16;
      }
      if (selection_start_z % 16 != 0) {
        selection_start_z=Math.round(selection_start_z / 16) * 16;
      }
      if (selection_end_x % 16 != 0) {
        selection_end_x=Math.round(selection_end_x / 16) * 16;
      }
      if (selection_end_z % 16 != 0) {
        selection_end_z=Math.round(selection_end_z / 16) * 16;
      }
    }
    repaint();
    return;
  }
  if (moving_map) {
    shift_x+=(x - last_x) / zoom_level;
    shift_y+=(y - last_y) / zoom_level;
    last_x=x;
    last_y=y;
    redraw(true);
    repaint();
  }
}

@ Override public void mouseDragged ( MouseEvent e ) { int x = e . getX ( ) ; int y = e . getY ( ) ; if ( selecting_area ) { if ( shaping_selection ) { int dx = ( x - origin_x ) / 4 ; int dy = ( y - origin_y ) / 4 ; if ( shaping_action == CursorSelectionPosition . INSIDE || shaping_action == CursorSelectionPosition . W_SIDE || shaping_action == CursorSelectionPosition . NW_CORNER || shaping_action == CursorSelectionPosition . SW_CORNER ) selection_start_x = ( int ) ( ssx + dx / zoom_level ) ; if ( shaping_action == CursorSelectionPosition . INSIDE || shaping_action == CursorSelectionPosition . N_SIDE || shaping_action == CursorSelectionPosition . NW_CORNER || shaping_action == CursorSelectionPosition . NE_CORNER ) selection_start_z = ( int ) ( ssz + dy / zoom_level ) ; if ( shaping_action == CursorSelectionPosition . INSIDE || shaping_action == CursorSelectionPosition . E_SIDE || shaping_action == CursorSelectionPosition . NE_CORNER || shaping_action == CursorSelectionPosition . SE_CORNER ) selection_end_x = ( int ) ( sex + dx / zoom_level ) ; if ( shaping_action == CursorSelectionPosition . INSIDE || shaping_action == CursorSelectionPosition . S_SIDE || shaping_action == CursorSelectionPosition . SW_CORNER || shaping_action == CursorSelectionPosition . SE_CORNER ) selection_end_z = ( int ) ( sez + dy / zoom_level ) ; repaint ( ) ; return ; } selection_end_x = ( int ) Math . floor ( ( e . getX ( ) / zoom_level - shift_x ) / 4 ) ; selection_end_z = ( int ) Math . floor ( ( e . getY ( ) / zoom_level - shift_y ) / 4 ) ; if ( selectchunks ) { if ( selection_start_x % 16 != 0 ) { selection_start_x = Math . round ( selection_start_x / 16 ) * 16 ; } if ( selection_start_z % 16 != 0 ) { selection_start_z = Math . round ( selection_start_z / 16 ) * 16 ; } if ( selection_end_x % 16 != 0 ) { selection_end_x = Math . round ( selection_end_x / 16 ) * 16 ; } if ( selection_end_z % 16 != 0 ) { selection_end_z = Math . round ( selection_end_z / 16 ) * 16 ; } } repaint ( ) ; return ; } if ( moving_map ) { shift_x += ( x - last_x ) / zoom_level ; shift_y += ( y - last_y ) / zoom_level ; last_x = x ; last_y = y ; redraw ( true ) ; repaint ( ) ; } }
event fired when mouse is moved with the button pressed inside the preview .
