<s> """<STR_LIT>""" <EOL> import math <EOL> from pyjamas . ui import HasHorizontalAlignment <EOL> from pyjamas . ui import HasVerticalAlignment <EOL> def validateMultipliers ( widthMultiplier , heightMultiplier ) : <EOL> if ( not ( widthMultiplier == <NUM_LIT:0> or abs ( widthMultiplier ) == <NUM_LIT:1> ) and <EOL> not ( heightMultiplier == <NUM_LIT:0> or abs ( heightMultiplier ) == <NUM_LIT:1> ) ) : <EOL> raise IllegalArgumentException ( <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) <EOL> def getAnnotationLocation ( widthMultiplier , heightMultiplier ) : <EOL> locationMap = [ <EOL> [ NORTHWEST , NORTH , NORTHEAST ] , <EOL> [ WEST , CENTER , EAST ] , <EOL> [ SOUTHWEST , SOUTH , SOUTHEAST ] ] <EOL> result = locationMap [ heightMultiplier + <NUM_LIT:1> ] [ widthMultiplier + <NUM_LIT:1> ] <EOL> return result <EOL> def transform ( a , signWidth , signHeight ) : <EOL> result = a <EOL> if signWidth < <NUM_LIT:0> or signHeight < <NUM_LIT:0> : <EOL> result = getAnnotationLocation ( <EOL> signWidth * a . widthMultiplier , <EOL> signHeight * a . heightMultiplier ) <EOL> return result <EOL> """<STR_LIT>""" <EOL> class AnnotationLocation : <EOL> def __init__ ( self , widthMultiplier , heightMultiplier ) : <EOL> validateMultipliers ( widthMultiplier , heightMultiplier ) <EOL> self . widthMultiplier = widthMultiplier <EOL> self . heightMultiplier = heightMultiplier <EOL> def getHorizontalAlignment ( self ) : <EOL> if self . widthMultiplier == - <NUM_LIT:1> : <EOL> result = HasHorizontalAlignment . ALIGN_RIGHT <EOL> elif self . widthMultiplier == <NUM_LIT:0> : <EOL> result = HasHorizontalAlignment . ALIGN_CENTER <EOL> elif self . widthMultiplier == <NUM_LIT:1> : <EOL> result = HasHorizontalAlignment . ALIGN_LEFT <EOL> else : <EOL> raise IllegalStateException ( <EOL> "<STR_LIT>" + str ( self . widthMultiplier ) + <EOL> "<STR_LIT>" ) <EOL> return result <EOL> """<STR_LIT>""" <EOL> def getUpperLeftX ( self , x , w , symbolW ) : <EOL> result = int ( round ( x + <EOL> ( self . widthMultiplier * ( w + symbolW ) - w ) / <NUM_LIT> ) ) <EOL> return result <EOL> """<STR_LIT>""" <EOL> def getUpperLeftY ( self , y , h , symbolH ) : <EOL> result = int ( round ( y + <EOL> ( self . heightMultiplier * ( h + symbolH ) - h ) / <NUM_LIT> ) ) <EOL> return result <EOL> def getVerticalAlignment ( self ) : <EOL> if self . heightMultiplier == - <NUM_LIT:1> : <EOL> result = HasVerticalAlignment . ALIGN_BOTTOM <EOL> elif self . heightMultiplier == <NUM_LIT:0> : <EOL> result = HasVerticalAlignment . ALIGN_MIDDLE <EOL> elif self . heightMultiplier == <NUM_LIT:1> : <EOL> result = HasVerticalAlignment . ALIGN_TOP <EOL> else : <EOL> raise IllegalStateException ( <EOL> "<STR_LIT>" + self . heightMultiplier + <EOL> "<STR_LIT>" ) <EOL> return result <EOL> """<STR_LIT>""" <EOL> def decodePieLocation ( self , thetaMid ) : <EOL> LOOKS_VERTICAL_OR_HORIZONTAL_DELTA = <NUM_LIT:0.1> <EOL> sinTheta = math . sin ( thetaMid ) <EOL> cosTheta = math . cos ( thetaMid ) <EOL> if cosTheta < - LOOKS_VERTICAL_OR_HORIZONTAL_DELTA : <EOL> pieTransformedWidthMultiplier = - self . heightMultiplier <EOL> elif cosTheta > LOOKS_VERTICAL_OR_HORIZONTAL_DELTA : <EOL> pieTransformedWidthMultiplier = self . heightMultiplier <EOL> else : <EOL> pieTransformedWidthMultiplier = <NUM_LIT:0> <EOL> if sinTheta < - LOOKS_VERTICAL_OR_HORIZONTAL_DELTA : <EOL> pieTransformedHeightMultiplier = - self . heightMultiplier <EOL> elif sinTheta > LOOKS_VERTICAL_OR_HORIZONTAL_DELTA : <EOL> pieTransformedHeightMultiplier = self . heightMultiplier <EOL> else : <EOL> pieTransformedHeightMultiplier = <NUM_LIT:0> <EOL> return getAnnotationLocation ( pieTransformedWidthMultiplier , <EOL> pieTransformedHeightMultiplier ) <EOL> AT_THE_MOUSE = AnnotationLocation ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> AT_THE_MOUSE_SNAP_TO_X = AnnotationLocation ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> AT_THE_MOUSE_SNAP_TO_Y = AnnotationLocation ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> """<STR_LIT>""" <EOL> CENTER = AnnotationLocation ( <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> north = AnnotationLocation ( <NUM_LIT:0> , - <NUM_LIT:1> ) <EOL> west = AnnotationLocation ( - <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> south = AnnotationLocation ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> CLOSEST_TO_HORIZONTAL_BASELINE = north <EOL> """<STR_LIT>""" <EOL> CLOSEST_TO_VERTICAL_BASELINE = west <EOL> """<STR_LIT>""" <EOL> EAST = AnnotationLocation ( <NUM_LIT:1> , <NUM_LIT:0> ) <EOL> """<STR_LIT>""" <EOL> FARTHEST_FROM_HORIZONTAL_BASELINE = south <EOL> """<STR_LIT>""" <EOL> FARTHEST_FROM_VERTICAL_BASELINE = EAST <EOL> """<STR_LIT>""" <EOL> INSIDE_PIE_ARC = north <EOL> """<STR_LIT>""" <EOL> NORTH = north <EOL> """<STR_LIT>""" <EOL> NORTHEAST = AnnotationLocation ( <NUM_LIT:1> , - <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> NORTHWEST = AnnotationLocation ( - <NUM_LIT:1> , - <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> ON_PIE_ARC = CENTER <EOL> """<STR_LIT>""" <EOL> OUTSIDE_PIE_ARC = south <EOL> """<STR_LIT>""" <EOL> SOUTH = south <EOL> """<STR_LIT>""" <EOL> SOUTHEAST = AnnotationLocation ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> SOUTHWEST = AnnotationLocation ( - <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> """<STR_LIT>""" <EOL> WEST = west </s>
