List of usage examples for android.graphics Paint setColor
public void setColor(@ColorInt int color)
From source file:org.navitproject.navit.NavitGraphics.java
protected void draw_text(Paint paint, int x, int y, String text, int size, int dx, int dy, int bgcolor) { int oldcolor = paint.getColor(); Path path = null;//from www. j ava2 s .c o m paint.setTextSize(size / 15); paint.setStyle(Paint.Style.FILL); if (dx != 0x10000 || dy != 0) { path = new Path(); path.moveTo(x, y); path.rLineTo(dx, dy); paint.setTextAlign(android.graphics.Paint.Align.LEFT); } if (bgcolor != 0) { paint.setStrokeWidth(3); paint.setColor(bgcolor); paint.setStyle(Paint.Style.STROKE); if (path == null) { draw_canvas.drawText(text, x, y, paint); } else { draw_canvas.drawTextOnPath(text, path, 0, 0, paint); } paint.setStyle(Paint.Style.FILL); paint.setColor(oldcolor); } if (path == null) { draw_canvas.drawText(text, x, y, paint); } else { draw_canvas.drawTextOnPath(text, path, 0, 0, paint); } paint.clearShadowLayer(); }
From source file:com.tr4android.support.extension.picker.date.SimpleMonthView.java
/** * Applies the specified text appearance resource to a paint, returning the * text color if one is set in the text appearance. * * @param p the paint to modify// www. j ava 2 s .c o m * @param resId the resource ID of the text appearance * @return the text color, if available */ private ColorStateList applyTextAppearance(Paint p, int resId) { final TypedArray ta = getContext().obtainStyledAttributes(null, R.styleable.TextAppearance, 0, resId); final String fontFamily = ta.getString(R.styleable.TextAppearance_android_fontFamily); if (fontFamily != null) { p.setTypeface(Typeface.create(fontFamily, 0)); } p.setTextSize(ta.getDimensionPixelSize(R.styleable.TextAppearance_android_textSize, (int) p.getTextSize())); final ColorStateList textColor = ta.getColorStateList(R.styleable.TextAppearance_android_textColor); if (textColor != null) { final int enabledColor = textColor.getColorForState(ENABLED_STATE_SET, 0); p.setColor(enabledColor); } ta.recycle(); return textColor; }
From source file:org.de.jmg.learn.SettingsActivity.java
public void init(boolean blnRestart) throws Exception { if (_Intent == null || _main == null || SettingsView == null || _blnInitialized) { return;// w w w . j a va2 s . co m } try { //lib.ShowToast(_main, "Settings Start"); RelativeLayout layout = (RelativeLayout) findViewById(R.id.layoutSettings); // id fetch from xml ShapeDrawable rectShapeDrawable = new ShapeDrawable(); // pre defined class int pxPadding = lib.dpToPx(10); rectShapeDrawable.setPadding(pxPadding, pxPadding, pxPadding, pxPadding * ((lib.NookSimpleTouch()) ? 2 : 1)); Paint paint = rectShapeDrawable.getPaint(); paint.setColor(Color.BLACK); paint.setStyle(Style.STROKE); paint.setStrokeWidth(5); // you can change the value of 5 lib.setBg(layout, rectShapeDrawable); mainView = _main.findViewById(Window.ID_ANDROID_CONTENT); //Thread.setDefaultUncaughtExceptionHandler(ErrorHandler); prefs = _main.getPreferences(Context.MODE_PRIVATE); TextView txtSettings = (TextView) findViewById(R.id.txtSettings); SpannableString Settings = new SpannableString(txtSettings.getText()); Settings.setSpan(new UnderlineSpan(), 0, Settings.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); txtSettings.setText(Settings); initCheckBoxes(); initSpinners(blnRestart); initButtons(); initHelp(); edDataDir = (EditText) findViewById(R.id.edDataDir); edDataDir.setSingleLine(true); edDataDir.setText(_main.JMGDataDirectory); edDataDir.setImeOptions(EditorInfo.IME_ACTION_DONE); edDataDir.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { String strDataDir = edDataDir.getText().toString(); File fileSelected = new File(strDataDir); if (fileSelected.isDirectory() && fileSelected.exists()) { _main.setJMGDataDirectory(fileSelected.getPath()); edDataDir.setText(_main.JMGDataDirectory); Editor editor = prefs.edit(); editor.putString("JMGDataDirectory", fileSelected.getPath()); editor.commit(); } } return true; } }); edDataDir.setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ShowDataDirDialog(); return true; } }); if (!(lib.NookSimpleTouch()) && !_main.isSmallDevice) { SettingsView.getViewTreeObserver() .addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { // Ensure you call it only once : lib.removeLayoutListener(SettingsView.getViewTreeObserver(), this); // Here you can get the size :) resize(0); //lib.ShowToast(_main, "Resize End"); } }); } else { //resize(1.8f); mScale = 1.0f; } _blnInitialized = true; } catch (Exception ex) { lib.ShowException(_main, ex); } }
From source file:com.lt.adamlee.aagame.GameView.java
public void help(Canvas c) { String x = ""; float textsize = F.hf(19.0f); Paint p4 = new Paint(); Paint p5 = new Paint(); Paint p6 = new Paint(); String text = ctx.getString(R.string.helptext); p4.setColor(getResources().getColor(R.color.bright_foreground_inverse_material_light)); p4.setFlags(1);//ww w . ja v a2 s. c om p5.setTypeface(tf); p5.setTextSize(F.hf(30.0f)); p6.setTextSize(textsize); p5.setColor(ViewCompat.MEASURED_STATE_MASK); c.drawRect(0.0f, 0.0f, (float) screenW, (float) screenH, p4); c.drawText(ctx.getString(R.string.help), ((float) (screenW / 2)) - (p5.measureText(ctx.getString(R.string.help)) / 2.0f), (float) (screenH / 8), p5); int i = 0; int xv1 = 0; int yv1 = (int) textsize; while (i < ctx.getString(R.string.helptext).length()) { if (text.charAt(i) != '$') { c.drawText(" " + ctx.getString(R.string.helptext).charAt(i), (float) xv1, ((float) ((screenH / 8) + yv1)) + (4.0f * textsize), p6); xv1 = (int) (((float) xv1) + p6.measureText(Character.toString(ctx.getString(R.string.helptext).charAt(i)))); } if (ctx.getString(R.string.helptext).charAt(i) == '$') { i++; x = " "; yv1 = (int) (((float) yv1) + textsize); xv1 = 0; } i++; } }
From source file:io.doist.datetimepicker.time.RadialTimePickerView.java
private void drawDebug(Canvas canvas) { // Draw outer numbers circle final float outerRadius = mCircleRadius[HOURS] * mNumbersRadiusMultiplier[HOURS]; canvas.drawCircle(mXCenter, mYCenter, outerRadius, mPaintDebug); // Draw inner numbers circle final float innerRadius = mCircleRadius[HOURS] * mNumbersRadiusMultiplier[HOURS_INNER]; canvas.drawCircle(mXCenter, mYCenter, innerRadius, mPaintDebug); // Draw outer background circle canvas.drawCircle(mXCenter, mYCenter, mCircleRadius[HOURS], mPaintDebug); // Draw outer rectangle for circles float left = mXCenter - outerRadius; float top = mYCenter - outerRadius; float right = mXCenter + outerRadius; float bottom = mYCenter + outerRadius; canvas.drawRect(left, top, right, bottom, mPaintDebug); // Draw outer rectangle for background left = mXCenter - mCircleRadius[HOURS]; top = mYCenter - mCircleRadius[HOURS]; right = mXCenter + mCircleRadius[HOURS]; bottom = mYCenter + mCircleRadius[HOURS]; canvas.drawRect(left, top, right, bottom, mPaintDebug); // Draw outer view rectangle canvas.drawRect(0, 0, getWidth(), getHeight(), mPaintDebug); // Draw selected time final String selected = String.format("%02d:%02d", getCurrentHour(), getCurrentMinute()); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); TextView tv = new TextView(getContext()); tv.setLayoutParams(lp);/* w ww . j a v a 2 s .co m*/ tv.setText(selected); tv.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); Paint paint = tv.getPaint(); paint.setColor(DEBUG_TEXT_COLOR); final int width = tv.getMeasuredWidth(); float height = paint.descent() - paint.ascent(); float x = mXCenter - width / 2; float y = mYCenter + 1.5f * height; canvas.drawText(selected, x, y, paint); }
From source file:net.toload.main.hd.candidate.CandidateView.java
private void doDraw(Canvas canvas) { if (mSuggestions == null) return;//from w ww . ja v a 2 s . c o m if (DEBUG) Log.i(TAG, "CandidateView:doDraw():Suggestion mCount:" + mCount + " mSuggestions.size:" + mSuggestions.size()); mTotalWidth = 0; updateFontSize(); if (mBgPadding == null) { mBgPadding = new Rect(0, 0, 0, 0); if (getBackground() != null) { getBackground().getPadding(mBgPadding); } } final int height = mHeight; final Rect bgPadding = mBgPadding; final Paint candidatePaint = mCandidatePaint; final Paint candidateEmojiPaint = mCandidatePaint; candidateEmojiPaint.setTextSize((float) (candidateEmojiPaint.getTextSize() * 0.9)); final Paint selKeyPaint = mSelKeyPaint; final int touchX = mTouchX; final int scrollX = getScrollX(); final boolean scrolled = mScrolled; final int textBaseLine = (int) (((height - mCandidatePaint.getTextSize()) / 2) - mCandidatePaint.ascent()); // Modified by jeremy '10, 3, 29. Update mselectedindex if touched and build wordX[i] and wordwidth[i] int x = 0; final int count = mCount; //Cache count here '11,8,18 for (int i = 0; i < count; i++) { if (count != mCount || mSuggestions == null || count != mSuggestions.size() || mSuggestions.size() == 0 || i >= mSuggestions.size()) return; // mSuggestion is updated, force abort String suggestion = mSuggestions.get(i).getWord(); if (i == 0 && mSuggestions.size() > 1 && mSuggestions.get(1).isRuntimeBuiltPhraseRecord() && suggestion.length() > 8) { suggestion = suggestion.substring(0, 2) + ".."; } float base = (suggestion == null) ? 0 : candidatePaint.measureText(""); float textWidth = (suggestion == null) ? 0 : candidatePaint.measureText(suggestion); if (textWidth < base) { textWidth = base; } final int wordWidth = (int) textWidth + X_GAP * 2; mWordX[i] = x; mWordWidth[i] = wordWidth; if (touchX + scrollX >= x && touchX + scrollX < x + wordWidth && !scrolled) { mSelectedIndex = i; } x += wordWidth; } mTotalWidth = x; if (DEBUG) Log.i(TAG, "CandidateView:doDraw():mTotalWidth :" + mTotalWidth + " this.getWidth():" + this.getWidth()); //Jeremy '11,8,11. If the candidate list is within 1 page and has more records, get full records first. if (mTotalWidth < this.getWidth()) checkHasMoreRecords(); // Paint all the suggestions and lines. if (canvas != null) { // Moved from above by jeremy '10 3, 29. Paint mSelectedindex in highlight here if (count > 0 && mSelectedIndex >= 0) { // candidatePaint.setColor(mColorComposingCode); // canvas.drawRect(mWordX[mSelectedIndex],bgPadding.top, mWordWidth[mSelectedIndex] , height, candidatePaint); canvas.translate(mWordX[mSelectedIndex], 0); mDrawableSuggestHighlight.setBounds(0, bgPadding.top, mWordWidth[mSelectedIndex], height); mDrawableSuggestHighlight.draw(canvas); canvas.translate(-mWordX[mSelectedIndex], 0); } if (mTransparentCandidateView) { canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR); Paint backgroundPaint = new Paint(); backgroundPaint.setColor(ContextCompat.getColor(mContext, R.color.third_background_light)); backgroundPaint.setAlpha(33); backgroundPaint.setStyle(Paint.Style.FILL); canvas.drawRect(0.5f, bgPadding.top, mScreenWidth, height, backgroundPaint); } for (int i = 0; i < count; i++) { if (count != mCount || mSuggestions == null || count != mSuggestions.size() || mSuggestions.size() == 0 || i >= mSuggestions.size()) break; boolean isEmoji = mSuggestions.get(i).isEmojiRecord(); String suggestion = mSuggestions.get(i).getWord(); if (i == 0 && mSuggestions.size() > 1 && mSuggestions.get(1).isRuntimeBuiltPhraseRecord() && suggestion.length() > 8) { suggestion = suggestion.substring(0, 2) + ".."; } int c = i + 1; switch (mSuggestions.get(i).getRecordType()) { case Mapping.RECORD_COMPOSING_CODE: if (mSelectedIndex == 0) { if (mTransparentCandidateView) { candidatePaint.setColor(mColorInvertedTextTransparent); } else { candidatePaint.setColor(mColorComposingCodeHighlight); } } else candidatePaint.setColor(mColorComposingCode); break; case Mapping.RECORD_CHINESE_PUNCTUATION_SYMBOL: case Mapping.RECORD_RELATED_PHRASE: selKeyPaint.setColor(mColorSelKeyShifted); if (i == mSelectedIndex) candidatePaint.setColor(mColorNormalTextHighlight); else candidatePaint.setColor(mColorNormalText); break; case Mapping.RECORD_EXACT_MATCH_TO_CODE: case Mapping.RECORD_PARTIAL_MATCH_TO_CODE: case Mapping.RECORD_RUNTIME_BUILT_PHRASE: case Mapping.RECORD_ENGLISH_SUGGESTION: default: selKeyPaint.setColor(mColorSelKey); if (i == mSelectedIndex) candidatePaint.setColor(mColorNormalTextHighlight); else candidatePaint.setColor(mColorNormalText); break; } if (isEmoji) { canvas.drawText(suggestion, mWordX[i] + X_GAP, Math.round(textBaseLine * 0.95), candidateEmojiPaint); } else { canvas.drawText(suggestion, mWordX[i] + X_GAP, textBaseLine, candidatePaint); } if (mShowNumber) { //Jeremy '11,6,17 changed from <=10 to mDisplaySelkey length. The length maybe 11 or 12 if shifted with space. if (c <= mDisplaySelkey.length()) { //Jeremy '11,6,11 Drawing text using relative font dimensions. canvas.drawText(mDisplaySelkey.substring(c - 1, c), mWordX[i] + mWordWidth[i] - height * 0.3f, height * 0.4f, selKeyPaint); } } //Draw spacer candidatePaint.setColor(mColorSpacer); canvas.drawLine(mWordX[i] + mWordWidth[i] + 0.5f, bgPadding.top + (mVerticalPadding / 2), mWordX[i] + mWordWidth[i] + 0.5f, height - (mVerticalPadding / 2), candidatePaint); candidatePaint.setFakeBoldText(false); } if (mTargetScrollX != getScrollX()) { if (DEBUG) Log.i(TAG, "CandidateView:doDraw():mTargetScrollX :" + mTargetScrollX + " getScrollX():" + getScrollX()); scrollToTarget(); } } }
From source file:io.doist.datetimepicker.time.RadialTimePickerView.java
/** * Draw the 12 text values at the positions specified by the textGrid parameters. *//*from www .j a v a2s.c o m*/ private void drawTextElements(Canvas canvas, float textSize, Typeface typeface, String[] texts, float[] textGridWidths, float[] textGridHeights, Paint paint, int color, int alpha) { paint.setTextSize(textSize); paint.setTypeface(typeface); paint.setColor(color); paint.setAlpha(getMultipliedAlpha(color, alpha)); canvas.drawText(texts[0], textGridWidths[3], textGridHeights[0], paint); canvas.drawText(texts[1], textGridWidths[4], textGridHeights[1], paint); canvas.drawText(texts[2], textGridWidths[5], textGridHeights[2], paint); canvas.drawText(texts[3], textGridWidths[6], textGridHeights[3], paint); canvas.drawText(texts[4], textGridWidths[5], textGridHeights[4], paint); canvas.drawText(texts[5], textGridWidths[4], textGridHeights[5], paint); canvas.drawText(texts[6], textGridWidths[3], textGridHeights[6], paint); canvas.drawText(texts[7], textGridWidths[2], textGridHeights[5], paint); canvas.drawText(texts[8], textGridWidths[1], textGridHeights[4], paint); canvas.drawText(texts[9], textGridWidths[0], textGridHeights[3], paint); canvas.drawText(texts[10], textGridWidths[1], textGridHeights[2], paint); canvas.drawText(texts[11], textGridWidths[2], textGridHeights[1], paint); }
From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java
/** * Applies the specified text appearance resource to a paint, returning the * text color if one is set in the text appearance. * * @param p the paint to modify/*from w w w .j a v a 2 s . c om*/ * @param resId the resource ID of the text appearance * @return the text color, if available */ private ColorStateList applyTextAppearance(Paint p, int resId) { // Workaround for inaccessible R.styleable.TextAppearance_* TextView tv = new TextView(mContext); if (SUtils.isApi_23_OrHigher()) { tv.setTextAppearance(resId); } else { //noinspection deprecation tv.setTextAppearance(mContext, resId); } p.setTypeface(tv.getTypeface()); p.setTextSize(tv.getTextSize()); final ColorStateList textColor = tv.getTextColors(); if (textColor != null) { final int enabledColor = textColor.getColorForState(ENABLED_STATE_SET, 0); p.setColor(enabledColor); } return textColor; }
From source file:com.cssweb.android.view.PriceMini.java
public void drawHKIndex(Canvas canvas) { Paint paint = this.mPaint; paint.setTypeface(Typeface.DEFAULT_BOLD); paint.setAntiAlias(true);/*from www . jav a2 s . c om*/ if (quoteData != null) { try { JSONArray jArr = quoteData.getJSONArray("data"); JSONObject jo = jArr.getJSONObject(0); double zrsp = jo.getDouble("zrsp"); double zjcj = jo.getDouble("zjcj"); paint.setTextSize(mTextSize * 2); setColor(paint, zjcj, zrsp); paint.setTextAlign(Paint.Align.LEFT); canvas.translate(DX * 0.5f, DY * 2f); canvas.drawText(Utils.dataFormation(zjcj, stockdigit), x, y, paint); paint.setStyle(Paint.Style.STROKE); paint.setTextSize(mTextSize); double zhangd = jo.getDouble("zd"); if (zhangd < 0) { paint.setColor(GlobalColor.colorPriceDown); } else if (zhangd > 0) { paint.setColor(GlobalColor.colorpriceUp); } else { paint.setColor(GlobalColor.colorPriceEqual); } canvas.translate(0, DY * 0.8f); String zhangdie = Utils.dataFormation(zhangd, stockdigit); if (zhangdie.equals("-")) canvas.drawText("", x, y, paint); else canvas.drawText(zhangdie, x, y, paint); double zhangf = jo.getDouble("zf"); if (zhangf < 0) { paint.setColor(GlobalColor.colorPriceDown); } else if (zhangf > 0) { paint.setColor(GlobalColor.colorpriceUp); } else { paint.setColor(GlobalColor.colorPriceEqual); } canvas.translate(DX * 3.5f, 0); String zhangfu = Utils.dataFormation(zhangf * 100, stockdigit); if (zhangfu.equals("-")) canvas.drawText("", x, y, paint); else canvas.drawText(zhangfu + "%", x, y, paint); paint.setColor(GlobalColor.colorLabelName); canvas.translate(-DX * 4f, DY * 1.2f); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("??", x, y, paint); canvas.translate(width / 2, -DY * 1); paint.setTextAlign(Paint.Align.RIGHT); paint.setColor(GlobalColor.colorLabelName); canvas.drawText(Utils.dataFormation(zrsp, stockdigit), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.getAmountFormat(jo.getDouble("cjje"), true), x - tips, y, paint); paint.setColor(GlobalColor.colorLabelName); paint.setTextAlign(Paint.Align.LEFT); canvas.translate(0, -DY * 4); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); paint.setTextAlign(Paint.Align.RIGHT); canvas.translate(width / 2, -DY * 3); double jrkp = jo.getDouble("jrkp"); setColor(paint, jrkp, zrsp); canvas.drawText(Utils.dataFormation(jrkp, stockdigit), x - tips, y, paint); canvas.translate(0, DY); double zg = jo.getDouble("zgcj"); setColor(paint, zg, zrsp); canvas.drawText(Utils.dataFormation(zg, stockdigit), x - tips, y, paint); canvas.translate(0, DY); double zd = jo.getDouble("zdcj"); setColor(paint, zd, zrsp); canvas.drawText(Utils.dataFormation(zd, stockdigit), x - tips, y, paint); paint.setColor(GlobalColor.colorStockName); canvas.translate(0, DY); canvas.drawText(Utils.dataFormation(jo.getDouble("amp") * 100, 1) + "%", x - tips, y, paint); } catch (JSONException e) { Log.e(TAG, e.toString()); } } else {//????? paint.setTextAlign(Paint.Align.LEFT); paint.setColor(GlobalColor.colorLabelName); canvas.translate(DX, DY * 2f); canvas.drawText("-", x, y, paint); paint.setStyle(Paint.Style.STROKE); paint.setTextSize(mTextSize); canvas.translate(-DX / 2, DY * 0.8f); canvas.drawText("-", x, y, paint); canvas.translate(DX * 2.5f, 0); canvas.drawText("-", x, y, paint); canvas.translate(-DX * 3, DY * 1.2f); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("??", x, y, paint); paint.setTextAlign(Paint.Align.LEFT); canvas.translate(width / 2, -DY * 4); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); canvas.translate(0, DY); canvas.drawText("", x, y, paint); } }
From source file:radialdemo.RadialMenuWidget.java
@Override protected void onDraw(Canvas c) { Paint paint = new Paint(); paint.setAntiAlias(true);// w ww. j av a 2 s .c om paint.setStrokeWidth(3); // draws a dot at the source of the press if (showSource == true) { paint.setColor(outlineColor); paint.setAlpha(outlineAlpha); paint.setStyle(Paint.Style.STROKE); c.drawCircle(xSource, ySource, cRadius / 10, paint); paint.setColor(selectedColor); paint.setAlpha(selectedAlpha); paint.setStyle(Paint.Style.FILL); c.drawCircle(xSource, ySource, cRadius / 10, paint); } //inner for (int i = 0; i < Wedges.length; i++) { RadialMenuWedge f = Wedges[i]; paint.setColor(outlineColor); paint.setAlpha(outlineAlpha); paint.setStyle(Paint.Style.STROKE); c.drawPath(f, paint); if (f == enabled && Wedge2Shown == true) { paint.setColor(wedge2Color); paint.setAlpha(wedge2Alpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } else if (f != enabled && Wedge2Shown == true) { paint.setColor(disabledColor); paint.setAlpha(disabledAlpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } else if (f == enabled && Wedge2Shown == false) { paint.setColor(wedge2Color); paint.setAlpha(wedge2Alpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } else if (f == selected) { paint.setColor(wedge2Color); paint.setAlpha(wedge2Alpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } else { paint.setColor(defaultColor); paint.setAlpha(defaultAlpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } //button content Rect rf = iconRect[i]; if ((menuEntries.get(i).getIcon() != 0) && (menuEntries.get(i).getLabel() != null)) { // This will look for a "new line" and split into multiple lines String menuItemName = menuEntries.get(i).getLabel(); String[] stringArray = menuItemName.split("\n"); paint.setColor(textColor); if (f != enabled && Wedge2Shown == true) { paint.setAlpha(disabledAlpha); } else { paint.setAlpha(textAlpha); } paint.setStyle(Paint.Style.FILL); paint.setTextSize(textSize); Rect rect = new Rect(); float textHeight = 0; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); textHeight = textHeight + (rect.height() + 3); } Rect rf2 = new Rect(); rf2.set(rf.left, rf.top - ((int) textHeight / 2), rf.right, rf.bottom - ((int) textHeight / 2)); float textBottom = rf2.bottom; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); float textLeft = rf.centerX() - rect.width() / 2; textBottom = textBottom + (rect.height() + 3); c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint); } // Puts in the Icon Drawable drawable = getResources().getDrawable(menuEntries.get(i).getIcon()); drawable.setBounds(rf2); if (f != enabled && Wedge2Shown == true) { drawable.setAlpha(disabledAlpha); } else { drawable.setAlpha(pictureAlpha); } drawable.draw(c); // Icon Only } else if (menuEntries.get(i).getIcon() != 0) { // Puts in the Icon Drawable drawable = getResources().getDrawable(menuEntries.get(i).getIcon()); drawable.setBounds(rf); if (f != enabled && Wedge2Shown == true) { drawable.setAlpha(disabledAlpha); } else { drawable.setAlpha(pictureAlpha); } drawable.draw(c); // Text Only } else { // Puts in the Text if no Icon paint.setColor(textColor); if (f != enabled && Wedge2Shown == true) { paint.setAlpha(disabledAlpha); } else { paint.setAlpha(textAlpha); } paint.setStyle(Paint.Style.FILL); paint.setTextSize(textSize + 10); // This will look for a "new line" and split into multiple lines String menuItemName = menuEntries.get(i).getLabel(); String[] stringArray = menuItemName.split("\n"); // gets total height Rect rect = new Rect(); float textHeight = 0; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); textHeight = textHeight + (rect.height() + 3); } float textBottom = rf.centerY() - (textHeight / 2); for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); float textLeft = rf.centerX() - rect.width() / 2; textBottom = textBottom + (rect.height() + 3); c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint); } } } // Animate the outer ring in/out if (animateOuterIn == true) { animateOuterWedges(ANIMATE_IN); } else if (animateOuterOut == true) { animateOuterWedges(ANIMATE_OUT); } //outer if (Wedge2Shown == true) { for (int i = 0; i < Wedges2.length; i++) { RadialMenuWedge f = Wedges2[i]; paint.setColor(outlineColor); paint.setAlpha(20); paint.setStyle(Paint.Style.STROKE); c.drawPath(f, paint); if (f == selected2) { paint.setColor(selectedColor); paint.setAlpha(selectedAlpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } else { paint.setColor(wedge2Color); paint.setAlpha(wedge2Alpha); paint.setStyle(Paint.Style.FILL); c.drawPath(f, paint); } Rect rf = iconRect2[i]; if ((wedge2Data.getChildren().get(i).getIcon() != 0) && (wedge2Data.getChildren().get(i).getLabel() != null)) { // This will look for a "new line" and split into multiple // lines String menuItemName = wedge2Data.getChildren().get(i).getLabel(); String[] stringArray = menuItemName.split("\n"); paint.setColor(textColor); paint.setAlpha(textAlpha); paint.setStyle(Paint.Style.FILL); paint.setTextSize(animateTextSize); Rect rect = new Rect(); float textHeight = 0; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); textHeight = textHeight + (rect.height() + 3); } Rect rf2 = new Rect(); rf2.set(rf.left, rf.top - ((int) textHeight / 2), rf.right, rf.bottom - ((int) textHeight / 2)); float textBottom = rf2.bottom; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); float textLeft = rf.centerX() - rect.width() / 2; textBottom = textBottom + (rect.height() + 3); c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint); } // Puts in the Icon Drawable drawable = getResources().getDrawable(wedge2Data.getChildren().get(i).getIcon()); drawable.setBounds(rf2); drawable.setAlpha(pictureAlpha); drawable.draw(c); // Icon Only } else if (wedge2Data.getChildren().get(i).getIcon() != 0) { // Puts in the Icon Drawable drawable = getResources().getDrawable(wedge2Data.getChildren().get(i).getIcon()); drawable.setBounds(rf); drawable.setAlpha(pictureAlpha); drawable.draw(c); // Text Only } else { // Puts in the Text if no Icon paint.setColor(textColor); paint.setAlpha(textAlpha); paint.setStyle(Paint.Style.FILL); paint.setTextSize(animateTextSize); // This will look for a "new line" and split into multiple // lines String menuItemName = wedge2Data.getChildren().get(i).getLabel(); String[] stringArray = menuItemName.split("\n"); // gets total height Rect rect = new Rect(); float textHeight = 0; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); textHeight = textHeight + (rect.height() + 3); } float textBottom = rf.centerY() - (textHeight / 2); for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); float textLeft = rf.centerX() - rect.width() / 2; textBottom = textBottom + (rect.height() + 3); c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint); } } } } //Check if the user has given input for centre circle if (centerCircle != null) { // Draws the Middle Circle paint.setColor(outlineColor); paint.setAlpha(outlineAlpha); paint.setStyle(Paint.Style.STROKE); c.drawCircle(xPosition, yPosition, cRadius, paint); if (inCircle == true) { paint.setColor(selectedColor); paint.setAlpha(selectedAlpha); paint.setStyle(Paint.Style.FILL); c.drawCircle(xPosition, yPosition, cRadius, paint); helper.onCloseAnimation(this, xPosition, yPosition, xSource, ySource); } else { paint.setColor(defaultColor); paint.setAlpha(defaultAlpha); paint.setStyle(Paint.Style.FILL); c.drawCircle(xPosition, yPosition, cRadius, paint); } // Draw the circle picture if ((centerCircle.getIcon() != 0) && (centerCircle.getLabel() != null)) { // This will look for a "new line" and split into multiple lines String menuItemName = centerCircle.getLabel(); String[] stringArray = menuItemName.split("\n"); paint.setColor(textColor); paint.setAlpha(textAlpha); paint.setStyle(Paint.Style.FILL); paint.setTextSize(textSize); Rect rectText = new Rect(); Rect rectIcon = new Rect(); Drawable drawable = getResources().getDrawable(centerCircle.getIcon()); int h = getIconSize(drawable.getIntrinsicHeight(), MinIconSize, MaxIconSize); int w = getIconSize(drawable.getIntrinsicWidth(), MinIconSize, MaxIconSize); rectIcon.set(xPosition - w / 2, yPosition - h / 2, xPosition + w / 2, yPosition + h / 2); float textHeight = 0; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rectText); textHeight = textHeight + (rectText.height() + 3); } rectIcon.set(rectIcon.left, rectIcon.top - ((int) textHeight / 2), rectIcon.right, rectIcon.bottom - ((int) textHeight / 2)); float textBottom = rectIcon.bottom; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rectText); float textLeft = xPosition - rectText.width() / 2; textBottom = textBottom + (rectText.height() + 3); c.drawText(stringArray[j], textLeft - rectText.left, textBottom - rectText.bottom, paint); } // Puts in the Icon drawable.setBounds(rectIcon); drawable.setAlpha(pictureAlpha); drawable.draw(c); // Icon Only } else if (centerCircle.getIcon() != 0) { Rect rect = new Rect(); Drawable drawable = getResources().getDrawable(centerCircle.getIcon()); int h = getIconSize(drawable.getIntrinsicHeight(), MinIconSize, MaxIconSize); int w = getIconSize(drawable.getIntrinsicWidth(), MinIconSize, MaxIconSize); rect.set(xPosition - w / 2, yPosition - h / 2, xPosition + w / 2, yPosition + h / 2); drawable.setBounds(rect); drawable.setAlpha(pictureAlpha); drawable.draw(c); // Text Only } else { // Puts in the Text if no Icon paint.setColor(textColor); paint.setAlpha(textAlpha); paint.setStyle(Paint.Style.FILL); paint.setTextSize(textSize); // This will look for a "new line" and split into multiple lines String menuItemName = centerCircle.getLabel(); String[] stringArray = menuItemName.split("\n"); // gets total height Rect rect = new Rect(); float textHeight = 0; for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); textHeight = textHeight + (rect.height() + 3); } float textBottom = yPosition - (textHeight / 2); for (int j = 0; j < stringArray.length; j++) { paint.getTextBounds(stringArray[j], 0, stringArray[j].length(), rect); float textLeft = xPosition - rect.width() / 2; textBottom = textBottom + (rect.height() + 3); c.drawText(stringArray[j], textLeft - rect.left, textBottom - rect.bottom, paint); } } } // Draws Text in TextBox if (headerString != null) { paint.setTextSize(headerTextSize); paint.getTextBounds(headerString, 0, headerString.length(), this.textRect); if (HeaderBoxBounded == false) { determineHeaderBox(); HeaderBoxBounded = true; } paint.setColor(outlineColor); paint.setAlpha(outlineAlpha); paint.setStyle(Paint.Style.STROKE); c.drawRoundRect(this.textBoxRect, scalePX(5), scalePX(5), paint); paint.setColor(headerBackgroundColor); paint.setAlpha(headerBackgroundAlpha); paint.setStyle(Paint.Style.FILL); c.drawRoundRect(this.textBoxRect, scalePX(5), scalePX(5), paint); paint.setColor(headerTextColor); paint.setAlpha(headerTextAlpha); paint.setStyle(Paint.Style.FILL); paint.setTextSize(headerTextSize); c.drawText(headerString, headerTextLeft, headerTextBottom, paint); } }