Comments (5)
I've answered on SO but here is "an" answer to help anyone else which
experiences the problem..
In com/jwetherell/augmented_reality/ui/objects/PaintableObject.java
Try changing the method:
public float getTextWidth(String txt) {
if (txt == null) throw new NullPointerException();
//return paint.measureText(txt);
return paint.measureText(txt, 0, txt.length);
}
Or try this if that doesn't work:
public float getTextWidth(String txt) {
if (txt == null) throw new NullPointerException();
//return paint.measureText(txt);
char[] seq = new char[txt.length()];
for(int i =0; i < txt.length(); i++) {
seq[i] = txt.charAt(i);
}
return paint.measureText(seq, 0, seq.length);
}
If all else fails, try this:
public float getTextWidth(String txt) {
if (txt == null) throw new NullPointerException();
//return paint.measureText(txt);
char[] seq = new char[txt.length()];
for(int i =0; i < txt.length(); i++) {
seq[i] = txt.charAt(i);
}
Rect bounds = new Rect();
paint.getTextBounds(seq, 0, seq.length, bounds);
return bounds.width();
}
I believe this is a JNI issue and theses are work arounds for the known JNI
issue. I haven't compiled the code, so there may some mistakes but you get the
idea.
Original comment by [email protected]
on 29 May 2013 at 11:44
from android-augment-reality-framework.
hi Mr phishman, thx for your reply , but the problem is still there , the
activity still force closed
Original comment by [email protected]
on 30 May 2013 at 12:00
from android-augment-reality-framework.
this is the logcat that i run with your third solution -pastebin.com/j7Vsp2pg
,thank you
Original comment by [email protected]
on 30 May 2013 at 12:01
from android-augment-reality-framework.
Thank you so much Mr Justin , your solution and effort saved me from getting
fail of this subject, thank you , the problem is solved, thank you
Original comment by [email protected]
on 31 May 2013 at 5:10
from android-augment-reality-framework.
This is another work around, if the ones above do not work.
private StaticLayout measure(TextPaint textPaint, String text, Integer
wrapWidth) {
int boundedWidth = Integer.MAX_VALUE;
if (wrapWidth != null && wrapWidth > 0) {
boundedWidth = wrapWidth;
}
StaticLayout layout = new StaticLayout(text, textPaint, boundedWidth, Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
return layout;
}
private float getMaxLineWidth(StaticLayout layout) {
float maxLine = 0.0f;
int lineCount = layout.getLineCount();
for (int i=0; i<lineCount; i++) {
if (layout.getLineWidth(0) > maxLine) {
maxLine = layout.getLineWidth(0);
}
}
return maxLine;
}
public float getTextWidth(String text) {
if (text == null) throw new NullPointerException();
TextPaint textPaint = new TextPaint(paint);
int widthWrap = 1000; // you may have to change this
StaticLayout layout = measure(textPaint, text, widthWrap);
return getMaxLineWidth(layout);
}
Original comment by [email protected]
on 31 May 2013 at 5:16
- Changed state: Verified
from android-augment-reality-framework.
Related Issues (20)
- Markers not updated properly HOT 2
- markers position HOT 2
- ARData azimuth HOT 2
- Program fail in AVD 4.2 HOT 3
- Live marker rotation HOT 3
- Rotation refresh rate is really slow HOT 1
- Latest code working for both orientations. What if want to work on one only? HOT 4
- Does not show multiple POIs close enough to share the screen space HOT 4
- Reference Table overflow HOT 2
- AFatal signal 11 (SIGSEGV) HOT 9
- apps auto close when too much marker on certain angle HOT 2
- Problem with icon movement in the screen HOT 2
- License change HOT 1
- Local Datasorce not showing POI HOT 2
- How to optimize the rendering performance for AR Objects(Markers) HOT 15
- Canvas getMatrix method dprecated HOT 5
- Show map view summary when device is horizontal to ground
- Marker on screen move with device movement
- Wrong marker position when marker is behind us
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-augment-reality-framework.