Java Code Examples for android.graphics.Paint

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 Android, under directory /app/src/main/java/com/github/mobile/ui/issue/.

Source file: LabelDrawableSpan.java

  18 
vote

@Override public void draw(final Canvas canvas){
  super.draw(canvas);
  layers.draw(canvas);
  final Paint paint=getPaint();
  final int original=paint.getColor();
  paint.setColor(textColor);
  canvas.drawText(name,paddingLeft,height - ((height - textHeight) / 2),paint);
  paint.setColor(original);
}
 

Example 2

From project android-thaiime, under directory /latinime/src/com/android/inputmethod/accessibility/.

Source file: AccessibleKeyboardViewProxy.java

  18 
vote

private void initInternal(InputMethodService inputMethod,SharedPreferences prefs){
  final Paint paint=new Paint();
  paint.setTextAlign(Paint.Align.LEFT);
  paint.setTextSize(14.0f);
  paint.setAntiAlias(true);
  paint.setColor(Color.YELLOW);
  mInputMethod=inputMethod;
  mGestureDetector=new KeyboardFlickGestureDetector(inputMethod);
}
 

Example 3

From project Android_1, under directory /PropagatedIntents/src/com/example/android/notepad/.

Source file: NoteEditor.java

  18 
vote

@Override protected void onDraw(Canvas canvas){
  int count=getLineCount();
  Rect r=mRect;
  Paint paint=mPaint;
  for (int i=0; i < count; i++) {
    int baseline=getLineBounds(i,r);
    canvas.drawLine(r.left,baseline + 1,r.right,baseline + 1,paint);
  }
  super.onDraw(canvas);
}
 

Example 4

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

Source file: BitmapUtils.java

  18 
vote

public static Bitmap resizeBitmapByScale(Bitmap bitmap,float scale,boolean recycle){
  int width=Math.round(bitmap.getWidth() * scale);
  int height=Math.round(bitmap.getHeight() * scale);
  if (width == bitmap.getWidth() && height == bitmap.getHeight())   return bitmap;
  Bitmap target=Bitmap.createBitmap(width,height,getConfig(bitmap));
  Canvas canvas=new Canvas(target);
  canvas.scale(scale,scale);
  Paint paint=new Paint(Paint.FILTER_BITMAP_FLAG | Paint.DITHER_FLAG);
  canvas.drawBitmap(bitmap,0,0,paint);
  if (recycle)   bitmap.recycle();
  return target;
}
 

Example 5

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

Source file: StringTexture.java

  18 
vote

public static int computeTextWidthForConfig(float textSize,Typeface typeface,String string){
  Paint paint=sPaint;
synchronized (paint) {
    paint.setAntiAlias(true);
    paint.setTypeface(typeface);
    paint.setTextSize(textSize);
    return (int)(10.0f * App.PIXEL_DENSITY) + (int)FloatMath.ceil(paint.measureText(string));
  }
}
 

Example 6

From project android_packages_inputmethods_LatinIME, under directory /java/src/com/android/inputmethod/accessibility/.

Source file: AccessibleKeyboardViewProxy.java

  18 
vote

private void initInternal(InputMethodService inputMethod,SharedPreferences prefs){
  final Paint paint=new Paint();
  paint.setTextAlign(Paint.Align.LEFT);
  paint.setTextSize(14.0f);
  paint.setAntiAlias(true);
  paint.setColor(Color.YELLOW);
  mInputMethod=inputMethod;
  mGestureDetector=new KeyboardFlickGestureDetector(inputMethod);
}
 

Example 7

From project android_packages_wallpapers_MusicVisualization, under directory /src/com/android/musicvis/vis1/.

Source file: Visualization1.java

  18 
vote

@Override public void onCreate(SurfaceHolder surfaceHolder){
  super.onCreate(surfaceHolder);
  final Paint paint=mPaint;
  paint.setColor(0xffffffff);
  paint.setAntiAlias(true);
  paint.setStrokeWidth(2);
  paint.setStrokeCap(Paint.Cap.ROUND);
  paint.setStyle(Paint.Style.STROKE);
  mStartTime=SystemClock.elapsedRealtime();
}
 

Example 8

From project beintoo-android-sdk, under directory /BeintooSDK/src/com/beintoo/beintoosdkutility/.

Source file: BDrawableGradient.java

  18 
vote

public Canvas beintooGrayGradient(int h,Canvas canvas){
  Paint p=new Paint();
  int[] colors={0xffCBCFD3,0xffB6BECA};
  float[] positions={0.0f,0.5f};
  p.setShader(new LinearGradient(0,0,0,h,colors,positions,Shader.TileMode.MIRROR));
  canvas.drawPaint(p);
  return canvas;
}
 

Example 9

From project AirCastingAndroidClient, under directory /src/main/java/pl/llp/aircasting/view/.

Source file: NoisePlot.java

  17 
vote

@Override protected void onDraw(Canvas canvas){
  Stopwatch stopwatch=new Stopwatch().start();
  bottom=settingsHelper.getThreshold(sensor,MeasurementLevel.VERY_LOW);
  top=settingsHelper.getThreshold(sensor,MeasurementLevel.VERY_HIGH);
  drawBackground(canvas);
  if (!measurements.isEmpty()) {
    measurements=aggregator.smoothenSamplesToReduceCount(newArrayList(measurements),1000);
    Path path=new Path();
    float lastY=project(measurements.get(0).getValue());
    path.moveTo(0,lastY);
    for (int i=1; i < measurements.size(); i++) {
      Measurement measurement=measurements.get(i);
      Point place=place(measurement);
      path.lineTo(place.x,place.y);
    }
    Constants.logGraphPerformance("onDraw to path creation took " + stopwatch.elapsedMillis());
    initializePaint();
    canvas.drawPath(path,paint);
    Constants.logGraphPerformance("onDraw to path draw took " + stopwatch.elapsedMillis());
    for (    Note note : notes) {
      drawNote(canvas,note);
    }
    if (settingsHelper.showGraphMetadata()) {
      String message="[" + measurements.size() + "] pts";
      String message2="drawing took " + stopwatch.elapsedMillis();
      long textSize=getResources().getDimensionPixelSize(R.dimen.debugFontSize);
      Paint textPaint=new Paint();
      textPaint.setColor(Color.WHITE);
      textPaint.setAlpha(OPAQUE);
      textPaint.setAntiAlias(true);
      textPaint.setTextSize(textSize);
      float textWidth=Math.max(textPaint.measureText(message),textPaint.measureText(message2));
      canvas.drawText(message,getWidth() - textWidth - 5,getHeight() - textSize - 5,textPaint);
      canvas.drawText(message2,getWidth() - textWidth - 5,getHeight() - 5,textPaint);
    }
  }
}
 

Example 10

From project android-bankdroid, under directory /src/com/liato/bankdroid/.

Source file: LockableActivity.java

  17 
vote

@Override public boolean onCreateThumbnail(Bitmap outBitmap,Canvas canvas){
  View decorview=getWindow().getDecorView();
  if (decorview == null) {
    return true;
  }
  final int vw=decorview.getWidth();
  final int vh=decorview.getHeight();
  final int dw=outBitmap.getWidth();
  final int dh=outBitmap.getHeight();
  Bitmap bluredBitmap=Bitmap.createBitmap(outBitmap.getWidth(),outBitmap.getHeight(),outBitmap.getConfig());
  Canvas c=new Canvas(bluredBitmap);
  c.save();
  c.scale(((float)dw) / vw,((float)dh) / vh);
  decorview.draw(c);
  c.restore();
  canvas.drawBitmap(pixelate(bluredBitmap,5),0,0,null);
  Bitmap lockbitmap=BitmapFactory.decodeResource(getResources(),R.drawable.lock);
  Paint p=new Paint();
  p.setAntiAlias(true);
  p.setDither(true);
  p.setFilterBitmap(true);
  canvas.drawBitmap(lockbitmap,null,new RectF(dw * 0.25f,dh * 0.25f,dw * 0.75f,dh * 0.75f),p);
  return true;
}
 

Example 11

From project android-ocr, under directory /android/src/edu/sfsu/cs/orange/ocr/.

Source file: OcrResult.java

  17 
vote

public OcrResult(Bitmap bitmap,String text,int[] wordConfidences,int meanConfidence,List<Rect> regionBoundingBoxes,List<Rect> textlineBoundingBoxes,List<Rect> wordBoundingBoxes,List<Rect> stripBoundingBoxes,List<Rect> characterBoundingBoxes,long recognitionTimeRequired){
  this.bitmap=bitmap;
  this.text=text;
  this.wordConfidences=wordConfidences;
  this.meanConfidence=meanConfidence;
  this.regionBoundingBoxes=regionBoundingBoxes;
  this.textlineBoundingBoxes=textlineBoundingBoxes;
  this.wordBoundingBoxes=wordBoundingBoxes;
  this.stripBoundingBoxes=stripBoundingBoxes;
  this.characterBoundingBoxes=characterBoundingBoxes;
  this.recognitionTimeRequired=recognitionTimeRequired;
  this.timestamp=System.currentTimeMillis();
  this.paint=new Paint();
}
 

Example 12

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

Source file: Bitmap4x8FontRenderer.java

  17 
vote

public Bitmap4x8FontRenderer(Resources resources,ColorScheme scheme){
  super(scheme);
  int fontResource=AndroidCompat.SDK <= 3 ? R.drawable.atari_small : R.drawable.atari_small_nodpi;
  mFont=BitmapFactory.decodeResource(resources,fontResource);
  mPaint=new Paint();
  mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
}
 

Example 13

From project android-xbmcremote, under directory /src/org/xbmc/android/widget/.

Source file: FastScrollView.java

  17 
vote

@Override public void draw(Canvas canvas){
  super.draw(canvas);
  if (!mThumbVisible) {
    return;
  }
  final int y=mThumbY;
  final int viewWidth=getWidth();
  final FastScrollView.ScrollFade scrollFade=mScrollFade;
  int alpha=-1;
  if (scrollFade.mStarted) {
    alpha=scrollFade.getAlpha();
    if (alpha < ScrollFade.ALPHA_MAX / 2) {
      mCurrentThumb.setAlpha(alpha * 2);
    }
    int left=viewWidth - (mThumbW * alpha) / ScrollFade.ALPHA_MAX;
    mCurrentThumb.setBounds(left,0,viewWidth,mThumbH);
    mChangedBounds=true;
  }
  canvas.translate(0,y);
  mCurrentThumb.draw(canvas);
  canvas.translate(0,-y);
  if (mDragging && mDrawOverlay) {
    mOverlayDrawable.draw(canvas);
    final Paint paint=mPaint;
    float descent=paint.descent();
    final RectF rectF=mOverlayPos;
    canvas.drawText(mSectionText,(int)(rectF.left + rectF.right) / 2,(int)(rectF.bottom + rectF.top) / 2 + mOverlaySize / 4 - descent,paint);
  }
 else   if (alpha == 0) {
    scrollFade.mStarted=false;
    removeThumb();
  }
 else {
    invalidate(viewWidth - mThumbW,y,viewWidth,y + mThumbH);
  }
}
 

Example 14

From project AndroidDevWeekendDub-BookLibrary, under directory /src/org/curiouscreature/android/shelves/drawable/.

Source file: SpotlightDrawable.java

  17 
vote

public SpotlightDrawable(Context context,ViewGroup view,int resource){
  mView=view;
  mBitmap=BitmapFactory.decodeResource(context.getResources(),resource);
  mPaint=new Paint();
  mPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SCREEN));
}
 

Example 15

From project androidquery, under directory /src/com/androidquery/callback/.

Source file: BitmapAjaxCallback.java

  17 
vote

private static Bitmap getRoundedCornerBitmap(Bitmap bitmap,int pixels){
  Bitmap output=Bitmap.createBitmap(bitmap.getWidth(),bitmap.getHeight(),Config.ARGB_8888);
  Canvas canvas=new Canvas(output);
  final int color=0xff424242;
  final Paint paint=new Paint();
  final Rect rect=new Rect(0,0,bitmap.getWidth(),bitmap.getHeight());
  final RectF rectF=new RectF(rect);
  final float roundPx=pixels;
  paint.setAntiAlias(true);
  canvas.drawARGB(0,0,0,0);
  paint.setColor(color);
  canvas.drawRoundRect(rectF,roundPx,roundPx,paint);
  paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
  canvas.drawBitmap(bitmap,rect,rect,paint);
  return output;
}
 

Example 16

From project androidtracks, under directory /src/org/sfcta/cycletracks/.

Source file: ShowMap.java

  17 
vote

@Override public boolean draw(Canvas canvas,MapView mapView,boolean shadow,long when){
  super.draw(canvas,mapView,shadow);
  if (track.size() < 2)   return true;
  float[] points=new float[4 * track.size()];
  int segments=0;
  int startx=-1;
  int starty=-1;
  for (int i=0; i < track.size(); i++) {
    CyclePoint z=(CyclePoint)track.getItem(i).getPoint();
    if (z.accuracy > 8) {
      startx=-1;
      continue;
    }
    Point screenPoint=new Point();
    mapView.getProjection().toPixels(z,screenPoint);
    if (startx == -1) {
      startx=screenPoint.x;
      starty=screenPoint.y;
      continue;
    }
    int numpts=segments * 4;
    points[numpts]=startx;
    points[numpts + 1]=starty;
    points[numpts + 2]=startx=screenPoint.x;
    points[numpts + 3]=starty=screenPoint.y;
    segments++;
  }
  Paint paint=new Paint();
  paint.setARGB(255,0,0,255);
  paint.setStrokeWidth(5);
  paint.setStyle(Style.FILL_AND_STROKE);
  canvas.drawLines(points,0,segments * 4,paint);
  return false;
}
 

Example 17

From project android_aosp_packages_apps_Settings, under directory /src/com/android/settings/fuelgauge/.

Source file: BatteryHistoryChart.java

  17 
vote

void setColors(int[] colors){
  mColors=colors;
  mPaints=new Paint[colors.length];
  for (int i=0; i < colors.length; i++) {
    mPaints[i]=new Paint();
    mPaints[i].setColor(colors[i]);
    mPaints[i].setStyle(Paint.Style.FILL);
  }
}
 

Example 18

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

Source file: ActionMenuButton.java

  17 
vote

private void init(){
  setFocusable(true);
  setPadding(PADDING_H,0,PADDING_H,PADDING_V);
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setColor(getContext().getResources().getColor(R.color.bubble_dark_background));
}
 

Example 19

From project android_packages_wallpapers_basic, under directory /src/com/android/wallpaper/polarclock/.

Source file: PolarClockWallpaper.java

  17 
vote

@Override public void onCreate(SurfaceHolder surfaceHolder){
  super.onCreate(surfaceHolder);
  mPrefs=PolarClockWallpaper.this.getSharedPreferences(SHARED_PREFS_NAME,0);
  mPrefs.registerOnSharedPreferenceChangeListener(this);
  onSharedPreferenceChanged(mPrefs,null);
  mCalendar=new Time();
  mCalendar.setToNow();
  final Paint paint=mPaint;
  paint.setAntiAlias(true);
  paint.setStrokeWidth(DEFAULT_RING_THICKNESS);
  paint.setStrokeCap(Paint.Cap.ROUND);
  paint.setStyle(Paint.Style.STROKE);
  if (isPreview()) {
    mOffsetX=0.5f;
  }
}
 

Example 20

From project android_wallpaper_flowers, under directory /src/fi/harism/wallpaper/flowers/.

Source file: FlowerObjects.java

  17 
vote

/** 
 * Called once Surface has been created.
 * @param context Context to read resources from.
 */
public void onSurfaceCreated(Context context){
  mShaderSpline.setProgram(context.getString(R.string.shader_spline_vs),context.getString(R.string.shader_spline_fs));
  mShaderTexture.setProgram(context.getString(R.string.shader_texture_vs),context.getString(R.string.shader_texture_fs));
  GLES20.glDeleteTextures(1,mFlowerTextureId,0);
  GLES20.glGenTextures(1,mFlowerTextureId,0);
  GLES20.glBindTexture(GLES20.GL_TEXTURE_2D,mFlowerTextureId[0]);
  GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_S,GLES20.GL_CLAMP_TO_EDGE);
  GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_WRAP_T,GLES20.GL_CLAMP_TO_EDGE);
  GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MIN_FILTER,GLES20.GL_NEAREST);
  GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D,GLES20.GL_TEXTURE_MAG_FILTER,GLES20.GL_LINEAR);
  Bitmap bitmap=Bitmap.createBitmap(256,256,Bitmap.Config.ARGB_8888);
  bitmap.eraseColor(Color.BLACK);
  Canvas canvas=new Canvas(bitmap);
  Paint paint=new Paint();
  paint.setStyle(Paint.Style.FILL);
  int borderColor=Color.rgb((int)(.8f * 255),0,0);
  int mainColor=Color.rgb(255,0,0);
  float leafDist=1.7f * 128 / 3f;
  float leafPositions[]=new float[10];
  for (int i=0; i < 5; ++i) {
    double r=Math.PI * 2 * i / 5;
    leafPositions[i * 2 + 0]=128 + (float)(Math.sin(r) * leafDist);
    leafPositions[i * 2 + 1]=128 + (float)(Math.cos(r) * leafDist);
  }
  paint.setColor(borderColor);
  for (int i=0; i < 5; ++i) {
    canvas.drawCircle(leafPositions[i * 2 + 0],leafPositions[i * 2 + 1],48,paint);
  }
  paint.setColor(mainColor);
  for (int i=0; i < 5; ++i) {
    canvas.drawCircle(leafPositions[i * 2 + 0],leafPositions[i * 2 + 1],36,paint);
  }
  paint.setColor(borderColor);
  canvas.drawCircle(128,128,48,paint);
  paint.setColor(Color.BLACK);
  canvas.drawCircle(128,128,36,paint);
  GLUtils.texImage2D(GLES20.GL_TEXTURE_2D,0,bitmap,0);
  bitmap.recycle();
}
 

Example 21

From project apps-for-android, under directory /Amazed/src/com/example/amazed/.

Source file: AmazedView.java

  17 
vote

/** 
 * Custom view constructor.
 * @param context Application context
 * @param activity Activity controlling the view
 */
public AmazedView(Context context,Activity activity){
  super(context);
  mActivity=activity;
  mPaint=new Paint();
  mPaint.setTextSize(14);
  mPaint.setTypeface(mFont);
  mPaint.setAntiAlias(true);
  mSensorManager=(SensorManager)activity.getSystemService(Context.SENSOR_SERVICE);
  mSensorManager.registerListener(mSensorAccelerometer,SensorManager.SENSOR_ACCELEROMETER,SensorManager.SENSOR_DELAY_GAME);
  mMaze=new Maze(mActivity);
  mMarble=new Marble(this);
  mStrings=getResources().getStringArray(R.array.gameStrings);
  switchGameState(GAME_INIT);
}
 

Example 22

From project AquaNotesTest, under directory /src/com/google/android/apps/iosched/ui/widget/.

Source file: TimeRulerView.java

  17 
vote

@Override protected synchronized void onDraw(Canvas canvas){
  super.onDraw(canvas);
  final int hourHeight=mHourHeight;
  final Paint dividerPaint=mDividerPaint;
  dividerPaint.setColor(mDividerColor);
  dividerPaint.setStyle(Style.FILL);
  final Paint labelPaint=mLabelPaint;
  labelPaint.setColor(mLabelColor);
  labelPaint.setTextSize(mLabelTextSize);
  labelPaint.setTypeface(Typeface.DEFAULT_BOLD);
  labelPaint.setAntiAlias(true);
  final FontMetricsInt metrics=labelPaint.getFontMetricsInt();
  final int labelHeight=Math.abs(metrics.ascent);
  final int labelOffset=labelHeight + mLabelPaddingLeft;
  final int right=getRight();
  final int hours=mEndHour - mStartHour;
  for (int i=0; i < hours; i++) {
    final int dividerY=hourHeight * i;
    final int nextDividerY=hourHeight * (i + 1);
    canvas.drawLine(0,dividerY,right,dividerY,dividerPaint);
    canvas.drawRect(0,dividerY,mHeaderWidth,nextDividerY,dividerPaint);
    final int hour=mStartHour + i;
    String label;
    if (hour == 0) {
      label="12am";
    }
 else     if (hour <= 11) {
      label=hour + "am";
    }
 else     if (hour == 12) {
      label="12pm";
    }
 else {
      label=(hour - 12) + "pm";
    }
    final float labelWidth=labelPaint.measureText(label);
    canvas.drawText(label,0,label.length(),mHeaderWidth - labelWidth - mLabelPaddingLeft,dividerY + labelOffset,labelPaint);
  }
}
 

Example 23

From project BF3-Battlelog, under directory /src/net/peterkuterna/android/apps/swipeytabs/.

Source file: SwipeyTabs.java

  17 
vote

/** 
 * Initialize the SwipeyTabs  {@link ViewGroup}
 */
private void init(){
  setHorizontalFadingEdgeEnabled(true);
  setFadingEdgeLength((int)(getResources().getDisplayMetrics().density * 35.0f + 0.5f));
  setWillNotDraw(false);
  mCachedTabPaint=new Paint();
  mCachedTabPaint.setColor(mBottomBarColor);
}
 

Example 24

From project Binaural-Beats, under directory /src/com/ihunda/android/binauralbeat/viz/.

Source file: Flash.java

  17 
vote

public Flash(){
  pFlash1=new Paint();
  pFlash1.setStyle(Paint.Style.FILL);
  pFlash1.setColor(COLOR_FLASH1);
  pFlash2=new Paint();
  pFlash2.setStyle(Paint.Style.FILL);
  pFlash2.setColor(COLOR_FLASH2);
}
 

Example 25

From project abalone-android, under directory /src/com/bytopia/abalone/.

Source file: BoardRenderer.java

  16 
vote

/** 
 * Constructor that initializes brushes and images from resources.
 * @param view parent view to render the board onto
 */
public BoardRenderer(View view){
  this.view=view;
  Resources r=view.getResources();
  blackBallPicture=r.getDrawable(R.drawable.black_ball);
  whiteBallPicture=r.getDrawable(R.drawable.white_ball);
  emptyBallPicture=r.getDrawable(R.drawable.hole);
  defaultPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  defaultPaint.setColor(r.getColor(R.color.defaultColor));
  blackP=new Paint(Paint.ANTI_ALIAS_FLAG);
  blackP.setColor(Color.BLACK);
  whiteP=new Paint(Paint.ANTI_ALIAS_FLAG);
  whiteP.setColor(Color.WHITE);
  emptyP=new Paint(Paint.ANTI_ALIAS_FLAG);
  emptyP.setColor(Color.GRAY);
  highlightedP=new Paint(Paint.ANTI_ALIAS_FLAG);
  highlightedP.setColor(Color.RED);
  highlightedP.setAlpha(100);
  selectedP=new Paint(Paint.ANTI_ALIAS_FLAG);
  selectedP.setColor(Color.GREEN);
  selectedP.setAlpha(100);
  boardP=new Paint(Paint.ANTI_ALIAS_FLAG);
  boardP.setColor(r.getColor(R.color.board));
  dst=new Rect();
}
 

Example 26

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/entities/.

Source file: PictoView.java

  16 
vote

/** 
 * Method to link a photo to this arrow, giving the photo position on arrow layout
 * @param picture
 * @param x
 * @param y
 * @throws FileNotFoundException
 */
public Bitmap setSupport(Bitmap picture,float targetx,float targety,Context c) throws FileNotFoundException {
  Bitmap arrow=((BitmapDrawable)this.getDrawable()).getBitmap();
  float coeffx=targetx / getWidth();
  float coeffy=targety / getHeight();
  int scaledOffsetX=(int)(offsetx * coeffx);
  int scaledOffsetY=(int)(offsety * coeffy);
  Matrix matrix=new Matrix();
  matrix.postRotate(degree,(arrow.getWidth() / 2),(arrow.getHeight() / 2));
  arrow=Bitmap.createBitmap(arrow,0,0,arrow.getWidth(),arrow.getHeight(),matrix,true);
  Bitmap b=picture.copy(picture.getConfig(),true);
  Canvas myCanvas=new Canvas(b);
  myCanvas.drawBitmap(arrow,(b.getWidth() - arrow.getWidth()) / 2 + scaledOffsetX,(b.getHeight() - arrow.getHeight()) / 2 + scaledOffsetY,new Paint());
  b.compress(CompressFormat.JPEG,80,c.openFileOutput("arrowed.jpg",Context.MODE_PRIVATE));
  return b;
}
 

Example 27

From project Android-MapForgeFragment, under directory /library-common/src/com/jakewharton/android/mapsforge_fragment/.

Source file: CanvasRenderer.java

  16 
vote

@Override void setupRenderer(Bitmap bitmap){
  this.canvas=new Canvas(bitmap);
  this.symbolMatrix=new Matrix();
  this.bitmapFilterPaint=new Paint(Paint.FILTER_BITMAP_FLAG);
  this.tileFrame=new float[]{0,0,0,Tile.TILE_SIZE,0,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,Tile.TILE_SIZE,0};
  this.path=new Path();
  this.path.setFillType(Path.FillType.EVEN_ODD);
  this.stringBuilder=new StringBuilder(16);
  PAINT_TILE_COORDINATES.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  PAINT_TILE_COORDINATES.setTextSize(20);
  PAINT_TILE_COORDINATES_STROKE.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
  PAINT_TILE_COORDINATES_STROKE.setStyle(Paint.Style.STROKE);
  PAINT_TILE_COORDINATES_STROKE.setStrokeWidth(5);
  PAINT_TILE_COORDINATES_STROKE.setTextSize(20);
  PAINT_TILE_COORDINATES_STROKE.setColor(Color.WHITE);
}
 

Example 28

From project android-viewflow, under directory /viewflow/src/org/taptwo/android/widget/.

Source file: TitleFlowIndicator.java

  16 
vote

/** 
 * Initialize draw objects
 */
private void initDraw(int textColor,float textSize,int selectedColor,boolean selectedBold,float selectedSize,float footerLineHeight,int footerColor){
  paintText=new Paint();
  paintText.setColor(textColor);
  paintText.setTextSize(textSize);
  paintText.setAntiAlias(true);
  paintSelected=new Paint();
  paintSelected.setColor(selectedColor);
  paintSelected.setTextSize(selectedSize);
  paintSelected.setFakeBoldText(selectedBold);
  paintSelected.setAntiAlias(true);
  paintFooterLine=new Paint();
  paintFooterLine.setStyle(Paint.Style.FILL_AND_STROKE);
  paintFooterLine.setStrokeWidth(footerLineHeight);
  paintFooterLine.setColor(footerColor);
  paintFooterTriangle=new Paint();
  paintFooterTriangle.setStyle(Paint.Style.FILL_AND_STROKE);
  paintFooterTriangle.setColor(footerColor);
}
 

Example 29

From project androidTileMapEditor_1, under directory /src/it/sineo/android/tileMapEditor/.

Source file: TiledMapView.java

  16 
vote

public void init(Context context){
  tileSize=context.getResources().getDimensionPixelSize(R.dimen.tiledMap_tile);
  gridPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  gridPaint.setColor(Color.WHITE);
  gridPaint.setStrokeWidth(1.5f);
  gridPaint.setAlpha(128);
  debugPaint=new Paint(gridPaint);
  debugPaint.setColor(Color.CYAN);
  debugPaint.setAlpha(255);
  SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext());
  mustDrawGrid=prefs.getBoolean(C.PREFS_MAP_SHOW_GRID,C.DEFAULT_MAP_SHOW_GRID);
  mustExportGrid=prefs.getBoolean(C.PREFS_EXPORT_SHOW_GRID,C.DEFAULT_EXPORT_SHOW_GRID);
  emptyTileColor=prefs.getInt(C.PREFS_MAP_COLOR_EMPTY_TILE,C.DEFAULT_MAP_COLOR_EMPTY_TILE);
  prefs.registerOnSharedPreferenceChangeListener(this);
  emptyTilePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  emptyTilePaint.setColor(emptyTileColor);
  emptyTilePaint.setStyle(Paint.Style.FILL_AND_STROKE);
  mapRect=new RectF(0,0,0,0);
  currentTouchPoint=new PointInfo();
  fingerDownPoint=new PointInfo();
}
 

Example 30

From project Anki-Android, under directory /src/com/ichi2/anki/.

Source file: Whiteboard.java

  16 
vote

public Whiteboard(Context context,AttributeSet attrs){
  super(context,attrs);
  mBackgroundColor=context.getResources().getColor(R.color.wb_bg_color);
  mForegroundColor=context.getResources().getColor(R.color.wb_fg_color);
  mPaint=new Paint();
  mPaint.setAntiAlias(true);
  mPaint.setDither(true);
  mPaint.setColor(mForegroundColor);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeJoin(Paint.Join.ROUND);
  mPaint.setStrokeCap(Paint.Cap.ROUND);
  String wbStrokeWidth=PrefSettings.getSharedPrefs(context).getString("wbStrokeWidth","6");
  mPaint.setStrokeWidth(Integer.parseInt(wbStrokeWidth));
  createBitmap();
  mPath=new Path();
  mBitmapPaint=new Paint(Paint.DITHER_FLAG);
}
 

Example 31

From project BibleQuote-for-Android, under directory /src/com/BibleQuote/controls/ColorPicker/.

Source file: ColorPickerView.java

  16 
vote

private void initPaintTools(){
  mSatValPaint=new Paint();
  mSatValTrackerPaint=new Paint();
  mHuePaint=new Paint();
  mHueTrackerPaint=new Paint();
  mAlphaPaint=new Paint();
  mAlphaTextPaint=new Paint();
  mBorderPaint=new Paint();
  mSatValTrackerPaint.setStyle(Style.STROKE);
  mSatValTrackerPaint.setStrokeWidth(2f * mDensity);
  mSatValTrackerPaint.setAntiAlias(true);
  mHueTrackerPaint.setColor(mSliderTrackerColor);
  mHueTrackerPaint.setStyle(Style.STROKE);
  mHueTrackerPaint.setStrokeWidth(2f * mDensity);
  mHueTrackerPaint.setAntiAlias(true);
  mAlphaTextPaint.setColor(0xff1c1c1c);
  mAlphaTextPaint.setTextSize(14f * mDensity);
  mAlphaTextPaint.setAntiAlias(true);
  mAlphaTextPaint.setTextAlign(Align.CENTER);
  mAlphaTextPaint.setFakeBoldText(true);
}
 

Example 32

From project AChartEngine, under directory /achartengine/src/org/achartengine/chart/.

Source file: AbstractChart.java

  15 
vote

/** 
 * Draws the chart background.
 * @param renderer the chart renderer
 * @param canvas the canvas to paint to
 * @param x the top left x value of the view to draw to
 * @param y the top left y value of the view to draw to
 * @param width the width of the view to draw to
 * @param height the height of the view to draw to
 * @param paint the paint used for drawing
 * @param newColor if a new color is to be used
 * @param color the color to be used
 */
protected void drawBackground(DefaultRenderer renderer,Canvas canvas,int x,int y,int width,int height,Paint paint,boolean newColor,int color){
  if (renderer.isApplyBackgroundColor() || newColor) {
    if (newColor) {
      paint.setColor(color);
    }
 else {
      paint.setColor(renderer.getBackgroundColor());
    }
    paint.setStyle(Style.FILL);
    canvas.drawRect(x,y,x + width,y + height,paint);
  }
}
 

Example 33

From project android-cropimage, under directory /src/com/android/camera/.

Source file: HighlightView.java

  15 
vote

public void setup(Matrix m,Rect imageRect,RectF cropRect,boolean circle,boolean maintainAspectRatio){
  if (circle) {
    maintainAspectRatio=true;
  }
  mMatrix=new Matrix(m);
  mCropRect=cropRect;
  mImageRect=new RectF(imageRect);
  mMaintainAspectRatio=maintainAspectRatio;
  mCircle=circle;
  mInitialAspectRatio=mCropRect.width() / mCropRect.height();
  mDrawRect=computeLayout();
  mFocusPaint.setARGB(125,50,50,50);
  mNoFocusPaint.setARGB(125,50,50,50);
  mOutlinePaint.setStrokeWidth(3F);
  mOutlinePaint.setStyle(Paint.Style.STROKE);
  mOutlinePaint.setAntiAlias(true);
  mMode=ModifyMode.None;
  init();
}
 

Example 34

From project android_7, under directory /src/org/immopoly/android/widget/.

Source file: ClusterMarker.java

  15 
vote

static void init(DisplayMetrics displayMetrics,int markerHeight){
  textSize=(int)(TEXT_SIZE_DP * displayMetrics.density + 0.5f);
  textY=6 * displayMetrics.density;
  textX=-2.5f * displayMetrics.density;
  textPaint.setColor(0xFFFFFFFF);
  textPaint.setTextSize(textSize);
  textPaint.setAntiAlias(true);
  textPaint.setTextAlign(Align.CENTER);
  textPaint.setTypeface(Typeface.DEFAULT_BOLD);
  shadowPaint.setColor(0xFFB25200);
  shadowPaint.setTextSize(textSize);
  shadowPaint.setAntiAlias(true);
  shadowPaint.setTextAlign(Align.CENTER);
  shadowPaint.setFlags(Paint.FAKE_BOLD_TEXT_FLAG);
}
 

Example 35

From project Bitcoin-Wallet-for-Android, under directory /wallet/src/de/schildbach/wallet/ui/.

Source file: WalletBalanceFragment.java

  15 
vote

public void onLoadFinished(final Loader<Cursor> loader,final Cursor data){
  if (data != null) {
    data.moveToFirst();
    final Double exchangeRate=data.getDouble(data.getColumnIndexOrThrow(ExchangeRatesProvider.KEY_EXCHANGE_RATE));
    viewBalanceLocal.setVisibility(View.GONE);
    if (application.getWallet().getBalance(BalanceType.ESTIMATED).signum() > 0 && exchangeRate != null) {
      final String exchangeCurrency=prefs.getString(Constants.PREFS_KEY_EXCHANGE_CURRENCY,Constants.DEFAULT_EXCHANGE_CURRENCY);
      final BigInteger balance=wallet.getBalance(BalanceType.ESTIMATED);
      final BigInteger valueLocal=new BigDecimal(balance).multiply(new BigDecimal(exchangeRate)).toBigInteger();
      viewBalanceLocal.setVisibility(View.VISIBLE);
      viewBalanceLocal.setText(getString(R.string.wallet_balance_fragment_local_value,exchangeCurrency,WalletUtils.formatValue(valueLocal)));
      if (Constants.TEST)       viewBalanceLocal.setPaintFlags(viewBalanceLocal.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
    }
  }
}