Java Code Examples for android.graphics.Shader

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 mobilis, under directory /DemoApps/AdHocClientDemo/src/de/tudresden/inf/rn/mobilis/adhoc/demo/.

Source file: ColorPickerDialog.java

  22 
vote

ColorPickerView(Context c,OnColorChangedListener l,int color){
  super(c);
  mListener=l;
  mColors=new int[]{0xFFFF0000,0xFFFF00FF,0xFF0000FF,0xFF00FFFF,0xFF00FF00,0xFFFFFF00,0xFFFF0000};
  Shader s=new SweepGradient(0,0,mColors,null);
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setShader(s);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(32);
  mCenterPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mCenterPaint.setColor(color);
  mCenterPaint.setStrokeWidth(5);
}
 

Example 2

From project PageTurner, under directory /src/main/java/yuku/ambilwarna/.

Source file: AmbilWarnaKotak.java

  22 
vote

@Override protected void onDraw(Canvas canvas){
  super.onDraw(canvas);
  if (paint == null) {
    paint=new Paint();
    luar=new LinearGradient(0.f,0.f,0.f,this.getMeasuredHeight(),0xffffffff,0xff000000,TileMode.CLAMP);
  }
  int rgb=Color.HSVToColor(color);
  Shader dalam=new LinearGradient(0.f,0.f,this.getMeasuredWidth(),0.f,0xffffffff,rgb,TileMode.CLAMP);
  ComposeShader shader=new ComposeShader(luar,dalam,PorterDuff.Mode.MULTIPLY);
  paint.setShader(shader);
  canvas.drawRect(0.f,0.f,this.getMeasuredWidth(),this.getMeasuredHeight(),paint);
}
 

Example 3

From project platform_packages_apps_Gallery2_1, under directory /src/com/android/gallery3d/app/.

Source file: ColorPickerView.java

  22 
vote

ColorPickerView(Context c,OnColorChangedListener l,int color){
  super(c);
  mListener=l;
  mColors=new int[]{Color.WHITE,Color.GREEN,Color.GRAY,Color.MAGENTA,Color.YELLOW,Color.BLACK,Color.BLUE,Color.RED,Color.WHITE};
  Shader s=new SweepGradient(0,0,mColors,null);
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setShader(s);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(32);
  mCenterPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mCenterPaint.setColor(color);
  mCenterPaint.setStrokeWidth(5);
}
 

Example 4

From project RebeLauncher, under directory /src/com/dirtypepper/rebelauncher/.

Source file: ColorPickerDialog.java

  22 
vote

ColorPickerView(Context c,OnColorChangedListener l,int color){
  super(c);
  mListener=l;
  mColors=new int[]{0xFFFF0000,0xFFFF00FF,0xFF0000FF,0xFF00FFFF,0xFF00FF00,0xFFFFFF00,0xFFFFFFFF,0xFF808080,0xFF000000,0xFFFF0000};
  Shader s=new SweepGradient(0,0,mColors,null);
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setShader(s);
  mPaint.setStyle(Paint.Style.STROKE);
  mPaint.setStrokeWidth(CENTER_RADIUS);
  mCenterPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mCenterPaint.setColor(color);
  mCenterPaint.setStrokeWidth(5);
}
 

Example 5

From project ToDo-List-Widget, under directory /src/org/chrisbailey/todo/widgets/.

Source file: ColorCircle.java

  22 
vote

/** 
 * Initializes variables.
 */
void init(){
  mColors=new int[]{0xFFFF0000,0xFFFF00FF,0xFF0000FF,0xFF00FFFF,0xFF00FF00,0xFFFFFF00,0xFFFF0000};
  Shader s=new SweepGradient(0,0,mColors,null);
  mPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mPaint.setShader(s);
  mPaint.setStyle(Paint.Style.STROKE);
  mCenterPaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  mCenterPaint.setStrokeWidth(5);
}
 

Example 6

From project Barcamp-Bangalore-Android-App, under directory /bcb_app/src/com/bangalore/barcamp/.

Source file: BCBUtils.java

  21 
vote

public static void createActionBarOnActivity(final Activity activity,boolean isHome){
  ActionBar actionbar=(ActionBar)activity.findViewById(R.id.actionBar1);
  actionbar.setHomeLogo(R.drawable.home);
  actionbar.setHomeAction(new Action(){
    @Override public void performAction(    View view){
      ((SlidingMenuActivity)activity).toggle();
    }
    @Override public int getDrawable(){
      return R.drawable.home;
    }
  }
);
  actionbar.setTitle(R.string.app_title_text);
  TextView logo=(TextView)activity.findViewById(R.id.actionbar_title);
  Shader textShader=new LinearGradient(0,0,0,logo.getHeight(),new int[]{Color.WHITE,0xff999999},null,TileMode.CLAMP);
  logo.getPaint().setShader(textShader);
  actionbar.setOnTitleClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
    }
  }
);
}
 

Example 7

From project CityBikes, under directory /src/net/homelinux/penecoptero/android/citybikes/view/.

Source file: FlingTooltip.java

  21 
vote

private void init(Context context){
  height=getMeasuredHeight();
  width=getMeasuredWidth();
  scale=context.getResources().getDisplayMetrics().density;
  line_width=CircleHelper.dip2px(LINE_WIDTH,scale);
  margins=CircleHelper.dip2px(MARGINS,scale);
  arrow_width=CircleHelper.dip2px(ARROW_WIDTH,scale);
  rightPaint=new Paint();
  rightPaint.setStyle(Style.FILL);
  rightPaint.setStrokeWidth(1);
  rightPaint.setAntiAlias(true);
  rightPaint.setARGB(180,191,210,85);
  int startRight=Color.rgb(191,210,85);
  int endRight=Color.rgb(147,186,43);
  Shader rightShader=new LinearGradient(0,0,width,arrow_width * (float)0.835,startRight,endRight,Shader.TileMode.REPEAT);
  leftPaint=new Paint();
  leftPaint.setStyle(Style.FILL);
  leftPaint.setStrokeWidth(1);
  leftPaint.setAntiAlias(true);
  leftPaint.setARGB(180,147,186,228);
  int startLeft=Color.rgb(147,186,228);
  int endLeft=Color.rgb(95,121,150);
  Shader leftShader=new LinearGradient(0,0,width,arrow_width * (float)0.835,startLeft,endLeft,Shader.TileMode.REPEAT);
}
 

Example 8

From project GSM-Signal-Tracking-, under directory /gpstracker/src/nl/sogeti/android/gpstracker/viewer/.

Source file: SegmentOverlay.java

  21 
vote

private void lineToGeoPoint(GeoPoint geoPoint,double speed){
  setScreenPoint(geoPoint);
  if (speed > 0) {
    int greenfactor=(int)Math.min((127 * speed) / mAvgSpeed,255);
    int redfactor=255 - greenfactor;
    mCurrentColor=Color.rgb(redfactor,greenfactor,0);
  }
 else {
    int greenfactor=Color.green(mCurrentColor);
    int redfactor=Color.red(mCurrentColor);
    mCurrentColor=Color.argb(128,redfactor,greenfactor,0);
  }
  float distance=(float)distanceInPoints(this.mPrevDrawnScreenPoint,this.mScreenPoint);
  if (distance > MINIMUM_PX_DISTANCE) {
    int x_circle=(this.mPrevDrawnScreenPoint.x + this.mScreenPoint.x) / 2;
    int y_circle=(this.mPrevDrawnScreenPoint.y + this.mScreenPoint.y) / 2;
    float radius_factor=0.4f;
    Shader lastShader=new RadialGradient(x_circle,y_circle,distance,new int[]{mCurrentColor,mCurrentColor,Color.TRANSPARENT},new float[]{0,radius_factor,0.6f},TileMode.CLAMP);
    if (this.mShader != null) {
      this.mShader=new ComposeShader(this.mShader,lastShader,Mode.DST_OVER);
    }
 else {
      this.mShader=lastShader;
    }
    this.mPrevDrawnScreenPoint.x=this.mScreenPoint.x;
    this.mPrevDrawnScreenPoint.y=this.mScreenPoint.y;
  }
  this.mPathCalculation.lineTo(this.mScreenPoint.x,this.mScreenPoint.y);
}
 

Example 9

From project Pixelesque, under directory /src/de/devmil/common/ui/color/.

Source file: HsvAlphaSelectorView.java

  21 
vote

private void setAlphaImage(){
  if (imgAlpha.getHeight() <= 0) {
    dirty=true;
    invalidate();
    return;
  }
  Paint paint=new Paint();
  Shader shader;
  Bitmap drawCache=null;
  if (drawCache == null) {
    int colorFullAlpha=color | 0xFF000000;
    int colorNoAlpha=color & 0x00FFFFFF;
    shader=new LinearGradient(0,imgAlpha.getHeight(),0,0,colorNoAlpha,colorFullAlpha,TileMode.CLAMP);
    paint.setShader(shader);
    drawCache=Bitmap.createBitmap(imgAlpha.getWidth(),imgAlpha.getHeight(),Bitmap.Config.ARGB_8888);
    Canvas cacheCanvas=new Canvas(drawCache);
    cacheCanvas.drawRect(0.f,0.f,imgAlpha.getWidth(),imgAlpha.getHeight(),paint);
    imgAlpha.setImageBitmap(drawCache);
  }
}
 

Example 10

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 11

From project 4308Cirrus, under directory /Extras/actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 12

From project ActionBarSherlock, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 13

From project Amantech, under directory /Android/action_bar_sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 14

From project andlytics, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 15

From project androidZenWriter, under directory /library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 16

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

Source file: LinearColorBar.java

  19 
vote

private void updateIndicator(){
  int off=getPaddingTop() - getPaddingBottom();
  if (off < 0)   off=0;
  mRect.top=off;
  mRect.bottom=getHeight();
  if (mShowingGreen) {
    mColorGradientPaint.setShader(new LinearGradient(0,0,0,off - 2,RIGHT_COLOR & 0xffffff,RIGHT_COLOR,Shader.TileMode.CLAMP));
  }
 else {
    mColorGradientPaint.setShader(new LinearGradient(0,0,0,off - 2,MIDDLE_COLOR & 0xffffff,MIDDLE_COLOR,Shader.TileMode.CLAMP));
  }
  mEdgeGradientPaint.setShader(new LinearGradient(0,0,0,off / 2,0x00a0a0a0,0xffa0a0a0,Shader.TileMode.CLAMP));
}
 

Example 17

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

Source file: StringTexture.java

  19 
vote

@Override protected Bitmap load(RenderView view){
  if (mString == null)   return null;
  Paint paint=computePaint();
  String stringToDraw=mString;
  Config config=mConfig;
  Bitmap.Config bmConfig=Bitmap.Config.ARGB_4444;
  Paint.FontMetricsInt metrics=paint.getFontMetricsInt();
  int padding=1 + config.shadowRadius;
  int ascent=metrics.ascent - padding;
  int descent=metrics.descent + padding;
  int backWidth=mWidth;
  int backHeight=mHeight;
  String string=mString;
  Rect bounds=new Rect();
  paint.getTextBounds(string,0,string.length(),bounds);
  if (config.sizeMode == Config.SIZE_BOUNDS_TO_TEXT) {
    backWidth=bounds.width() + 2 * padding;
    int height=descent - ascent;
    backHeight=height + padding;
  }
  if (backWidth <= 0 || backHeight <= 0)   return null;
  Bitmap bitmap=Bitmap.createBitmap(backWidth,backHeight,bmConfig);
  Canvas canvas=new Canvas(bitmap);
  int x=(config.xalignment == Config.ALIGN_LEFT) ? padding : (config.xalignment == Config.ALIGN_RIGHT ? backWidth - padding : backWidth / 2);
  int y=(config.yalignment == Config.ALIGN_TOP) ? -metrics.top + padding : ((config.yalignment == Config.ALIGN_BOTTOM) ? (backHeight - descent) : ((int)backHeight - (descent + ascent)) / 2);
  canvas.drawText(stringToDraw,x,y,paint);
  if (bounds.width() > backWidth && config.overflowMode == Config.OVERFLOW_FADE) {
    float gradientLeft=backWidth - Config.FADE_WIDTH;
    LinearGradient gradient=new LinearGradient(gradientLeft,0,backWidth,0,0xffffffff,0x00ffffff,Shader.TileMode.CLAMP);
    paint=new Paint();
    paint.setSubpixelText(true);
    paint.setShader(gradient);
    paint.setDither(true);
    paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.MULTIPLY));
    canvas.drawRect(gradientLeft,0,backWidth,backHeight,paint);
  }
  mBaselineHeight=padding + metrics.bottom;
  return bitmap;
}
 

Example 18

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

Source file: BDrawableGradient.java

  19 
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 19

From project BookingRoom, under directory /src/org/androidaalto/bookingroom/view/.

Source file: WeekView.java

  19 
vote

/** 
 * @param rf
 * @param canvas
 * @param p
 */
private void drawNavigationButtons(RectF rf,Canvas canvas,Paint p){
  p.setTextSize(BIG_FONT_SIZE);
  p.setTextAlign(Paint.Align.CENTER);
  p.setTypeface(Typeface.DEFAULT_BOLD);
  p.setAntiAlias(true);
  canvas.save();
  rf.top=0;
  rf.bottom=getHeight();
  rf.left=mMaxViewX - mNavigationWidth;
  rf.right=mMaxViewX;
  p.setShader(new LinearGradient(rf.right,0,rf.left,0,mNavigationBackgroundDarkColor,mNavigationBackgroundColor,Shader.TileMode.MIRROR));
  canvas.drawRoundRect(rf,BIG_ROUND_RADIUS,BIG_ROUND_RADIUS,p);
  p.setShader(null);
  p.setColor(mNavigationTextColor);
  canvas.rotate(90);
  int x=mMaxViewY / 2 - mNavigationTextWidth / 2;
  int y=-mMaxViewX + (int)(mNavigationWidth * 0.75);
  canvas.drawText(mNextWeekStr,x,y,p);
  canvas.restore();
  rf.top=0;
  rf.bottom=getHeight();
  rf.left=0;
  rf.right=mNavigationWidth;
  canvas.save();
  p.setShader(new LinearGradient(rf.left,0,rf.right,0,mNavigationBackgroundDarkColor,mNavigationBackgroundColor,Shader.TileMode.MIRROR));
  canvas.drawRoundRect(rf,BIG_ROUND_RADIUS,BIG_ROUND_RADIUS,p);
  p.setShader(null);
  p.setColor(mNavigationTextColor);
  canvas.rotate(270);
  x=-mMaxViewY / 2 + mNavigationTextWidth / 2;
  y=(int)(mNavigationWidth * 0.75);
  canvas.drawText(mPreviousWeekStr,x,y,p);
  canvas.restore();
}
 

Example 20

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 21

From project cow, under directory /libs/ActionBarSherlock/library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 22

From project creamed_glacier_app_settings, under directory /src/com/android/settings/applications/.

Source file: LinearColorBar.java

  19 
vote

private void updateIndicator(){
  int off=getPaddingTop() - getPaddingBottom();
  if (off < 0)   off=0;
  mRect.top=off;
  mRect.bottom=getHeight();
  if (mShowingGreen) {
    mColorGradientPaint.setShader(new LinearGradient(0,0,0,off - 2,RIGHT_COLOR & 0xffffff,RIGHT_COLOR,Shader.TileMode.CLAMP));
  }
 else {
    mColorGradientPaint.setShader(new LinearGradient(0,0,0,off - 2,MIDDLE_COLOR & 0xffffff,MIDDLE_COLOR,Shader.TileMode.CLAMP));
  }
  mEdgeGradientPaint.setShader(new LinearGradient(0,0,0,off / 2,0x00a0a0a0,0xffa0a0a0,Shader.TileMode.CLAMP));
}
 

Example 23

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 24

From project DeskSMS, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 25

From project dmix, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 26

From project dreamDroid, under directory /libraries/ABS/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 27

From project examples_2, under directory /SearchView/actionbarsherlock-lib/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 28

From project farebot, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 29

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 30

From project GnucashMobile, under directory /com_actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 31

From project Google-Tasks-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 32

From project HeLauncher, under directory /src/com/tmobile/themechooser/.

Source file: ReflectionLayout.java

  19 
vote

public ReflectionLayout(Context context,AttributeSet attrs,int defStyle){
  super(context,attrs,defStyle);
  setWillNotDraw(false);
  mDarkPaint.setColor(0x98000000);
  mShader=new LinearGradient(0,0,0,1,0x00000000,0xFF000000,Shader.TileMode.CLAMP);
  mReflectionPaint.setShader(mShader);
  mReflectionPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT));
}
 

Example 33

From project HSR-Timetable, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 34

From project iosched_3, under directory /libprojects/abs/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 35

From project IRC-Client, under directory /actionbarsherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 36

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

Source file: ColorPickerDialog.java

  19 
vote

private void drawSVRegion(Canvas canvas){
  final float RESOLUTION=(float)0.01;
  for (float y=0; y < 1; y+=RESOLUTION) {
    mChroma=new int[10];
    int i=0;
    for (float x=0; i < 10; x+=0.1, i+=1) {
      mChroma[i]=setHSVColor(selectHue,x,y);
    }
    lg=new LinearGradient(OK_X0,0,OK_X1,0,mChroma,null,Shader.TileMode.CLAMP);
    mPaintC.setShader(lg);
    canvas.drawLine(OK_X0,OK_X0 + (CENTER_X * y),OK_X1,OK_X0 + (float)(CENTER_X * (y)),mPaintC);
  }
}
 

Example 37

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

Source file: Xfermodes.java

  19 
vote

public SampleView(Context context){
  super(context);
  mSrcB=makeSrc(W,H);
  mDstB=makeDst(W,H);
  Bitmap bm=Bitmap.createBitmap(new int[]{0xFFFFFFFF,0xFFCCCCCC,0xFFCCCCCC,0xFFFFFFFF},2,2,Bitmap.Config.RGB_565);
  mBG=new BitmapShader(bm,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT);
  Matrix m=new Matrix();
  m.setScale(6,6);
  mBG.setLocalMatrix(m);
}
 

Example 38

From project MensaUPB, under directory /libs/ActionbarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 39

From project mp3tunes-android, under directory /src/com/mp3tunes/android/.

Source file: RemoteImageView.java

  19 
vote

public void setArtwork(Bitmap art){
  mScale=1.00f;
  cX=0f;
  cY=0f;
  cR=0f;
  if (art == null) {
    BitmapFactory.Options opts=new BitmapFactory.Options();
    opts.inPreferredConfig=Bitmap.Config.ARGB_8888;
    art=BitmapFactory.decodeResource(getResources(),mUnknownImage,opts);
  }
  if (art != null) {
    mBit=art;
    mCoverPaint=new Paint();
    mCoverPaint.setFilterBitmap(true);
    mCoverPaint.setDither(true);
    BitmapShader sh1=new BitmapShader(mBit,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT);
    LinearGradient sh2=new LinearGradient(0f,mBit.getHeight(),0f,mBit.getHeight() / 3,0x7f000000,0x00000000,Shader.TileMode.CLAMP);
    Xfermode mode=new PorterDuffXfermode(PorterDuff.Mode.DST_IN);
    mReflectionShader=new ComposeShader(sh1,sh2,mode);
    mCamera=new Camera();
    mCamera.rotateY(cR);
    mCamera.translate(cX,cY,0);
  }
}
 

Example 40

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 41

From project MyHeath-Android, under directory /actionbarlib/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 42

From project NineOldAndroids, under directory /sample/src/com/jakewharton/nineoldandroids/sample/apidemos/.

Source file: AnimationCloning.java

  19 
vote

private ShapeHolder addBall(float x,float y){
  OvalShape circle=new OvalShape();
  circle.resize(50f * mDensity,50f * mDensity);
  ShapeDrawable drawable=new ShapeDrawable(circle);
  ShapeHolder shapeHolder=new ShapeHolder(drawable);
  shapeHolder.setX(x - 25f);
  shapeHolder.setY(y - 25f);
  int red=(int)(100 + Math.random() * 155);
  int green=(int)(100 + Math.random() * 155);
  int blue=(int)(100 + Math.random() * 155);
  int color=0xff000000 | red << 16 | green << 8 | blue;
  Paint paint=drawable.getPaint();
  int darkColor=0xff000000 | red / 4 << 16 | green / 4 << 8 | blue / 4;
  RadialGradient gradient=new RadialGradient(37.5f,12.5f,50f,color,darkColor,Shader.TileMode.CLAMP);
  paint.setShader(gradient);
  shapeHolder.setPaint(paint);
  balls.add(shapeHolder);
  return shapeHolder;
}
 

Example 43

From project No-Pain-No-Game, under directory /src/edu/ucla/cs/nopainnogame/weightchart/.

Source file: ChartDraw.java

  19 
vote

public void setSize(int sizeX,int sizeY){
  mSizeX=sizeX;
  mSizeY=sizeY;
  mGradientPaint.setShader(new LinearGradient(0,sizeY - 2.7f * mTextPaint.getTextSize(),0,sizeY,0x2666cc00,0x66cc00,Shader.TileMode.CLAMP));
  if (mDays == 0) {
    mDays=sizeX / mTextPaint.getTextSize() / 21 < 2 ? 14 : 21;
  }
}
 

Example 44

From project onebusaway-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 45

From project open311-android, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 46

From project platform_packages_apps_browser, under directory /src/com/android/browser/.

Source file: TabBar.java

  19 
vote

@Override protected void dispatchDraw(Canvas canvas){
  if (mCurrentTextureWidth != mUi.getContentWidth() || mCurrentTextureHeight != getHeight()) {
    mCurrentTextureWidth=mUi.getContentWidth();
    mCurrentTextureHeight=getHeight();
    if (mCurrentTextureWidth > 0 && mCurrentTextureHeight > 0) {
      Bitmap activeTexture=getDrawableAsBitmap(mActiveDrawable,mCurrentTextureWidth,mCurrentTextureHeight);
      Bitmap inactiveTexture=getDrawableAsBitmap(mInactiveDrawable,mCurrentTextureWidth,mCurrentTextureHeight);
      mActiveShader=new BitmapShader(activeTexture,Shader.TileMode.CLAMP,Shader.TileMode.CLAMP);
      mActiveShaderPaint.setShader(mActiveShader);
      mInactiveShader=new BitmapShader(inactiveTexture,Shader.TileMode.CLAMP,Shader.TileMode.CLAMP);
      mInactiveShaderPaint.setShader(mInactiveShader);
    }
  }
  if ((mActiveShader != null) && (mInactiveShader != null)) {
    int state=canvas.save();
    getLocationInWindow(mWindowPos);
    Paint paint=mSelected ? mActiveShaderPaint : mInactiveShaderPaint;
    drawClipped(canvas,paint,mPath,mWindowPos[0]);
    canvas.restoreToCount(state);
  }
  super.dispatchDraw(canvas);
}
 

Example 47

From project platform_packages_apps_settings, under directory /src/com/android/settings/applications/.

Source file: LinearColorBar.java

  19 
vote

private void updateIndicator(){
  int off=getPaddingTop() - getPaddingBottom();
  if (off < 0)   off=0;
  mRect.top=off;
  mRect.bottom=getHeight();
  if (mShowingGreen) {
    mColorGradientPaint.setShader(new LinearGradient(0,0,0,off - 2,RIGHT_COLOR & 0xffffff,RIGHT_COLOR,Shader.TileMode.CLAMP));
  }
 else {
    mColorGradientPaint.setShader(new LinearGradient(0,0,0,off - 2,MIDDLE_COLOR & 0xffffff,MIDDLE_COLOR,Shader.TileMode.CLAMP));
  }
  mEdgeGradientPaint.setShader(new LinearGradient(0,0,0,off / 2,0x00a0a0a0,0xffa0a0a0,Shader.TileMode.CLAMP));
}
 

Example 48

From project Schedule, under directory /libs/android/sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 49

From project SeriesGuide, under directory /ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 50

From project SMSSync, under directory /abslib/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 51

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 52

From project subsonic, under directory /subsonic-android/src/github/daneren2005/dsub/util/.

Source file: ImageLoader.java

  19 
vote

private Bitmap createReflection(Bitmap originalImage){
  int width=originalImage.getWidth();
  int height=originalImage.getHeight();
  final int reflectionGap=4;
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap reflectionImage=Bitmap.createBitmap(originalImage,0,height / 2,width,height / 2,matrix,false);
  Bitmap bitmapWithReflection=Bitmap.createBitmap(width,(height + height / 2),Bitmap.Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage,0,0,null);
  Paint defaultPaint=new Paint();
  canvas.drawRect(0,height,width,height + reflectionGap,defaultPaint);
  canvas.drawBitmap(reflectionImage,0,height + reflectionGap,null);
  Paint paint=new Paint();
  LinearGradient shader=new LinearGradient(0,originalImage.getHeight(),0,bitmapWithReflection.getHeight() + reflectionGap,0x70000000,0xff000000,Shader.TileMode.CLAMP);
  paint.setShader(shader);
  canvas.drawRect(0,height,width,bitmapWithReflection.getHeight() + reflectionGap,paint);
  return bitmapWithReflection;
}
 

Example 53

From project Subsonic-Android, under directory /src/net/sourceforge/subsonic/androidapp/util/.

Source file: ImageLoader.java

  19 
vote

private Bitmap createReflection(Bitmap originalImage){
  int width=originalImage.getWidth();
  int height=originalImage.getHeight();
  final int reflectionGap=4;
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap reflectionImage=Bitmap.createBitmap(originalImage,0,height / 2,width,height / 2,matrix,false);
  Bitmap bitmapWithReflection=Bitmap.createBitmap(width,(height + height / 2),Bitmap.Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage,0,0,null);
  Paint defaultPaint=new Paint();
  canvas.drawRect(0,height,width,height + reflectionGap,defaultPaint);
  canvas.drawBitmap(reflectionImage,0,height + reflectionGap,null);
  Paint paint=new Paint();
  LinearGradient shader=new LinearGradient(0,originalImage.getHeight(),0,bitmapWithReflection.getHeight() + reflectionGap,0x70000000,0xff000000,Shader.TileMode.CLAMP);
  paint.setShader(shader);
  canvas.drawRect(0,height,width,bitmapWithReflection.getHeight() + reflectionGap,paint);
  return bitmapWithReflection;
}
 

Example 54

From project subsonic_1, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/util/.

Source file: ImageLoader.java

  19 
vote

private Bitmap createReflection(Bitmap originalImage){
  int width=originalImage.getWidth();
  int height=originalImage.getHeight();
  final int reflectionGap=4;
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap reflectionImage=Bitmap.createBitmap(originalImage,0,height / 2,width,height / 2,matrix,false);
  Bitmap bitmapWithReflection=Bitmap.createBitmap(width,(height + height / 2),Bitmap.Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage,0,0,null);
  Paint defaultPaint=new Paint();
  canvas.drawRect(0,height,width,height + reflectionGap,defaultPaint);
  canvas.drawBitmap(reflectionImage,0,height + reflectionGap,null);
  Paint paint=new Paint();
  LinearGradient shader=new LinearGradient(0,originalImage.getHeight(),0,bitmapWithReflection.getHeight() + reflectionGap,0x70000000,0xff000000,Shader.TileMode.CLAMP);
  paint.setShader(shader);
  canvas.drawRect(0,height,width,bitmapWithReflection.getHeight() + reflectionGap,paint);
  return bitmapWithReflection;
}
 

Example 55

From project subsonic_2, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/util/.

Source file: ImageLoader.java

  19 
vote

private Bitmap createReflection(Bitmap originalImage){
  int width=originalImage.getWidth();
  int height=originalImage.getHeight();
  final int reflectionGap=4;
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap reflectionImage=Bitmap.createBitmap(originalImage,0,height / 2,width,height / 2,matrix,false);
  Bitmap bitmapWithReflection=Bitmap.createBitmap(width,(height + height / 2),Bitmap.Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage,0,0,null);
  Paint defaultPaint=new Paint();
  canvas.drawRect(0,height,width,height + reflectionGap,defaultPaint);
  canvas.drawBitmap(reflectionImage,0,height + reflectionGap,null);
  Paint paint=new Paint();
  LinearGradient shader=new LinearGradient(0,originalImage.getHeight(),0,bitmapWithReflection.getHeight() + reflectionGap,0x70ffffff,0x00ffffff,Shader.TileMode.CLAMP);
  paint.setShader(shader);
  paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
  canvas.drawRect(0,height,width,bitmapWithReflection.getHeight() + reflectionGap,paint);
  return bitmapWithReflection;
}
 

Example 56

From project Supersonic, under directory /subsonic-android/src/net/sourceforge/subsonic/androidapp/util/.

Source file: ImageLoader.java

  19 
vote

private Bitmap createReflection(Bitmap originalImage){
  int width=originalImage.getWidth();
  int height=originalImage.getHeight();
  final int reflectionGap=4;
  Matrix matrix=new Matrix();
  matrix.preScale(1,-1);
  Bitmap reflectionImage=Bitmap.createBitmap(originalImage,0,height / 2,width,height / 2,matrix,false);
  Bitmap bitmapWithReflection=Bitmap.createBitmap(width,(height + height / 2),Bitmap.Config.ARGB_8888);
  Canvas canvas=new Canvas(bitmapWithReflection);
  canvas.drawBitmap(originalImage,0,0,null);
  Paint defaultPaint=new Paint();
  canvas.drawRect(0,height,width,height + reflectionGap,defaultPaint);
  canvas.drawBitmap(reflectionImage,0,height + reflectionGap,null);
  Paint paint=new Paint();
  LinearGradient shader=new LinearGradient(0,originalImage.getHeight(),0,bitmapWithReflection.getHeight() + reflectionGap,0x70000000,0xff000000,Shader.TileMode.CLAMP);
  paint.setShader(shader);
  canvas.drawRect(0,height,width,bitmapWithReflection.getHeight() + reflectionGap,paint);
  return bitmapWithReflection;
}
 

Example 57

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

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 58

From project ThreadPaint, under directory /src/at/droidcode/threadpaint/dialog/.

Source file: ShapeView.java

  19 
vote

protected ShapeView(Context c,AttributeSet attrs){
  super(c,attrs);
  shape=Shape.CIRCLE;
  shapeDiameter=Utils.dp2px(c,100);
  shapeRadius=shapeDiameter / 2f;
  centerX=Utils.sreenWidthPx(c,0.75f) / 2;
  indicatorFrameWidth=Utils.dp2px(c,5);
  shapePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  framePaint=new Paint(Paint.ANTI_ALIAS_FLAG);
  framePaint.setStrokeWidth(indicatorFrameWidth);
  framePaint.setStyle(Style.STROKE);
  float r=Math.round(shapeRadius * 0.8f);
  rectFull=new RectF(-r,-r,r,r);
  rectFullInset=new RectF(rectFull);
  rectFullInset.inset(1f,1f);
  r+=indicatorFrameWidth;
  rectFrame=new RectF(-r,-r,r,r);
  Bitmap checkerboard=BitmapFactory.decodeResource(c.getResources(),R.drawable.transparent);
  BitmapShader shader=new BitmapShader(checkerboard,Shader.TileMode.REPEAT,Shader.TileMode.REPEAT);
  checkeredPattern=new Paint();
  checkeredPattern.setShader(shader);
}
 

Example 59

From project titanium_modules, under directory /beintoosdk/mobile/android/src/com/beintoo/beintoosdkutility/.

Source file: BDrawableGradient.java

  19 
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 60

From project twidere, under directory /src/org/mariotaku/twidere/fragment/.

Source file: UserProfileFragment.java

  19 
vote

public static Bitmap createAlphaGradientBanner(final Bitmap orig){
  final int width=orig.getWidth(), height=orig.getHeight();
  final Bitmap bitmap=Bitmap.createBitmap(width,height,Bitmap.Config.ARGB_8888);
  final Canvas canvas=new Canvas(bitmap);
  final Paint paint=new Paint();
  final LinearGradient shader=new LinearGradient(width / 2,0,width / 2,height,0xffffffff,0x00ffffff,Shader.TileMode.CLAMP);
  paint.setShader(shader);
  paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN));
  canvas.drawBitmap(orig,0,0,null);
  canvas.drawRect(0,0,width,height,paint);
  return bitmap;
}
 

Example 61

From project Unibeer, under directory /libs/sherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 62

From project vanilla, under directory /src/org/kreed/vanilla/.

Source file: CoverBitmap.java

  19 
vote

/** 
 * Generate the default cover (a rendition of a CD). Returns a square iamge. Both dimensions are the lesser of width and height.
 * @param width The max width
 * @param height The max height
 * @return The default cover.
 */
public static Bitmap generateDefaultCover(int width,int height){
  int size=Math.min(width,height);
  int halfSize=size / 2;
  int eightSize=size / 8;
  Bitmap bitmap=Bitmap.createBitmap(size,size,Bitmap.Config.RGB_565);
  LinearGradient gradient=new LinearGradient(size,0,0,size,0xff646464,0xff464646,Shader.TileMode.CLAMP);
  RectF oval=new RectF(eightSize,0,size - eightSize,size);
  Paint paint=new Paint();
  paint.setAntiAlias(true);
  Canvas canvas=new Canvas(bitmap);
  canvas.rotate(-45,halfSize,halfSize);
  paint.setShader(gradient);
  canvas.translate(size / 20,size / 20);
  canvas.scale(0.9f,0.9f);
  canvas.drawOval(oval,paint);
  paint.setShader(null);
  paint.setColor(0xff000000);
  canvas.translate(size / 3,size / 3);
  canvas.scale(0.333f,0.333f);
  canvas.drawOval(oval,paint);
  paint.setShader(gradient);
  canvas.translate(size / 3,size / 3);
  canvas.scale(0.333f,0.333f);
  canvas.drawOval(oval,paint);
  return bitmap;
}
 

Example 63

From project Wifileaks, under directory /WifiLeaks/ABS/library/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 64

From project XTrade, under directory /sherlock-bar/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 65

From project Yaaic, under directory /libs/ActionBarSherlock/src/com/actionbarsherlock/internal/widget/.

Source file: IcsProgressBar.java

  19 
vote

/** 
 * Converts a drawable to a tiled version of itself. It will recursively traverse layer and state list drawables.
 */
private Drawable tileify(Drawable drawable,boolean clip){
  if (drawable instanceof LayerDrawable) {
    LayerDrawable background=(LayerDrawable)drawable;
    final int N=background.getNumberOfLayers();
    Drawable[] outDrawables=new Drawable[N];
    for (int i=0; i < N; i++) {
      int id=background.getId(i);
      outDrawables[i]=tileify(background.getDrawable(i),(id == android.R.id.progress || id == android.R.id.secondaryProgress));
    }
    LayerDrawable newBg=new LayerDrawable(outDrawables);
    for (int i=0; i < N; i++) {
      newBg.setId(i,background.getId(i));
    }
    return newBg;
  }
 else   if (drawable instanceof BitmapDrawable) {
    final Bitmap tileBitmap=((BitmapDrawable)drawable).getBitmap();
    if (mSampleTile == null) {
      mSampleTile=tileBitmap;
    }
    final ShapeDrawable shapeDrawable=new ShapeDrawable(getDrawableShape());
    final BitmapShader bitmapShader=new BitmapShader(tileBitmap,Shader.TileMode.REPEAT,Shader.TileMode.CLAMP);
    shapeDrawable.getPaint().setShader(bitmapShader);
    return (clip) ? new ClipDrawable(shapeDrawable,Gravity.LEFT,ClipDrawable.HORIZONTAL) : shapeDrawable;
  }
  return drawable;
}
 

Example 66

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

Source file: EqualizerView.java

  19 
vote

private void drawBars(Canvas canvas,Point[] points){
  if (points == null || points.length < 1)   return;
  Paint paint=new Paint(){
{
      setStyle(Paint.Style.STROKE);
      setAntiAlias(true);
      setColor(Color.GREEN);
      if (mBands == null || mBands.length < 1) {
        setStrokeWidth(12.0f);
      }
 else {
        setStrokeWidth(getWidth() / mBands.length / 8);
      }
      setShader(new LinearGradient(0,0,0,getHeight(),0xffbfff00,0xff003300,Shader.TileMode.CLAMP));
    }
  }
;
  for (  Point point : points) {
    canvas.drawLine(point.x,getHeight() / 2,point.x,point.y,paint);
  }
}