Java Code Examples for android.util.FloatMath

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project 2Degrees-Toolbox, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  20 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 2

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 3

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 4

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 5

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 6

From project android-gltron, under directory /GlTron/src/com/glTron/Game/.

Source file: Recognizer.java

  19 
vote

private float getAngle(Vec velocity){
  float dxval=velocity.v[0];
  float dyval=velocity.v[0];
  float phi=(float)Math.acos(dxval / FloatMath.sqrt(dxval * dxval + dyval * dyval));
  if (dyval < 0.0f)   phi=(float)(2.0f * Math.PI - phi);
  return (float)((phi + Math.PI / 2.0f) * 180.0f / Math.PI);
}
 

Example 7

From project Android-Terminal-Emulator, under directory /libraries/emulatorview/src/jackpal/androidterm/emulatorview/.

Source file: PaintRenderer.java

  19 
vote

public PaintRenderer(int fontSize,ColorScheme scheme){
  super(scheme);
  mTextPaint=new Paint();
  mTextPaint.setTypeface(Typeface.MONOSPACE);
  mTextPaint.setAntiAlias(true);
  mTextPaint.setTextSize(fontSize);
  mCharHeight=(int)FloatMath.ceil(mTextPaint.getFontSpacing());
  mCharAscent=(int)FloatMath.ceil(mTextPaint.ascent());
  mCharDescent=mCharHeight + mCharAscent;
  mCharWidth=mTextPaint.measureText(EXAMPLE_CHAR,0,1);
}
 

Example 8

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 9

From project android_packages_apps_Gallery2, under directory /gallerycommon/src/com/android/gallery3d/common/.

Source file: BitmapUtils.java

  19 
vote

private static int computeInitialSampleSize(int w,int h,int minSideLength,int maxNumOfPixels){
  if (maxNumOfPixels == UNCONSTRAINED && minSideLength == UNCONSTRAINED)   return 1;
  int lowerBound=(maxNumOfPixels == UNCONSTRAINED) ? 1 : (int)FloatMath.ceil(FloatMath.sqrt((float)(w * h) / maxNumOfPixels));
  if (minSideLength == UNCONSTRAINED) {
    return lowerBound;
  }
 else {
    int sampleSize=Math.min(w / minSideLength,h / minSideLength);
    return Math.max(sampleSize,lowerBound);
  }
}
 

Example 10

From project android_packages_apps_Gallery3D, under directory /src/com/cooliris/media/.

Source file: FloatAnim.java

  19 
vote

private float getInterpolatedValue(long currentTime){
  float ratio=(float)(currentTime - mStartTime) * 0.001f / mDuration;
  if (ratio >= 1f) {
    mStartTime=0;
    return mValue;
  }
 else {
    ratio=0.5f - 0.5f * FloatMath.cos(ratio * 3.14159265f);
    return mValue + (1f - ratio) * mDelta;
  }
}
 

Example 11

From project Common-Sense-Net-2, under directory /AndroidBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 12

From project connectbot, under directory /src/sk/vx/connectbot/service/.

Source file: TerminalBridge.java

  19 
vote

/** 
 * Request a different font size. Will make call to parentChanged() to make sure we resize PTY if needed.
 */
final void setFontSize(float size){
  if (size <= 0.0)   return;
  defaultPaint.setTextSize(size);
  fontSize=size;
  FontMetrics fm=defaultPaint.getFontMetrics();
  charTop=(int)FloatMath.ceil(fm.top);
  float[] widths=new float[1];
  defaultPaint.getTextWidths("X",widths);
  charWidth=(int)FloatMath.ceil(widths[0]);
  charHeight=(int)FloatMath.ceil(fm.descent - fm.top);
  if (parent != null)   parentChanged(parent);
  for (  FontSizeChangedListener ofscl : fontSizeChangedListeners)   ofscl.onFontSizeChanged(size);
  host.setFontSize((int)fontSize);
  manager.hostdb.updateFontSize(host);
}
 

Example 13

From project cw-omnibus, under directory /external/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 14

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 15

From project dmix, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 16

From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 17

From project eoit, under directory /EOIT/src/fr/eoit/activity/fragment/blueprint/.

Source file: InventionFragment.java

  19 
vote

private void updateInventionChances(){
  inventionChances=FormulaCalculator.calculateInventionChances(FormulaCalculator.getBaseInventionChances(producedItemId,producedItemGroupId),encryptionSkillLevel,datacore1SkillLevel,datacore2SkillLevel,metaLevel,currentDecryptorBonuses.probabilityMultiplier);
  numberOfChances=(int)FloatMath.ceil(1 / (inventionChances));
  inventionChancesTextView.setText(nfPercent.format(inventionChances));
  requiredItemsInventionFragment.setParentFragment(this);
  requiredItemsInventionFragment.setDecryptorId(decryptorId);
  requiredItemsInventionFragment.setNumberOfChances(numberOfChances);
}
 

Example 18

From project examples_2, under directory /SearchView/actionbarsherlock-lib/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 19

From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 20

From project FBReaderJ, under directory /src/org/geometerplus/android/fbreader/image/.

Source file: ImageViewActivity.java

  19 
vote

private boolean onDoubleTouchEvent(MotionEvent event){
switch (event.getAction() & MotionEvent.ACTION_MASK) {
case MotionEvent.ACTION_POINTER_UP:
    myStartPinchDistance2=-1;
  break;
case MotionEvent.ACTION_POINTER_DOWN:
{
  final float diffX=event.getX(0) - event.getX(1);
  final float diffY=event.getY(0) - event.getY(1);
  myStartPinchDistance2=Math.max(diffX * diffX + diffY * diffY,10f);
  myStartZoomFactor=myZoomFactor;
  break;
}
case MotionEvent.ACTION_MOVE:
{
final float diffX=event.getX(0) - event.getX(1);
final float diffY=event.getY(0) - event.getY(1);
final float distance2=Math.max(diffX * diffX + diffY * diffY,10f);
if (myStartPinchDistance2 < 0) {
  myStartPinchDistance2=distance2;
  myStartZoomFactor=myZoomFactor;
}
 else {
  myZoomFactor=myStartZoomFactor * FloatMath.sqrt(distance2 / myStartPinchDistance2);
  postInvalidate();
}
}
break;
}
return true;
}
 

Example 21

From project finch, under directory /libs/JakeWharton-ActionBarSherlock-2eabf25/library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 22

From project Gaggle, under directory /src/com/geeksville/location/.

Source file: LocationUtils.java

  19 
vote

/** 
 * Convert distance between two lat/long points into meters
 * @param lat_a
 * @param lng_a
 * @param lat_b
 * @param lng_b
 * @return
 */
public static double LatLongToMeter(float lat_a,float lng_a,float lat_b,float lng_b){
  float pk=(float)(180 / 3.14169);
  float a1=lat_a / pk;
  float a2=lng_a / pk;
  float b1=lat_b / pk;
  float b2=lng_b / pk;
  float t1=FloatMath.cos(a1) * FloatMath.cos(a2) * FloatMath.cos(b1)* FloatMath.cos(b2);
  float t2=FloatMath.cos(a1) * FloatMath.sin(a2) * FloatMath.cos(b1)* FloatMath.sin(b2);
  float t3=FloatMath.sin(a1) * FloatMath.sin(b1);
  double tt=Math.acos(t1 + t2 + t3);
  if (Double.isNaN(tt))   tt=0;
  return 6366000 * tt;
}
 

Example 23

From project gesture-imageview, under directory /main/src/com/polites/android/.

Source file: MathUtils.java

  19 
vote

/** 
 * Rotates p1 around p2 by angle degrees.
 * @param p1
 * @param p2
 * @param angle
 */
public void rotate(PointF p1,PointF p2,float angle){
  float px=p1.x;
  float py=p1.y;
  float ox=p2.x;
  float oy=p2.y;
  p1.x=(FloatMath.cos(angle) * (px - ox) - FloatMath.sin(angle) * (py - oy) + ox);
  p1.y=(FloatMath.sin(angle) * (px - ox) + FloatMath.cos(angle) * (py - oy) + oy);
}
 

Example 24

From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 25

From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 26

From project HSR-Timetable, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 27

From project iosched_3, under directory /libprojects/abs/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 28

From project IRC-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 29

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/text/.

Source file: BoringLayout.java

  19 
vote

void init(CharSequence source,TextPaint paint,int outerwidth,Alignment align,float spacingmult,float spacingadd,BoringLayout.Metrics metrics,boolean includepad,boolean trustWidth){
  int spacing;
  if (source instanceof String && align == Layout.Alignment.ALIGN_NORMAL) {
    mDirect=source.toString();
  }
 else {
    mDirect=null;
  }
  mPaint=paint;
  if (includepad) {
    spacing=metrics.bottom - metrics.top;
  }
 else {
    spacing=metrics.descent - metrics.ascent;
  }
  if (spacingmult != 1 || spacingadd != 0) {
    spacing=(int)(spacing * spacingmult + spacingadd + 0.5f);
  }
  mBottom=spacing;
  if (includepad) {
    mDesc=spacing + metrics.top;
  }
 else {
    mDesc=spacing + metrics.ascent;
  }
  if (trustWidth) {
    mMax=metrics.width;
  }
 else {
synchronized (sTemp) {
      mMax=(int)(FloatMath.ceil(Styled.measureText(paint,sTemp,source,0,source.length(),null)));
    }
  }
  if (includepad) {
    mTopPadding=metrics.top - metrics.ascent;
    mBottomPadding=metrics.bottom - metrics.descent;
  }
}
 

Example 30

From project lightbox-android-webservices, under directory /LightboxAndroidWebServices/src/com/lightbox/android/bitmap/.

Source file: BitmapUtils.java

  19 
vote

public static Bitmap decodeFile(String pathName,int maxWidth,int maxHeight){
  Options options=new Options();
  options.inJustDecodeBounds=true;
  int sampleSize=1;
  options.inSampleSize=sampleSize;
  BitmapFactory.decodeFile(pathName,options);
  if (maxWidth < options.outWidth || maxHeight < options.outHeight) {
    int sampleSizeW=(int)FloatMath.ceil((float)options.outWidth / maxWidth);
    int sampleSizeH=(int)FloatMath.ceil((float)options.outHeight / maxHeight);
    sampleSize=Math.max(sampleSizeW,sampleSizeH);
    options.inSampleSize=sampleSize;
  }
  options.inJustDecodeBounds=false;
  return BitmapFactory.decodeFile(pathName,options);
}
 

Example 31

From project liquidroid, under directory /src/com/viewpagerindicator/.

Source file: LinePageIndicator.java

  19 
vote

/** 
 * Determines the width of this view
 * @param measureSpec A measureSpec packed into an int
 * @return The width of the view, honoring constraints from measureSpec
 */
private int measureWidth(int measureSpec){
  float result=0;
  int specMode=MeasureSpec.getMode(measureSpec);
  int specSize=MeasureSpec.getSize(measureSpec);
  if ((specMode == MeasureSpec.EXACTLY) || (mViewPager == null)) {
    result=specSize;
  }
 else {
    final int count=mViewPager.getAdapter().getCount();
    result=getPaddingLeft() + getPaddingRight() + (count * mLineWidth)+ ((count - 1) * mGapWidth);
    if (specMode == MeasureSpec.AT_MOST) {
      result=Math.min(result,specSize);
    }
  }
  return (int)FloatMath.ceil(result);
}
 

Example 32

From project maven-android-plugin-samples, under directory /apidemos-android-10/application/src/main/java/com/example/android/apis/graphics/.

Source file: BitmapMesh.java

  19 
vote

private void warp(float cx,float cy){
  final float K=10000;
  float[] src=mOrig;
  float[] dst=mVerts;
  for (int i=0; i < COUNT * 2; i+=2) {
    float x=src[i + 0];
    float y=src[i + 1];
    float dx=cx - x;
    float dy=cy - y;
    float dd=dx * dx + dy * dy;
    float d=FloatMath.sqrt(dd);
    float pull=K / (dd + 0.000001f);
    pull/=(d + 0.000001f);
    if (pull >= 1) {
      dst[i + 0]=cx;
      dst[i + 1]=cy;
    }
 else {
      dst[i + 0]=x + dx * pull;
      dst[i + 1]=y + dy * pull;
    }
  }
}
 

Example 33

From project mediaphone, under directory /src/ac/robinson/mediaphone/view/.

Source file: VUMeter.java

  19 
vote

@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  canvas.drawColor(Color.BLACK);
  float angle=mMinAngle;
  if (mRecorder != null) {
    angle+=(float)(mMaxAngle - mMinAngle) * mRecorder.getMaxAmplitude() / 16384f;
  }
  if (angle > mCurrentAngle || mRecorder == null) {
    mCurrentAngle=angle;
  }
 else {
    mCurrentAngle=Math.max(angle,mCurrentAngle - DROPOFF_STEP);
  }
  mCurrentAngle=Math.min(mMaxAngle,mCurrentAngle);
  if (mCurrentAngle > mMinAngle && !mRecordingStarted) {
    mRecordingStarted=true;
    if (mRecordingStartedCallback != null) {
      mRecordingStartedCallback.recordingStarted();
    }
  }
  float w=getWidth();
  float h=getHeight();
  float pivotX=w / 2;
  float pivotY=h - PIVOT_RADIUS - PIVOT_Y_OFFSET;
  float l=h * 0.89f;
  float sin=FloatMath.sin(mCurrentAngle);
  float cos=FloatMath.cos(mCurrentAngle);
  float x0=pivotX - l * cos;
  float y0=pivotY - l * sin;
  mDrawRect.set(0,0,(int)w,(int)h);
  canvas.drawPicture(mBackgroundDrawable,mDrawRect);
  canvas.drawLine(x0 + SHADOW_OFFSET,y0 + SHADOW_OFFSET,pivotX + SHADOW_OFFSET,pivotY + SHADOW_OFFSET,mShadow);
  canvas.drawCircle(pivotX + SHADOW_OFFSET,pivotY + SHADOW_OFFSET,SHADOW_RADIUS,mShadow);
  canvas.drawLine(x0,y0,pivotX,pivotY,mPaint);
  canvas.drawCircle(pivotX,pivotY,PIVOT_RADIUS,mPaint);
  if (mRecorder != null && mRecorder.isRecording()) {
    postInvalidateDelayed(ANIMATION_INTERVAL);
  }
}
 

Example 34

From project mediautilities, under directory /src/com/polites/android/.

Source file: MathUtils.java

  19 
vote

/** 
 * Rotates p1 around p2 by angle degrees.
 * @param p1
 * @param p2
 * @param angle
 */
public void rotate(PointF p1,PointF p2,float angle){
  float px=p1.x;
  float py=p1.y;
  float ox=p2.x;
  float oy=p2.y;
  p1.x=(FloatMath.cos(angle) * (px - ox) - FloatMath.sin(angle) * (py - oy) + ox);
  p1.y=(FloatMath.sin(angle) * (px - ox) + FloatMath.cos(angle) * (py - oy) + oy);
}
 

Example 35

From project MensaUPB, under directory /libs/ActionbarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 36

From project mixare, under directory /plugins/mixare-library/src/org/mixare/lib/gui/.

Source file: ScreenLine.java

  19 
vote

public void rotate(float t){
  float xp=(float)FloatMath.cos(t) * x - (float)FloatMath.sin(t) * y;
  float yp=(float)FloatMath.sin(t) * x + (float)FloatMath.cos(t) * y;
  x=xp;
  y=yp;
}
 

Example 37

From project mWater-Android-App, under directory /android/actionbarsherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 38

From project MyHeath-Android, under directory /actionbarlib/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 39

From project OAK, under directory /oak-library/src/main/java/oak/util/.

Source file: ScaleGestureDetector.java

  19 
vote

/** 
 * Return the current distance between the two pointers forming the gesture in progress.
 * @return Distance between pointers in pixels.
 */
public float getCurrentSpan(){
  if (mCurrLen == -1) {
    final float cvx=mCurrFingerDiffX;
    final float cvy=mCurrFingerDiffY;
    mCurrLen=FloatMath.sqrt(cvx * cvx + cvy * cvy);
  }
  return mCurrLen;
}
 

Example 40

From project onebusaway-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 41

From project open311-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 42

From project packages_apps_Camera_1, under directory /src/com/android/camera/.

Source file: Camera.java

  19 
vote

private float getDistance(MotionEvent e){
  if (e.getPointerCount() < 2)   return 0;
  float x=e.getX(0) - e.getX(1);
  float y=e.getY(0) - e.getY(1);
  return FloatMath.sqrt(x * x + y * y);
}
 

Example 43

From project packages_apps_Camera_2, under directory /src/com/android/camera/.

Source file: Camera.java

  19 
vote

private float getDistance(MotionEvent e){
  if (e.getPointerCount() < 2)   return 0;
  float x=e.getX(0) - e.getX(1);
  float y=e.getY(0) - e.getY(1);
  return FloatMath.sqrt(x * x + y * y);
}
 

Example 44

From project parandroid, under directory /src/com/rabenauge/parandroid/.

Source file: CopperBars.java

  19 
vote

private static void calcCylinderGeom(float radius,float length,int sides,IntBuffer coords,IntBuffer normals){
  length*=65536 / 2;
  int g=0, offset=sides * 3;
  for (int i=0; i < sides; ++i) {
    float angle=(float)i / sides * DemoMath.PI * 2;
    float x=FloatMath.cos(angle) * 65536;
    float y=FloatMath.sin(angle) * 65536;
    int xc=(int)(x * radius);
    int yc=(int)(y * radius);
    int zc=(int)(length);
    coords.put(g,xc);
    coords.put(g + 1,yc);
    coords.put(g + 2,zc);
    coords.put(offset + g,xc);
    coords.put(offset + g + 1,yc);
    coords.put(offset + g + 2,-zc);
    normals.put(g,(int)x);
    normals.put(g + 1,(int)y);
    normals.put(g + 2,0);
    normals.put(offset + g,(int)x);
    normals.put(offset + g + 1,(int)y);
    normals.put(offset + g + 2,0);
    g+=3;
  }
}
 

Example 45

From project platform_packages_apps_camera, under directory /src/com/android/camera/.

Source file: CameraSettings.java

  19 
vote

private void buildExposureCompensation(PreferenceGroup group,ListPreference exposure){
  int max=mParameters.getMaxExposureCompensation();
  int min=mParameters.getMinExposureCompensation();
  if (max == 0 && min == 0) {
    removePreference(group,exposure.getKey());
    return;
  }
  float step=mParameters.getExposureCompensationStep();
  int maxValue=(int)FloatMath.floor(max * step);
  int minValue=(int)FloatMath.ceil(min * step);
  CharSequence entries[]=new CharSequence[maxValue - minValue + 1];
  CharSequence entryValues[]=new CharSequence[maxValue - minValue + 1];
  for (int i=minValue; i <= maxValue; ++i) {
    entryValues[maxValue - i]=Integer.toString(Math.round(i / step));
    StringBuilder builder=new StringBuilder();
    if (i > 0)     builder.append('+');
    entries[maxValue - i]=builder.append(i).toString();
  }
  exposure.setEntries(entries);
  exposure.setEntryValues(entryValues);
}
 

Example 46

From project PocketVDC, under directory /src/sate/pocketvdc/rendering/.

Source file: PocketVDCRenderer.java

  19 
vote

/** 
 * @param event the touch event
 * @return distance between two fingers
 */
private float spacing(MotionEvent event){
  if (event.getPointerCount() >= 2) {
    float x=event.getX(0) - event.getX(1);
    float y=event.getY(0) - event.getY(1);
    return FloatMath.sqrt(x * x + y * y);
  }
  return this.oldDist;
}
 

Example 47

From project QuickSnap, under directory /Camera/src/com/lightbox/android/camera/.

Source file: CameraSettings.java

  19 
vote

private void buildExposureCompensation(PreferenceGroup group,ListPreference exposure){
  int max=ParameterUtils.getMaxExposureCompensation(mParameters);
  int min=ParameterUtils.getMinExposureCompensation(mParameters);
  if (max == 0 && min == 0) {
    removePreference(group,exposure.getKey());
    return;
  }
  float step=ParameterUtils.getExposureCompensationStep(mParameters);
  int maxValue=(int)FloatMath.floor(max * step);
  int minValue=(int)FloatMath.ceil(min * step);
  CharSequence entries[]=new CharSequence[maxValue - minValue + 1];
  CharSequence entryValues[]=new CharSequence[maxValue - minValue + 1];
  for (int i=minValue; i <= maxValue; ++i) {
    entryValues[maxValue - i]=Integer.toString(Math.round(i / step));
    StringBuilder builder=new StringBuilder();
    if (i > 0)     builder.append('+');
    entries[maxValue - i]=builder.append(i).toString();
  }
  exposure.setEntries(entries);
  exposure.setEntryValues(entryValues);
}
 

Example 48

From project Schedule, under directory /libs/android/sherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 49

From project SeriesGuide, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 50

From project Sketchy-Truck, under directory /andengine/src/org/anddev/andengine/engine/camera/hud/controls/.

Source file: AnalogOnScreenControl.java

  19 
vote

@Override protected void onUpdateControlKnob(final float pRelativeX,final float pRelativeY){
  if (pRelativeX * pRelativeX + pRelativeY * pRelativeY <= 0.25f) {
    super.onUpdateControlKnob(pRelativeX,pRelativeY);
  }
 else {
    final float angleRad=MathUtils.atan2(pRelativeY,pRelativeX);
    super.onUpdateControlKnob(FloatMath.cos(angleRad) * 0.5f,FloatMath.sin(angleRad) * 0.5f);
  }
}
 

Example 51

From project SMSSync, under directory /abslib/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 52

From project Something-Awful-Android, under directory /libraries/Sherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 53

From project The-Reverse-Recipe-Book, under directory /actionbarsherlock4.0/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 54

From project Unibeer, under directory /libs/sherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 55

From project valence, under directory /src/com/cafbit/valence/.

Source file: TouchPadHandler.java

  19 
vote

public void move(NormalMotionEvent nme){
  long nt=nme.t;
  float nx=nme.x * 100.0f / xdpi;
  float ny=nme.y * 100.0f / ydpi;
  if (nme.pc == 1 && pc > 1) {
    dt=0;
    dx=0.0f;
    dy=0.0f;
  }
 else {
    dt=nt - t;
    dx=nx - x;
    dy=ny - y;
  }
  t=nt;
  x=nx;
  y=ny;
  pc=nme.pc;
  d=FloatMath.sqrt(dx * dx + dy * dy);
  totalDistance+=d;
  if (pc > 1) {
    multiTouch=true;
    handleScroll(nme);
  }
 else {
    currentDirection=0;
    newDirection=0;
    newDirectionDistance=0.0f;
    sx=0.0f;
    sy=0.0f;
  }
}
 

Example 56

From project warda, under directory /src/app/warda/fotos/singlefotoview/logic/.

Source file: MathUtils.java

  19 
vote

/** 
 * Rotates p1 around p2 by angle degrees.
 * @param p1
 * @param p2
 * @param angle
 */
public void rotate(PointF p1,PointF p2,float angle){
  float px=p1.x;
  float py=p1.y;
  float ox=p2.x;
  float oy=p2.y;
  p1.x=(FloatMath.cos(angle) * (px - ox) - FloatMath.sin(angle) * (py - oy) + ox);
  p1.y=(FloatMath.sin(angle) * (px - ox) + FloatMath.cos(angle) * (py - oy) + oy);
}
 

Example 57

From project Wifileaks, under directory /WifiLeaks/ABS/library/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 58

From project XTrade, under directory /sherlock-bar/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 59

From project Yaaic, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/nineoldandroids/view/animation/.

Source file: AnimatorProxy.java

  19 
vote

private void invalidateAfterUpdate(){
  View view=mView.get();
  if (view == null) {
    return;
  }
  View parent=(View)view.getParent();
  if (parent == null) {
    return;
  }
  view.setAnimation(this);
  final RectF after=mAfter;
  computeRect(after,view);
  after.union(mBefore);
  parent.invalidate((int)FloatMath.floor(after.left),(int)FloatMath.floor(after.top),(int)FloatMath.ceil(after.right),(int)FloatMath.ceil(after.bottom));
}
 

Example 60

From project yammp, under directory /src/org/yammp/util/.

Source file: ShakeListener.java

  19 
vote

@Override public void onSensorChanged(SensorEvent event){
  mCurrentTimeStamp=event.timestamp / 1000 / 1000;
  float eventX=event.values[SensorManager.DATA_X], eventY=event.values[SensorManager.DATA_Y], eventZ=event.values[SensorManager.DATA_Z];
  if (mFirstSensorUpdate) {
    mLastX=eventX;
    mLastY=eventY;
    mLastZ=eventZ;
    mLastUpdateTime=mCurrentTimeStamp;
    mFirstDeltaUpdate=true;
    mFirstSensorUpdate=false;
    return;
  }
  float deltaX=eventX - mLastX, deltaY=eventY - mLastY, deltaZ=eventZ - mLastZ;
  mLastX=eventX;
  mLastY=eventY;
  mLastZ=eventZ;
  float deltaTimeForSpeed=mCurrentTimeStamp - mLastUpdateTime;
  mLastUpdateTime=mCurrentTimeStamp;
  if (mFirstDeltaUpdate) {
    mCurrentSpeed=FloatMath.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / deltaTimeForSpeed;
    mFirstDeltaUpdate=false;
    return;
  }
  mLastSpeed=mCurrentSpeed;
  mCurrentSpeed=FloatMath.sqrt(deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ) / deltaTimeForSpeed;
  float delta=Math.abs(mLastSpeed - mCurrentSpeed) / deltaTimeForSpeed * 1000 * 1000;
  if (delta > mShakeThreshold) {
    if (mCurrentTimeStamp > mLastShakeTimeStamp + mShakeInterval) {
      mLastShakeTimeStamp=mCurrentTimeStamp;
      notifyListeners();
    }
  }
}