List of usage examples for android.graphics Paint setTextSize
public void setTextSize(float textSize)
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void setupHourTextPaint(Paint p) { p.setColor(mCalendarHourLabelColor); p.setTextSize(HOURS_TEXT_SIZE); p.setTypeface(Typeface.DEFAULT);/*from w w w. j a va 2 s .c o m*/ p.setTextAlign(Align.RIGHT); p.setAntiAlias(true); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void drawAmPm(Canvas canvas, Paint p) { p.setColor(mCalendarAmPmLabel);//w w w. j a v a 2s . c o m p.setTextSize(AMPM_TEXT_SIZE); p.setTypeface(mBold); p.setAntiAlias(true); p.setTextAlign(Align.RIGHT); String text = mAmString; if (mFirstHour >= 12) { text = mPmString; } int y = mFirstCell + mFirstHourOffset + 2 * mHoursTextHeight + HOUR_GAP; canvas.drawText(text, HOURS_LEFT_MARGIN, y, p); if (mFirstHour < 12 && mFirstHour + mNumHours > 12) { // Also draw the "PM" text = mPmString; y = mFirstCell + mFirstHourOffset + (12 - mFirstHour) * (mCellHeight + HOUR_GAP) + 2 * mHoursTextHeight + HOUR_GAP; canvas.drawText(text, HOURS_LEFT_MARGIN, y, p); } }
From source file:com.eveningoutpost.dexdrip.Home.java
private void setupCharts() { bgGraphBuilder = new BgGraphBuilder(this); updateStuff = false;// ww w . jav a2 s .c om chart = (LineChartView) findViewById(R.id.chart); if (BgGraphBuilder.isXLargeTablet(getApplicationContext())) { ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) chart.getLayoutParams(); params.topMargin = 130; chart.setLayoutParams(params); } chart.setBackgroundColor(getCol(X.color_home_chart_background)); chart.setZoomType(ZoomType.HORIZONTAL); //Transmitter Battery Level final Sensor sensor = Sensor.currentSensor(); if (sensor != null && sensor.latest_battery_level != 0 && sensor.latest_battery_level <= Constants.TRANSMITTER_BATTERY_LOW && !prefs.getBoolean("disable_battery_warning", false)) { Drawable background = new Drawable() { @Override public void draw(Canvas canvas) { DisplayMetrics metrics = getApplicationContext().getResources().getDisplayMetrics(); int px = (int) (30 * (metrics.densityDpi / 160f)); Paint paint = new Paint(); paint.setTextSize(px); paint.setAntiAlias(true); paint.setColor(Color.parseColor("#FFFFAA")); paint.setStyle(Paint.Style.STROKE); paint.setAlpha(100); canvas.drawText(getString(R.string.transmitter_battery), 10, chart.getHeight() / 3 - (int) (1.2 * px), paint); if (sensor.latest_battery_level <= Constants.TRANSMITTER_BATTERY_EMPTY) { paint.setTextSize((int) (px * 1.5)); canvas.drawText(getString(R.string.very_low), 10, chart.getHeight() / 3, paint); } else { canvas.drawText(getString(R.string.low), 10, chart.getHeight() / 3, paint); } } @Override public void setAlpha(int alpha) { } @Override public void setColorFilter(ColorFilter cf) { } @Override public int getOpacity() { return 0; // TODO Which pixel format should this be? } }; chart.setBackground(background); } previewChart = (PreviewLineChartView) findViewById(R.id.chart_preview); chart.setLineChartData(bgGraphBuilder.lineData()); chart.setOnValueTouchListener(bgGraphBuilder.getOnValueSelectTooltipListener(mActivity)); previewChart.setBackgroundColor(getCol(X.color_home_chart_background)); previewChart.setZoomType(ZoomType.HORIZONTAL); previewChart.setLineChartData(bgGraphBuilder.previewLineData(chart.getLineChartData())); updateStuff = true; previewChart.setViewportCalculationEnabled(true); chart.setViewportCalculationEnabled(true); previewChart.setViewportChangeListener(new ViewportListener()); chart.setViewportChangeListener(new ChartViewPortListener()); setViewport(); if (small_height) { previewChart.setVisibility(View.GONE); // quick test Viewport moveViewPort = new Viewport(chart.getMaximumViewport()); float tempwidth = (float) moveViewPort.width() / 4; holdViewport.left = moveViewPort.right - tempwidth; holdViewport.right = moveViewPort.right + (moveViewPort.width() / 24); holdViewport.top = moveViewPort.top; holdViewport.bottom = moveViewPort.bottom; chart.setCurrentViewport(holdViewport); previewChart.setCurrentViewport(holdViewport); } else { previewChart.setVisibility(View.VISIBLE); } if (insulinset || glucoseset || carbsset || timeset) { if (chart != null) { chart.setAlpha((float) 0.10); // TODO also set buttons alpha } } }
From source file:info.bartowski.easteregg.MLand.java
@Override public void onDraw(Canvas c) { super.onDraw(c); if (SHOW_TOUCHES) { for (Player p : mPlayers) { if (p.mTouchX > 0) { mTouchPaint.setColor(0x80FFFFFF & p.color); mPlayerTracePaint.setColor(0x80FFFFFF & p.color); float x1 = p.mTouchX; float y1 = p.mTouchY; c.drawCircle(x1, y1, 100, mTouchPaint); float x2 = p.getX() + p.getPivotX(); float y2 = p.getY() + p.getPivotY(); float angle = PI_2 - (float) Math.atan2(x2 - x1, y2 - y1); x1 += 100 * Math.cos(angle); y1 += 100 * Math.sin(angle); c.drawLine(x1, y1, x2, y2, mPlayerTracePaint); }//from w w w . j a v a 2 s .c o m } } if (!DEBUG_DRAW) return; final Paint pt = new Paint(); pt.setColor(0xFFFFFFFF); for (Player p : mPlayers) { final int L = p.corners.length; final int N = L / 2; for (int i = 0; i < N; i++) { final int x = (int) p.corners[i * 2]; final int y = (int) p.corners[i * 2 + 1]; c.drawCircle(x, y, 4, pt); c.drawLine(x, y, p.corners[(i * 2 + 2) % L], p.corners[(i * 2 + 3) % L], pt); } } pt.setStyle(Paint.Style.STROKE); pt.setStrokeWidth(getResources().getDisplayMetrics().density); final int M = getChildCount(); pt.setColor(0x8000FF00); for (int i = 0; i < M; i++) { final View v = getChildAt(i); if (v instanceof Player) continue; if (!(v instanceof GameView)) continue; if (v instanceof Pop) { final Pop pop = (Pop) v; c.drawCircle(pop.cx, pop.cy, pop.r, pt); } else { final Rect r = new Rect(); v.getHitRect(r); c.drawRect(r, pt); } } pt.setColor(Color.BLACK); final StringBuilder sb = new StringBuilder("obstacles: "); for (Obstacle ob : mObstaclesInPlay) { sb.append(ob.hitRect.toShortString()); sb.append(" "); } pt.setTextSize(20f); c.drawText(sb.toString(), 20, 100, pt); }
From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java
private void drawDayHeader(String dayStr, int day, String dateNumStr, Canvas canvas, Paint p) { int x;/*from w w w . j a v a 2s .c o m*/ p.setAntiAlias(true); int todayIndex = mTodayJulianDay - mFirstJulianDay; // Draw day of the month if (mNumDays > 1) { float y = DAY_HEADER_HEIGHT - DAY_HEADER_BOTTOM_MARGIN; // Draw day of the month x = computeDayLeftPosition(day + 1) - DAY_HEADER_RIGHT_MARGIN; p.setTextAlign(Align.RIGHT); p.setTextSize(DATE_HEADER_FONT_SIZE); p.setTypeface(todayIndex == day ? mBold : Typeface.DEFAULT); canvas.drawText(dateNumStr, x, y, p); // Draw day of the week x -= p.measureText(" " + dateNumStr); p.setTextSize(DAY_HEADER_FONT_SIZE); p.setTypeface(Typeface.DEFAULT); canvas.drawText(dayStr, x, y, p); } else { float y = DAY_HEADER_HEIGHT - DAY_HEADER_ONE_DAY_BOTTOM_MARGIN; p.setTextAlign(Align.LEFT); // Draw day of the week x = computeDayLeftPosition(day) + DAY_HEADER_ONE_DAY_LEFT_MARGIN; x = x + ((mCellWidth - mDateStrWidthLong) / 2); p.setTextSize(DAY_HEADER_FONT_SIZE); p.setTypeface(Typeface.DEFAULT); canvas.drawText(dayStr, x, y, p); // Draw day of the month x += p.measureText(dayStr) + DAY_HEADER_ONE_DAY_RIGHT_MARGIN; p.setTextSize(DATE_HEADER_FONT_SIZE); p.setTypeface(todayIndex == day ? mBold : Typeface.DEFAULT); canvas.drawText(dateNumStr, x, y, p); } }
From source file:com.example.SmartBoard.DrawingView.java
public void onDrawLine(Canvas canvas) { Paint paint = drawPaint; if (points[1] == null) //point4 null when user did not touch and move on screen. return;/*from ww w . j a va 2 s . c om*/ //draw stroke paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(5); if (finished) { JSONObject objectProperties = new JSONObject(); String key = UUID.randomUUID().toString(); try { objectProperties.put("id", key); objectProperties.put("clientId", client.getClientId()); objectProperties.put("type", "Line"); objectProperties.put("color", drawPaint.getColor()); objectProperties.put("size", 5); objectProperties.put("startx", linePath.startx()); objectProperties.put("starty", linePath.starty()); objectProperties.put("stopx", linePath.stopx()); objectProperties.put("stopy", linePath.stopy()); objectProperties.put("gradient", linePath.getGradient()); objectProperties.put("length", linePath.length()); } catch (JSONException e) { e.printStackTrace(); } objectDrawables.put(key, objectProperties); mqtt.publishLine(objectProperties); //reset to start drawing again points = new Point[4]; colorballs.clear(); return; } canvas.drawLine(linePath.startx(), linePath.starty(), linePath.stopx(), linePath.stopy(), paint); // draw the balls on the canvas paint.setTextSize(18); paint.setStrokeWidth(0); for (int i = 0; i < colorballs.size(); i++) { ColorBall ball = colorballs.get(i); canvas.drawBitmap(ball.getBitmap(), ball.getX(), ball.getY(), paint); canvas.drawText("" + (i + 1), ball.getX(), ball.getY(), paint); } }
From source file:com.cssweb.android.view.KlineView.java
public void drawQuoteWin(Canvas canvas, JSONObject quoteData, int idx) throws JSONException { Paint mPaint = new Paint(); mPaint.setTextAlign(Paint.Align.LEFT); mPaint.setStyle(Paint.Style.STROKE); mPaint.setTypeface(Typeface.DEFAULT_BOLD); mPaint.setAntiAlias(true);//from w w w . j a v a2 s. c o m mPaint.setColor(GlobalColor.colorKlinePopub); mPaint.setTextSize(sTextSize); canvas.drawText(":", 0, axisLabelHeight, mPaint); canvas.drawText(":", 0, axisLabelHeight * 3, mPaint); canvas.drawText(":", 0, axisLabelHeight * 5, mPaint); canvas.drawText(":", 0, axisLabelHeight * 7, mPaint); canvas.drawText(":", 0, axisLabelHeight * 9, mPaint); canvas.drawText(":", 0, axisLabelHeight * 11, mPaint); canvas.drawText("??:", 0, axisLabelHeight * 13, mPaint); canvas.drawText("??:", 0, axisLabelHeight * 15, mPaint); mPaint.setTextAlign(Paint.Align.RIGHT); String qt = quoteData.getJSONArray("K").getJSONArray(idx).getString(0); double jrkp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(1); double zg = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(2); double zd = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(3); double sp = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4); double preclose; if ("cf".equals(exchange) || "dc".equals(exchange) || "sf".equals(exchange) || "cz".equals(exchange)) { switch (idx) { case 0: preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(7); break; default: preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(7); break; } if (quoteData.getJSONArray("K").length() == 1) { preclose = quoteData.getJSONArray("K").getJSONArray(0).getDouble(7); } } else { switch (idx) { case 0: preclose = quoteData.getJSONArray("K").getJSONArray(idx).getDouble(4); break; default: preclose = quoteData.getJSONArray("K").getJSONArray(idx - 1).getDouble(4); break; } if (quoteData.getJSONArray("K").length() == 1) { preclose = quoteData.getDouble("zrsp");//quoteData.getJSONArray("K").getJSONArray(0).getDouble(4); } } mPaint.setColor(getcolor(jrkp, preclose)); canvas.drawText(Utils.dataFormation(jrkp, stockdigit), klineX, axisLabelHeight * 2, mPaint); mPaint.setColor(getcolor(zg, preclose)); canvas.drawText(Utils.dataFormation(zg, stockdigit), klineX, axisLabelHeight * 4, mPaint); mPaint.setColor(getcolor(zd, preclose)); canvas.drawText(Utils.dataFormation(zd, stockdigit), klineX, axisLabelHeight * 6, mPaint); mPaint.setColor(getcolor(sp, preclose)); canvas.drawText(Utils.dataFormation(sp, stockdigit), klineX, axisLabelHeight * 8, mPaint); double zhangdie = sp - preclose; if (zhangdie > 0) mPaint.setColor(GlobalColor.colorpriceUp); else if (zhangdie < 0) mPaint.setColor(GlobalColor.colorPriceDown); else mPaint.setColor(GlobalColor.colorPriceEqual); canvas.drawText(Utils.dataFormation(zhangdie, stockdigit), klineX, axisLabelHeight * 10, mPaint); // if(quoteData.getString("period").equals("min5") || // quoteData.getString("period").equals("min15") || // quoteData.getString("period").equals("min30") || // quoteData.getString("period").equals("min60")){ // qt = qt.substring(4,6)+'/'+qt.substring(6,8)+' '+qt.substring(8); // }else{ // qt = qt.substring(2,4)+qt.substring(4,6)+qt.substring(6,8); // } qt = qt.substring(2, 4) + qt.substring(4, 6) + qt.substring(6, 8); mPaint.setColor(GlobalColor.colorLabelName); canvas.drawText(qt, klineX, axisLabelHeight * 12, mPaint); mPaint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(quoteData.getJSONArray("K").getJSONArray(idx).getDouble(5), false), klineX, axisLabelHeight * 14, mPaint); mPaint.setColor(GlobalColor.colorStockName); canvas.drawText(Utils.getAmountFormat(quoteData.getJSONArray("K").getJSONArray(idx).getDouble(6), false), klineX, axisLabelHeight * 16, mPaint); }
From source file:com.example.SmartBoard.DrawingView.java
public void onDrawCircle(Canvas canvas) { Paint paint = drawPaint; if (points[3] == null) //point4 null when user did not touch and move on screen. return;/*w w w . ja v a2 s . c om*/ int left, top, right, bottom; left = points[0].x; top = points[0].y; right = points[0].x; bottom = points[0].y; for (int i = 1; i < points.length; i++) { left = left > points[i].x ? points[i].x : left; top = top > points[i].y ? points[i].y : top; right = right < points[i].x ? points[i].x : right; bottom = bottom < points[i].y ? points[i].y : bottom; } float cx = (left + right) / 2f; float cy = (top + bottom) / 2f; float radius = (float) Math.hypot(top - bottom, right - left) / 2f; //draw stroke paint.setStyle(Paint.Style.STROKE); // paint.setColor(Color.parseColor("#AADB1255")); paint.setStrokeWidth(5); if (finished) { JSONObject objectProperties = new JSONObject(); String key = UUID.randomUUID().toString(); try { objectProperties.put("id", key); objectProperties.put("type", "Circle"); objectProperties.put("color", drawPaint.getColor()); objectProperties.put("size", 5); objectProperties.put("clientId", client.getClientId()); objectProperties.put("radius", radius); objectProperties.put("x", cx); objectProperties.put("y", cy); } catch (JSONException e) { } objectDrawables.put(key, objectProperties); // drawCanvas.drawCircle(cx, cy, radius, paint); // drawCanvas.save(); // mqtt.publishRectangle(objectProperties); mqtt.publishCircle(objectProperties); //reset to start drawing again points = new Point[4]; colorballs.clear(); return; } canvas.drawCircle(cx, cy, radius, paint); // draw the balls on the canvas // paint.setColor(Color.BLUE); paint.setTextSize(18); paint.setStrokeWidth(0); // paint.setColor(Color.BLUE); for (int i = 0; i < colorballs.size(); i++) { ColorBall ball = colorballs.get(i); canvas.drawBitmap(ball.getBitmap(), ball.getX(), ball.getY(), paint); canvas.drawText("" + (i + 1), ball.getX(), ball.getY(), paint); } }
From source file:com.example.SmartBoard.DrawingView.java
public void onDrawRectangle(Canvas canvas) { Paint paint = drawPaint; if (points[3] == null) //point4 null when user did not touch and move on screen. return;/*from w w w . j a v a 2 s .co m*/ int left, top, right, bottom; left = points[0].x; top = points[0].y; right = points[0].x; bottom = points[0].y; for (int i = 1; i < points.length; i++) { left = left > points[i].x ? points[i].x : left; top = top > points[i].y ? points[i].y : top; right = right < points[i].x ? points[i].x : right; bottom = bottom < points[i].y ? points[i].y : bottom; } //draw stroke paint.setStyle(Paint.Style.STROKE); // paint.setColor(Color.parseColor("#AADB1255")); paint.setStrokeWidth(5); if (finished) { Rect rect = new Rect(left + colorballs.get(0).getWidthOfBall() / 2, top + colorballs.get(0).getWidthOfBall() / 2, right + colorballs.get(2).getWidthOfBall() / 2, bottom + colorballs.get(2).getWidthOfBall() / 2); JSONObject objectProperties = new JSONObject(); String key = UUID.randomUUID().toString(); try { objectProperties.put("type", "Rectangle"); objectProperties.put("clientId", client.getClientId()); objectProperties.put("id", key); objectProperties.put("color", drawPaint.getColor()); objectProperties.put("size", 5); objectProperties.put("dimens", rect.flattenToString()); } catch (JSONException e) { } objectDrawables.put(key, objectProperties); mqtt.publishRectangle(objectProperties); //reset to start drawing again points = new Point[4]; colorballs.clear(); return; } //temporary canvas drawing on resize mode canvas.drawRect(left + colorballs.get(0).getWidthOfBall() / 2, top + colorballs.get(0).getWidthOfBall() / 2, right + colorballs.get(2).getWidthOfBall() / 2, bottom + colorballs.get(2).getWidthOfBall() / 2, paint); //draw the corners BitmapDrawable bitmap = new BitmapDrawable(); // draw the balls on the canvas paint.setTextSize(18); paint.setStrokeWidth(0); for (int i = 0; i < colorballs.size(); i++) { ColorBall ball = colorballs.get(i); canvas.drawBitmap(ball.getBitmap(), ball.getX(), ball.getY(), paint); // System.out.println("RectMode"); canvas.drawText("" + (i + 1), ball.getX(), ball.getY(), paint); } }
From source file:radialdemo.RadialMenuWidget.java
@Override protected void onDraw(Canvas c) { Paint paint = new Paint(); paint.setAntiAlias(true);//from w ww .ja v a2 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); } }