#NEWLINE# def _determine_focus( self ) : #NEWLINE# #INDENT# 'Determine the focal point of the view based on foxus (fx, fy),\n        allow_oob and maps.\n\n        Note that this method does not actually change the focus attributes\n        fx and fy.\n        ' #NEWLINE# fx = int ( self . fx ) #NEWLINE# fy = int ( self . fy ) #NEWLINE# if self . allow_oob : #NEWLINE# #INDENT# return ( fx , fy ) #NEWLINE# #UNINDENT# bounded = [ ] #NEWLINE# for layer in self . layers : #NEWLINE# #INDENT# if hasattr ( layer , 'pixel_width' ) : #NEWLINE# #INDENT# bounded . append ( layer ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not bounded ) : #NEWLINE# #INDENT# return ( fx , fy ) #NEWLINE# #UNINDENT# m = bounded [ 0 ] #NEWLINE# b_min_x = m . x #NEWLINE# b_min_y = m . y #NEWLINE# b_max_x = ( m . x + m . pixel_width ) #NEWLINE# b_max_y = ( m . y + m . pixel_height ) #NEWLINE# for m in bounded [ 1 : ] : #NEWLINE# #INDENT# b_min_x = min ( b_min_x , m . x ) #NEWLINE# b_min_y = min ( b_min_y , b_min_y . y ) #NEWLINE# b_max_x = min ( b_max_x , ( m . x + m . pixel_width ) ) #NEWLINE# b_max_y = min ( b_max_y , ( m . y + m . pixel_height ) ) #NEWLINE# #UNINDENT# w2 = ( self . width / 2 ) #NEWLINE# h2 = ( self . height / 2 ) #NEWLINE# v_min_x = ( fx - w2 ) #NEWLINE# v_min_y = ( fy - h2 ) #NEWLINE# x_moved = y_moved = False #NEWLINE# if ( v_min_x < b_min_x ) : #NEWLINE# #INDENT# fx += ( b_min_x - v_min_x ) #NEWLINE# x_moved = True #NEWLINE# #UNINDENT# if ( v_min_y < b_min_y ) : #NEWLINE# #INDENT# fy += ( b_min_y - v_min_y ) #NEWLINE# y_moved = True #NEWLINE# #UNINDENT# v_max_x = ( fx + w2 ) #NEWLINE# v_max_y = ( fy + h2 ) #NEWLINE# if ( ( not x_moved ) and ( v_max_x > b_max_x ) ) : #NEWLINE# #INDENT# fx -= ( v_max_x - b_max_x ) #NEWLINE# #UNINDENT# if ( ( not y_moved ) and ( v_max_y > b_max_y ) ) : #NEWLINE# #INDENT# fy -= ( v_max_y - b_max_y ) #NEWLINE# #UNINDENT# return map ( int , ( fx , fy ) )