public NormalBatteryMeterDrawable(Resources res, boolean horizontal) {
      super();
      mHorizontal = horizontal;
      mDisposed = false;

      mFramePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mFramePaint.setColor(res.getColor(R.color.batterymeter_frame_color));
      mFramePaint.setDither(true);
      mFramePaint.setStrokeWidth(0);
      mFramePaint.setStyle(Paint.Style.FILL_AND_STROKE);
      mFramePaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));

      mBatteryPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mBatteryPaint.setDither(true);
      mBatteryPaint.setStrokeWidth(0);
      mBatteryPaint.setStyle(Paint.Style.FILL_AND_STROKE);

      mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mTextPaint.setColor(res.getColor(R.color.batterymeter_bolt_color));
      Typeface font = Typeface.create("sans-serif-condensed", Typeface.BOLD);
      mTextPaint.setTypeface(font);
      mTextPaint.setTextAlign(Paint.Align.CENTER);

      mWarningTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mWarningTextPaint.setColor(mColors[1]);
      font = Typeface.create("sans-serif", Typeface.BOLD);
      mWarningTextPaint.setTypeface(font);
      mWarningTextPaint.setTextAlign(Paint.Align.CENTER);

      mBoltPaint = new Paint();
      mBoltPaint.setAntiAlias(true);
      mBoltPaint.setColor(res.getColor(R.color.batterymeter_bolt_color));
      mBoltPoints = loadBoltPoints(res);
    }
Example #2
0
  // called when the alert dialog (mAlertDialog) is displayed
  @Override
  public void onShow(DialogInterface dialog) {

    // link the layout objects to the corresponding dialog-ui elements
    Button negativeButton = ((AlertDialog) dialog).getButton(BUTTON_NEGATIVE);
    Button neutralButton = ((AlertDialog) dialog).getButton(BUTTON_NEUTRAL);
    Button positiveButton = ((AlertDialog) dialog).getButton(BUTTON_POSITIVE);

    TextView dialogText = (TextView) ((AlertDialog) dialog).findViewById(android.R.id.message);

    // set the parameters for the negative button, if exists
    if (negativeButton != null) {
      negativeButton.setTypeface(Typeface.create(mButtonTextFont, mButtonTypefaceStyle));
      negativeButton.setTextColor(mButtonTextColor);
    }

    // set the parameters for the neutral button, if exists
    if (neutralButton != null) {
      neutralButton.setTypeface(Typeface.create(mButtonTextFont, mButtonTypefaceStyle));
      neutralButton.setTextColor(mButtonTextColor);
    }

    // set the parameters for the positive button, if exists
    if (positiveButton != null) {
      positiveButton.setTypeface(Typeface.create(mButtonTextFont, mButtonTypefaceStyle));
      positiveButton.setTextColor(mButtonTextColor);
    }

    // set the arguments for the displayed text message
    if (dialogText != null) {
      dialogText.setTypeface(Typeface.create(mMessageTextFont, mMessageTypefaceStyle));
      dialogText.setTextColor(mMessageTextColor);
    }
  }
  /** Sets up the text and style properties for painting. */
  private void initPaints(Resources res) {
    final String monthTypeface = res.getString(R.string.date_picker_month_typeface);
    final String dayOfWeekTypeface = res.getString(R.string.date_picker_day_of_week_typeface);
    final String dayTypeface = res.getString(R.string.date_picker_day_typeface);

    final int monthTextSize = res.getDimensionPixelSize(R.dimen.date_picker_month_text_size);
    final int dayOfWeekTextSize =
        res.getDimensionPixelSize(R.dimen.date_picker_day_of_week_text_size);
    final int dayTextSize = res.getDimensionPixelSize(R.dimen.date_picker_day_text_size);

    mMonthPaint.setAntiAlias(true);
    mMonthPaint.setTextSize(monthTextSize);
    mMonthPaint.setTypeface(Typeface.create(monthTypeface, 0));
    mMonthPaint.setTextAlign(Align.CENTER);
    mMonthPaint.setStyle(Style.FILL);

    mDayOfWeekPaint.setAntiAlias(true);
    mDayOfWeekPaint.setTextSize(dayOfWeekTextSize);
    mDayOfWeekPaint.setTypeface(Typeface.create(dayOfWeekTypeface, 0));
    mDayOfWeekPaint.setTextAlign(Align.CENTER);
    mDayOfWeekPaint.setStyle(Style.FILL);

    mDaySelectorPaint.setAntiAlias(true);
    mDaySelectorPaint.setStyle(Style.FILL);

    mDayHighlightPaint.setAntiAlias(true);
    mDayHighlightPaint.setStyle(Style.FILL);

    mDayPaint.setAntiAlias(true);
    mDayPaint.setTextSize(dayTextSize);
    mDayPaint.setTypeface(Typeface.create(dayTypeface, 0));
    mDayPaint.setTextAlign(Align.CENTER);
    mDayPaint.setStyle(Style.FILL);
  }
  @Override
  public View getView(int i, View convertView, ViewGroup viewGroup) {
    View rowView = convertView;
    final PasswordItem pass = values.get(i);

    // reuse for performance, holder pattern!
    if (rowView == null) {
      LayoutInflater inflater =
          (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      rowView = inflater.inflate(R.layout.password_row_layout, viewGroup, false);

      ViewHolder viewHolder = new ViewHolder();
      viewHolder.name = (TextView) rowView.findViewById(R.id.label);
      viewHolder.back_name = (TextView) rowView.findViewById(R.id.label_back);
      viewHolder.type = (TextView) rowView.findViewById(R.id.type);
      rowView.setTag(viewHolder);
    }

    ViewHolder holder = (ViewHolder) rowView.getTag();

    holder.name.setText(pass.toString());
    holder.back_name.setText(pass.toString());

    if (pass.getType() == PasswordItem.TYPE_CATEGORY) {
      holder.name.setTextColor(
          this.activity.getResources().getColor(android.R.color.holo_blue_dark));
      holder.name.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
      holder.type.setText("Category: ");
    } else {
      holder.type.setText("Password: ");
      holder.name.setTextColor(
          this.activity.getResources().getColor(android.R.color.holo_orange_dark));
      holder.name.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));

      holder.back_name.setTextColor(this.activity.getResources().getColor(android.R.color.white));
      holder.back_name.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD_ITALIC));

      View.OnClickListener onClickListener =
          new View.OnClickListener() {
            @Override
            public void onClick(View view) {
              switch (view.getId()) {
                case R.id.crypto_show_button:
                  activity.decryptPassword(pass);
                  break;
                case R.id.crypto_delete_button:
                  activity.deletePassword(pass);
                  break;
              }
            }
          };

      ((ImageButton) rowView.findViewById(R.id.crypto_show_button))
          .setOnClickListener(onClickListener);
      ((ImageButton) rowView.findViewById(R.id.crypto_delete_button))
          .setOnClickListener(onClickListener);
    }

    return rowView;
  }
Example #5
0
  @Override
  public void Draw(Canvas canvas, Paint paint) {

    Typeface tf = paint.getTypeface();
    paint.setUnderlineText(underline);
    paint.setTypeface(Typeface.create(tf, style));
    paint.setTextSize(size);
    paint.setStyle(Paint.Style.FILL);

    if (v.currBrushColor != -1) { // draw background rect
      int clr = paint.getColor();
      paint.setColor(v.currBrushColor + v.Opaque);
      canvas.drawRect(
          x - 1,
          y,
          x + paint.measureText(text) + 1,
          y - paint.ascent() + paint.descent() / 2,
          paint);
      paint.setColor(clr);
    }

    canvas.drawText(text, x, y - paint.ascent(), paint);

    paint.setStyle(Paint.Style.STROKE);
    paint.setUnderlineText(false);
    paint.setTypeface(tf);
  }
Example #6
0
  /**
   * Sets up the text and style properties for painting. Override this if you want to use a
   * different paint.
   */
  protected void initView() {
    mMonthTitlePaint = new Paint();
    mMonthTitlePaint.setFakeBoldText(true);
    mMonthTitlePaint.setAntiAlias(true);
    mMonthTitlePaint.setTextSize(MONTH_LABEL_TEXT_SIZE);
    mMonthTitlePaint.setTypeface(Typeface.create(mMonthTitleTypeface, Typeface.BOLD));
    mMonthTitlePaint.setColor(mDayTextColor);
    mMonthTitlePaint.setTextAlign(Align.CENTER);
    mMonthTitlePaint.setStyle(Style.FILL);

    mSelectedCirclePaint = new Paint();
    mSelectedCirclePaint.setFakeBoldText(true);
    mSelectedCirclePaint.setAntiAlias(true);
    mSelectedCirclePaint.setColor(mTodayNumberColor);
    mSelectedCirclePaint.setTextAlign(Align.CENTER);
    mSelectedCirclePaint.setStyle(Style.FILL);
    mSelectedCirclePaint.setAlpha(SELECTED_CIRCLE_ALPHA);

    mMonthDayLabelPaint = new Paint();
    mMonthDayLabelPaint.setAntiAlias(true);
    mMonthDayLabelPaint.setTextSize(MONTH_DAY_LABEL_TEXT_SIZE);
    mMonthDayLabelPaint.setColor(mMonthDayTextColor);
    mMonthDayLabelPaint.setTypeface(TypefaceHelper.get(getContext(), "Roboto-Medium"));
    mMonthDayLabelPaint.setStyle(Style.FILL);
    mMonthDayLabelPaint.setTextAlign(Align.CENTER);
    mMonthDayLabelPaint.setFakeBoldText(true);

    mMonthNumPaint = new Paint();
    mMonthNumPaint.setAntiAlias(true);
    mMonthNumPaint.setTextSize(MINI_DAY_NUMBER_TEXT_SIZE);
    mMonthNumPaint.setStyle(Style.FILL);
    mMonthNumPaint.setTextAlign(Align.CENTER);
    mMonthNumPaint.setFakeBoldText(false);
  }
Example #7
0
 /**
  * 图片加上水印
  *
  * @param src 底图
  * @param waterMak
  * @param title 文字
  * @return
  */
 public static Bitmap createBitmap(Bitmap src, Bitmap waterMak, String title) {
   if (src == null) {
     return src;
   }
   // 获取原始图片与水印图片的宽与高
   int w = src.getWidth();
   int h = src.getHeight();
   Bitmap newBitmap = Bitmap.createBitmap(w, h, Config.RGB_565);
   Canvas mCanvas = new Canvas(newBitmap);
   // 往位图中开始画入src原始图片
   mCanvas.drawBitmap(src, 0, 0, null);
   // 在src的右下角添加水印
   Paint paint = new Paint();
   if (waterMak != null) {
     int ww = waterMak.getWidth();
     int wh = waterMak.getHeight();
     mCanvas.drawBitmap(waterMak, w - ww - 5, h - wh - 5, paint);
   }
   // 开始加入文字
   if (null != title) {
     Paint textPaint = new Paint();
     textPaint.setColor(Color.WHITE);
     textPaint.setTextSize(18);
     String familyName = "宋体";
     Typeface typeface = Typeface.create(familyName, Typeface.BOLD_ITALIC);
     textPaint.setTypeface(typeface);
     textPaint.setTextAlign(Align.CENTER);
     mCanvas.drawText(title, w / 2, h - 30, textPaint);
   }
   mCanvas.save(Canvas.ALL_SAVE_FLAG);
   mCanvas.restore();
   return newBitmap;
 }
Example #8
0
 private void initScoreboard(Context context) {
   scoreB.setTextContext(Typeface.create("Helvetica", Typeface.BOLD), 20, 0xff, 0xff, 0xff, 0xff);
   for (int i = 0; i < scoreHandles.length - 1; i++) {
     scoreHandles[i] = scoreB.setTextTexture(context, i + "");
   }
   scoreHandles[10] = scoreB.setTextTexture(context, "Score: ");
 }
    public CircleBatteryMeterDrawable(Resources res) {
      super();
      mDisposed = false;

      mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mTextPaint.setColor(res.getColor(R.color.status_bar_clock_color));
      Typeface font = Typeface.create("sans-serif-condensed", Typeface.NORMAL);
      mTextPaint.setTypeface(font);
      mTextPaint.setTextAlign(Paint.Align.CENTER);

      mFrontPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mFrontPaint.setStrokeCap(Paint.Cap.BUTT);
      mFrontPaint.setDither(true);
      mFrontPaint.setStrokeWidth(0);
      mFrontPaint.setStyle(Paint.Style.STROKE);
      mFrontPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_ATOP));

      mBackPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
      mBackPaint.setColor(res.getColor(R.color.batterymeter_frame_color));
      mBackPaint.setStrokeCap(Paint.Cap.BUTT);
      mBackPaint.setDither(true);
      mBackPaint.setStrokeWidth(0);
      mBackPaint.setStyle(Paint.Style.STROKE);
      mBackPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.XOR));

      mBoltPaint = new Paint();
      mBoltPaint.setAntiAlias(true);
      mBoltPaint.setColor(getColorForLevel(50));
      mBoltPoints = loadBoltPoints(res);
    }
Example #10
0
  @Override
  public void updateDrawState(TextPaint textPaint) {
    super.updateDrawState(textPaint);

    textPaint.setUnderlineText(false);
    textPaint.setColor(activity.getResources().getColor(R.color.secondary_text));
    textPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.ITALIC));
  }
Example #11
0
 public void onDraw(Canvas canvas) {
   canvas.drawColor(Color.LTGRAY);
   Paint Pnt = new Paint();
   int y = 1;
   Pnt.setAntiAlias(true);
   Pnt.setTextSize(30);
   Pnt.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
   canvas.drawText("Font:Default", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.DEFAULT_BOLD, Typeface.NORMAL));
   canvas.drawText("Font:Default Bold", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.MONOSPACE, Typeface.NORMAL));
   canvas.drawText("Font:Monospace", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL));
   canvas.drawText("Font:Sans Serif", 10, y++ * 40, Pnt);
   Pnt.setTypeface(Typeface.create(Typeface.SERIF, Typeface.NORMAL));
   canvas.drawText("Font:Serif", 10, y++ * 40, Pnt);
 }
Example #12
0
  public void drawText(Canvas canvas) {
    Paint paint = new Paint();
    paint.setColor(Color.BLACK);
    paint.setTextSize(30);
    paint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    canvas.drawText("DISTANCE: " + (player.getScore() * 3), 10, HEIGHT - 10, paint);
    canvas.drawText("BEST: " + best, WIDTH - 215, HEIGHT - 10, paint);

    if (!player.getPlaying() && newGameCreated && reset) {
      Paint paint1 = new Paint();
      paint1.setTextSize(40);
      paint1.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
      canvas.drawText("PRESS TO START", WIDTH / 2 - 50, HEIGHT / 2, paint1);

      paint1.setTextSize(20);
      canvas.drawText("PRESS AND HOLD TO GO UP", WIDTH / 2 - 50, HEIGHT / 2 + 20, paint1);
      canvas.drawText("RELEASE TO GO DOWN", WIDTH / 2 - 50, HEIGHT / 2 + 40, paint1);
    }
  }
  private View makeView() {
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    LinearLayout view = new LinearLayout(this);
    view.setOrientation(LinearLayout.VERTICAL);
    view.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    final int p = (int) (8 * metrics.density);
    view.setPadding(p, p, p, p);

    Typeface light = Typeface.create("sans-serif-light", Typeface.NORMAL);
    Typeface normal = Typeface.create("sans-serif", Typeface.BOLD);

    String paVersion = SystemProperties.get("ro.pa.version");

    final float size = 14 * metrics.density;
    final LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.CENTER_HORIZONTAL;
    lp.bottomMargin = (int) (-4 * metrics.density);

    TextView tv = new TextView(this);
    if (normal != null) tv.setTypeface(normal);
    tv.setTextSize(1.25f * size);
    tv.setTextColor(0xFFFFFFFF);
    tv.setShadowLayer(4 * metrics.density, 0, 2 * metrics.density, 0x66000000);
    tv.setText("ParanoidAndroid");
    view.addView(tv, lp);

    tv = new TextView(this);
    if (light != null) tv.setTypeface(light);
    tv.setTextSize(size);
    tv.setTextColor(0xFFFFFFFF);
    tv.setShadowLayer(4 * metrics.density, 0, 2 * metrics.density, 0x66000000);
    tv.setText(paVersion);
    view.addView(tv, lp);

    return view;
  }
    @Override
    public void onCreate(SurfaceHolder holder) {
      super.onCreate(holder);

      mBackgroundBitmap = Bitmap.createBitmap(320, 320, Bitmap.Config.RGB_565);
      mBackgroundBitmap.eraseColor(Color.BLACK);

      mPaint.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
      mPaint.setTextSize(20f);
      mPaint.setColor(Color.BLUE);
    }
Example #15
0
  public void setMediumTypeface(TextView textView) {
    if (hasL()) {
      if (sMediumTypeface == null) {
        sMediumTypeface = Typeface.create("sans-serif-medium", Typeface.NORMAL);
      }

      textView.setTypeface(sMediumTypeface);
    } else {
      textView.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    }
  }
 // 画扫描框下面的字
 private void drawText(Canvas canvas) {
   paint.setColor(Color.WHITE);
   paint.setTextSize(TEXT_SIZE * density);
   paint.setAlpha(0xee);
   paint.setTypeface(Typeface.create("System", Typeface.BOLD));
   paint.getTextBounds(Contants.TEXT_SCAN_TIP, 0, Contants.TEXT_SCAN_TIP.length(), textBound);
   canvas.drawText(
       Contants.TEXT_SCAN_TIP,
       (width - textBound.width()) / 2,
       (float) (slideBottom + (float) TEXT_PADDING_TOP * density),
       paint);
 }
Example #17
0
    public AlarmItemAdapter(
        Context context,
        int[] expandedIds,
        int[] repeatCheckedIds,
        int[] selectedAlarms,
        Bundle previousDaysOfWeekMap,
        ListView list) {
      super(context, null, 0);
      mContext = context;
      mFactory = LayoutInflater.from(context);
      mList = list;

      DateFormatSymbols dfs = new DateFormatSymbols();
      mShortWeekDayStrings = dfs.getShortWeekdays();
      mLongWeekDayStrings = dfs.getWeekdays();

      Resources res = mContext.getResources();
      mColorLit = res.getColor(R.color.clock_white);
      mColorDim = res.getColor(R.color.clock_gray);
      mBackgroundColorSelected = res.getColor(R.color.alarm_selected_color);
      mBackgroundColor = res.getColor(R.color.alarm_whiteish);

      mRobotoBold = Typeface.create("sans-serif-condensed", Typeface.BOLD);
      mRobotoNormal = Typeface.create("sans-serif-condensed", Typeface.NORMAL);

      if (expandedIds != null) {
        buildHashSetFromArray(expandedIds, mExpanded);
      }
      if (repeatCheckedIds != null) {
        buildHashSetFromArray(repeatCheckedIds, mRepeatChecked);
      }
      if (previousDaysOfWeekMap != null) {
        mPreviousDaysOfWeekMap = previousDaysOfWeekMap;
      }
      if (selectedAlarms != null) {
        buildHashSetFromArray(selectedAlarms, mSelectedAlarms);
      }

      mHasVibrator = ((Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE)).hasVibrator();
    }
Example #18
0
  public TextRenderer(Context context) {
    this.context = context;
    paintText = new Paint();
    paintText.setStyle(Style.FILL);
    paintText.setStrokeWidth(1);
    paintText.setColor(Color.BLACK);
    paintText.setTextAlign(Align.CENTER);
    paintText.setTypeface(Typeface.create("Droid Serif", Typeface.NORMAL)); // $NON-NLS-1$
    paintText.setAntiAlias(true);

    paintIcon = new Paint();
    paintIcon.setStyle(Style.STROKE);
  }
 private Builder() {
   text = "";
   color = Color.GRAY;
   textColor = Color.WHITE;
   borderThickness = 0;
   width = -1;
   height = -1;
   shape = new RectShape();
   font = Typeface.create("sans-serif-light", Typeface.NORMAL);
   fontSize = -1;
   isBold = false;
   toUpperCase = false;
 }
 @Override
 public void onCreateResources() {
   this.mFont =
       FontFactory.create(
           this.getFontManager(),
           this.getTextureManager(),
           256,
           256,
           TextureOptions.BILINEAR,
           Typeface.create(Typeface.DEFAULT, Typeface.BOLD),
           24);
   this.mFont.load();
 }
  @Override
  public void drawMonthDay(
      Canvas canvas,
      int year,
      int month,
      int day,
      int x,
      int y,
      int startX,
      int stopX,
      int startY,
      int stopY) {
    if (mSelectedDay == day) {
      canvas.drawCircle(
          x, y - (MINI_DAY_NUMBER_TEXT_SIZE / 3), DAY_SELECTED_CIRCLE_SIZE, mSelectedCirclePaint);
    }

    if (isHighlighted(year, month, day)) {
      mMonthNumPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
    } else {
      mMonthNumPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
    }

    // If we have a mindate or maxdate, gray out the day number if it's outside the range.
    if (isOutOfRange(year, month, day)) {
      mMonthNumPaint.setColor(mDisabledDayTextColor);
    } else if (mSelectedDay == day) {
      mMonthNumPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
      mMonthNumPaint.setColor(mSelectedDayTextColor);
    } else if (mHasToday && mToday == day) {
      mMonthNumPaint.setColor(mTodayNumberColor);
    } else {
      mMonthNumPaint.setColor(
          isHighlighted(year, month, day) ? mHighlightedDayTextColor : mDayTextColor);
    }

    canvas.drawText(String.format("%d", day), x, y, mMonthNumPaint);
  }
Example #22
0
 public static Font create(
     final FontManager pFontManager,
     final ITexture pTexture,
     final float pSize,
     final boolean pAntiAlias,
     final int pColor) {
   return FontFactory.create(
       pFontManager,
       pTexture,
       Typeface.create(Typeface.DEFAULT, Typeface.NORMAL),
       pSize,
       pAntiAlias,
       pColor);
 }
Example #23
0
 public void Text() {
   brush.setTypeface(Typeface.create("Roboto", Typeface.BOLD));
   brush.setColor(Color.RED);
   brush.setTextSize(width / 5);
   refCanvas.drawText("WHOOPS!!", 0, height * 3 / 4, brush);
   time++;
   if (time == 150) {
     state = 3;
     wind.stop();
     wind = new MediaPlayer();
     wind = MediaPlayer.create(cont, R.raw.fall);
     wind.start();
   }
 }
  private static Paint newPaint(
      final String fontName, final int fontSize, final int horizontalAlignment) {
    final Paint paint = new Paint();
    paint.setColor(Color.WHITE);
    paint.setTextSize(fontSize);
    paint.setAntiAlias(true);

    // Set type face for paint, now it support .ttf file.
    if (fontName.endsWith(".ttf")) {
      try {
        final Typeface typeFace = Cocos2dxTypefaces.get(Cocos2dxBitmap.sContext, fontName);
        paint.setTypeface(typeFace);
      } catch (final Exception e) {
        Log.e("Cocos2dxBitmap", "error to create ttf type face: " + fontName);

        // The file may not find, use system font.
        paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL));
      }
    } else {
      paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL));
    }

    switch (horizontalAlignment) {
      case HORIZONTALALIGN_CENTER:
        paint.setTextAlign(Align.CENTER);
        break;
      case HORIZONTALALIGN_RIGHT:
        paint.setTextAlign(Align.RIGHT);
        break;
      case HORIZONTALALIGN_LEFT:
      default:
        paint.setTextAlign(Align.LEFT);
        break;
    }

    return paint;
  }
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);

    paint.setTypeface(Typeface.create("", Typeface.BOLD));

    paint.setTextSize((int) (textSize * BaseActivity.screen_width));
    paint.setAntiAlias(true);
    paint.setColor(Color.rgb(100, 100, 100));

    float x = Utils.measureX(paint, AVAILABLE_BALANCE_TITLE, maxwidth);
    canvas.drawText(AVAILABLE_BALANCE_TITLE, x, (float) (availableY * maxHeight), paint);

    x = Utils.measureX(paint, ACCOUNT_BALANCE_TITLE, maxwidth);
    canvas.drawText(ACCOUNT_BALANCE_TITLE, x, (float) ((accountY) * maxHeight), paint);
    x = Utils.measureX(paint, ACCOUNT_BALANCE_TITLE, maxwidth);
    canvas.drawText(ACCOUNT_BALANCE_TITLE, x, (float) ((accountY) * maxHeight), paint);

    paint.setColor(Color.BLACK);
    x = Utils.measureX(paint, getAvailableBalanceValue(), maxwidth);
    canvas.drawText(
        getAvailableBalanceValue(), x, (float) ((availableY + line) * maxHeight), paint);

    x = Utils.measureX(paint, getAccountBalanceValue(), maxwidth);
    canvas.drawText(getAccountBalanceValue(), x, (float) ((accountY + line) * maxHeight), paint);

    x = (float) (maxwidth / 2 - paint.measureText(DEPOSIT_TITLE) - placeholderLineDrawableWidth);
    canvas.drawText(DEPOSIT_TITLE, x, (float) ((depositY) * maxHeight), paint);

    x = (float) (maxwidth / 2 + placeholderLineDrawableWidth);
    canvas.drawText(WITHDRAWALS_TITLE, x, (float) ((depositY) * maxHeight), paint);

    x =
        (float)
            (maxwidth / 2 - paint.measureText(getDepositValue()) - placeholderLineDrawableWidth);
    canvas.drawText(getDepositValue(), x, (float) ((depositY + line) * maxHeight), paint);

    x = (float) (maxwidth / 2 + placeholderLineDrawableWidth);

    canvas.drawText(getWidthdrawalsValue(), x, (float) ((depositY + line) * maxHeight), paint);

    if (placeholderLineDrawable != null) {
      canvas.save();
      // canvas.scale((float)xx, (float)xx);
      canvas.translate((float) (o_x), (float) ((depositY) * maxHeight) - paint.getTextSize());
      placeholderLineDrawable.draw(canvas);
      canvas.restore();
    }
  }
/** Displays text with no padding at the top. */
public class ZeroTopPaddingTextView extends TextView {
  private static final float NORMAL_FONT_PADDING_RATIO = 0.328f;
  // the bold fontface has less empty space on the top
  private static final float BOLD_FONT_PADDING_RATIO = 0.208f;

  private static final float NORMAL_FONT_BOTTOM_PADDING_RATIO = 0.25f;
  // the bold fontface has less empty space on the top
  private static final float BOLD_FONT_BOTTOM_PADDING_RATIO = 0.208f;

  private static final Typeface SAN_SERIF_BOLD = Typeface.create("san-serif", Typeface.BOLD);

  private int mPaddingRight = 0;

  public ZeroTopPaddingTextView(Context context) {
    this(context, null);
  }

  public ZeroTopPaddingTextView(Context context, AttributeSet attrs) {
    this(context, attrs, 0);
  }

  public ZeroTopPaddingTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    setIncludeFontPadding(false);
    updatePadding();
  }

  public void updatePadding() {
    float paddingRatio = NORMAL_FONT_PADDING_RATIO;
    float bottomPaddingRatio = NORMAL_FONT_BOTTOM_PADDING_RATIO;
    if (getTypeface().equals(SAN_SERIF_BOLD)) {
      paddingRatio = BOLD_FONT_PADDING_RATIO;
      bottomPaddingRatio = BOLD_FONT_BOTTOM_PADDING_RATIO;
    }
    // no need to scale by display density because getTextSize() already returns the font
    // height in px
    setPadding(
        0,
        (int) (-paddingRatio * getTextSize()) + 5,
        mPaddingRight,
        // (int) (-bottomPaddingRatio * getTextSize())+5);
        0);
  }

  public void setPaddingRight(int padding) {
    mPaddingRight = padding;
    updatePadding();
  }
}
Example #27
0
  public void loadResources() {
    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");
    TA =
        new BuildableBitmapTextureAtlas(
            this.activity.getTextureManager(),
            1024,
            1024,
            BitmapTextureFormat.RGBA_4444,
            TextureOptions.BILINEAR_PREMULTIPLYALPHA);
    map.loadResources(TA);

    creditsTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(TA, activity, "menu/credits.png");
    homeTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(TA, activity, "home.png");
    gamebyTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            TA, this.activity, "credits/game by.png");
    zarokhanTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            TA, this.activity, "credits/zarokhan.png");
    robinTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            TA, this.activity, "credits/robin.png");
    musicbyTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            TA, this.activity, "credits/music by.png");
    alexTR =
        BitmapTextureAtlasTextureRegionFactory.createFromAsset(
            TA, this.activity, "credits/alexander.png");

    font =
        FontFactory.create(
            this.activity.getFontManager(),
            this.activity.getTextureManager(),
            256,
            256,
            Typeface.create(Typeface.DEFAULT, Typeface.NORMAL),
            GameManager.lengthOfTile);
    font.load();

    try {
      TA.build(
          new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(1, 1, 0));
      TA.load();
    } catch (TextureAtlasBuilderException e) {
      e.printStackTrace();
    }
  }
Example #28
0
 /** 画布 */
 @Override
 protected void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   /*
    * Resources r = this.getContext().getResources(); InputStream is =
    * r.openRawResource(iResId[iShowId]); BitmapDrawable bmpDraw = new
    * BitmapDrawable(is); Bitmap bmp = bmpDraw.getBitmap();
    * canvas.drawBitmap(bmp, 0, 0, p);
    */
   canvas.drawColor(Color.TRANSPARENT);
   p.setColor(Color.parseColor("#444444"));
   p.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.BOLD));
   p.setAntiAlias(true);
   onDrawTop(canvas);
   if (list != null && list.get(0).getBallNum() != null) {
     if (iGameType.equals("gd-10")) {
       if (isRed) {
         p.setColor(Color.GRAY);
         canvas.drawLine(FIRST_WITH, 0, FIRST_WITH, getHeight(), p);
       } else {
         onDrawLeft(canvas);
       }
     } else {
       if (isRed) {
         onDrawLeft(canvas);
       } else {
         p.setColor(Color.GRAY);
         canvas.drawLine(FIRST_WITH, 0, FIRST_WITH, getHeight(), p);
       }
     }
     if (iGameType.equals("fc3d")
         || iGameType.equals("pl3")
         || iGameType.equals("pl5")
         || iGameType.equals("qxc")
         || iGameType.equals("ssc")) {
       int ballNum = 3;
       if (iGameType.equals("pl5") || iGameType.equals("ssc")) {
         ballNum = 5;
       } else if (iGameType.equals("qxc")) {
         ballNum = 7;
       }
       onDrawCenterPL3(canvas, ballNum);
     } else {
       onDrawCenter(canvas);
     }
   }
 }
Example #29
0
  private void drawTile(
      Canvas canvas, String letter, int tileColor, int left, int top, int right, int bottom) {
    letter = letter.toUpperCase(Locale.getDefault());
    Paint tilePaint = new Paint(), textPaint = new Paint();
    tilePaint.setColor(tileColor);
    textPaint.setFlags(Paint.ANTI_ALIAS_FLAG);
    textPaint.setColor(FG_COLOR);
    textPaint.setTypeface(Typeface.create("sans-serif-light", Typeface.NORMAL));
    textPaint.setTextSize((float) ((right - left) * 0.8));
    Rect rect = new Rect();

    canvas.drawRect(new Rect(left, top, right, bottom), tilePaint);
    textPaint.getTextBounds(letter, 0, 1, rect);
    float width = textPaint.measureText(letter);
    canvas.drawText(
        letter, (right + left) / 2 - width / 2, (top + bottom) / 2 + rect.height() / 2, textPaint);
  }
Example #30
0
 public int FromByteArray(byte[] BA, int Idx) throws IOException {
   Level = TDataConverter.ConvertLEByteArrayToInt16(BA, Idx);
   Idx += 2;
   // .
   InfoComponent_Type = TDataConverter.ConvertLEByteArrayToInt16(BA, Idx);
   Idx += 2;
   InfoComponent_ID = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
   Idx += 8; // . Int64
   // .
   BindingPointX = TDataConverter.ConvertLEByteArrayToDouble(BA, Idx);
   Idx += 8;
   BindingPointY = TDataConverter.ConvertLEByteArrayToDouble(BA, Idx);
   Idx += 8;
   BaseSquare = TDataConverter.ConvertLEByteArrayToDouble(BA, Idx);
   Idx += 8;
   // .
   InfoImageDATAFileID = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
   Idx += 8; // . Int64
   byte SS = BA[Idx];
   Idx++;
   if (SS > 0) {
     InfoString = new String(BA, Idx, SS, "windows-1251");
     Idx += SS;
   } else InfoString = "";
   InfoStringFontColor = TDataConverter.ConvertLEByteArrayToInt32(BA, Idx);
   Idx += 4;
   InfoStringFontSize = BA[Idx];
   Idx++;
   SS = BA[Idx];
   Idx++;
   if (SS > 0) {
     InfoStringFontName = new String(BA, Idx, SS, "windows-1251");
     Idx += SS;
   } else InfoStringFontName = "";
   // .
   Typeface tf = Typeface.create(InfoStringFontName, Typeface.NORMAL);
   paint.setTypeface(tf);
   paint.setAntiAlias(true);
   paint.setTextSize(InfoStringFontSize * metrics.density * 2.0F);
   byte R = (byte) (InfoStringFontColor & 255);
   byte G = (byte) ((InfoStringFontColor >> 8) & 255);
   byte B = (byte) ((InfoStringFontColor >> 16) & 255);
   paint.setColor(Color.argb(255, R, G, B));
   // .
   return Idx;
 }