public synchronized void addItem ( T item ) { synchronized ( items ) { items . add ( item ) ; } // clusterMarker.setMarkerBitmap(); if ( center == null ) { center = item . getLatLong ( ) ; } else { // computing the centroid double lat = 0 , lon = 0 ; int n = 0 ; synchronized ( items ) { for ( T object : items ) { if ( object == null ) { throw new NullPointerException ( "object == null" ) ; } if ( object . getLatLong ( ) == null ) { throw new NullPointerException ( "object.getLatLong() == null" ) ; } lat += object . getLatLong ( ) . latitude ; lon += object . getLatLong ( ) . longitude ; n ++ ; } } center = new LatLong ( lat / n , lon / n ) ; } }
add item to cluster object