From 41c87ecdca3678ca1996c48843afb63a9ceff36d Mon Sep 17 00:00:00 2001 From: "mmarc471@gmail.com" Date: Thu, 10 Sep 2020 20:10:56 +0200 Subject: [PATCH] suppresion de code inutile --- .../myapplication/Video/Drawable.java | 80 ------------------- 1 file changed, 80 deletions(-) diff --git a/app/src/main/java/com/iutlaval/myapplication/Video/Drawable.java b/app/src/main/java/com/iutlaval/myapplication/Video/Drawable.java index ee7db01..6008bd3 100644 --- a/app/src/main/java/com/iutlaval/myapplication/Video/Drawable.java +++ b/app/src/main/java/com/iutlaval/myapplication/Video/Drawable.java @@ -83,64 +83,18 @@ public class Drawable { List linesOfText = cutText(20,text); p.setTextSize(textSize); - /*float size = 0; - for(String str : linesOfText) - { - float i; - if((i = getTextSizeForWidth(p,x_scaled_size,y_scaled_size,str)) > size) - { - size = i; - } - } - p.setTextSize(size);*/ //+10 permet d'e prendre en compte les p,q,j qui dessende plus bas que les autres bitmap = Bitmap.createBitmap(x_scaled_size, y_scaled_size+10, Bitmap.Config.ARGB_8888); Canvas c = new Canvas(bitmap); - /*List linesOfText = cutText(20,text); - - bitmap = Bitmap.createBitmap((int)(textSize * 9), (int) 40*linesOfText.size(), Bitmap.Config.ARGB_8888); - - checkPaint(); - p.setTextSize(textSize); - p.setColor(Color.BLACK); - - Canvas c = new Canvas(bitmap); -*/ int index = 1; for(String line : linesOfText) { c.drawText(line ,0,index*y_scaled_size/linesOfText.size(),p); index++; } -/* - float x_scaled_size = x_size* GameActivity.screenWidth/100; - float y_scaled_size = y_size* GameActivity.screenHeight/100; - bitmap = Bitmap.createScaledBitmap(bitmap, (int)x_scaled_size, (int)y_scaled_size, GameActivity.bilinearFiltering);*/ - } - private String arrangeText(int charPerLines, String text) { - //TODO cut text in lines - StringBuilder nextLine = new StringBuilder(text); - int index = 0; - int size=0; - for (String word : text.split(" ")) { - if(word.length() < charPerLines) - { - if(word.length() + size +1 < charPerLines) - { - index +=word.length(); - size += word.length(); - }else{ - size=0; - nextLine.insert(index++,'\n'); - } - }else{ - Log.e("TextRender","ERROR WORD TOO LONG :" + word); - } - } - return nextLine.toString(); } @@ -287,38 +241,4 @@ public class Drawable { } return output; } - - private void fillWithSpace(StringBuilder nextLine, int charPerLines) { - for(int i=0 ; i < charPerLines-nextLine.length();i++) - { - nextLine.append(' '); - } - } - - /** - * https://stackoverflow.com/questions/12166476/android-canvas-drawtext-set-font-size-from-width - * @param paint - * @param desiredWidth - * @param text - */ - private static float getTextSizeForWidth(Paint paint, float desiredWidth, - String text) { - - // Pick a reasonably large value for the test. Larger values produce - // more accurate results, but may cause problems with hardware - // acceleration. But there are workarounds for that, too; refer to - // http://stackoverflow.com/questions/6253528/font-size-too-large-to-fit-in-cache - final float testTextSize = 48f; - - // Get the bounds of the text, using our testTextSize. - paint.setTextSize(testTextSize); - Rect bounds = new Rect(); - paint.getTextBounds(text, 0, text.length(), bounds); - - // Calculate the desired size as a proportion of our testTextSize. - float desiredTextWidth = testTextSize * desiredWidth / bounds.width(); - - // Set the paint for that size. - return desiredTextWidth; - } }