• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Révision01889503c47aadc9faacf727371f1d23e3a99d97 (tree)
l'heure2009-11-14 09:36:18
AuteurXavier Ducrohet <xav@andr...>
CommiterXavier Ducrohet

Message de Log

Properly implement Paint.breakText for layoutlib. (do not merge)

BUG 2260400

This is integrated from Eclair.

Change Summary

Modification

--- a/tools/layoutlib/bridge/src/android/graphics/Paint.java
+++ b/tools/layoutlib/bridge/src/android/graphics/Paint.java
@@ -755,13 +755,45 @@ public class Paint extends _Original_Paint {
755755 @Override
756756 public int breakText(String text, boolean measureForwards,
757757 float maxWidth, float[] measuredWidth) {
758- // NOTE: javadoc doesn't match. Just a guess.
759758 return breakText(text,
760759 0 /* start */, text.length() /* end */,
761760 measureForwards, maxWidth, measuredWidth);
762761 }
763762
764763 /**
764+ * Measure the text, stopping early if the measured width exceeds maxWidth.
765+ * Return the number of chars that were measured, and if measuredWidth is
766+ * not null, return in it the actual width measured.
767+ *
768+ * @param text The text to measure
769+ * @param start The offset into text to begin measuring at
770+ * @param end The end of the text slice to measure.
771+ * @param measureForwards If true, measure forwards, starting at start.
772+ * Otherwise, measure backwards, starting with end.
773+ * @param maxWidth The maximum width to accumulate.
774+ * @param measuredWidth Optional. If not null, returns the actual width
775+ * measured.
776+ * @return The number of chars that were measured. Will always be <=
777+ * abs(end - start).
778+ */
779+ @Override
780+ public int breakText(CharSequence text, int start, int end, boolean measureForwards,
781+ float maxWidth, float[] measuredWidth) {
782+ char[] buf = new char[end - start];
783+ int result;
784+
785+ TextUtils.getChars(text, start, end, buf, 0);
786+
787+ if (measureForwards) {
788+ result = breakText(buf, 0, end - start, maxWidth, measuredWidth);
789+ } else {
790+ result = breakText(buf, 0, -(end - start), maxWidth, measuredWidth);
791+ }
792+
793+ return result;
794+ }
795+
796+ /**
765797 * Return the advance widths for the characters in the string.
766798 *
767799 * @param text The text to measure