[android-developers] Heatmaps

2011-06-09 Thread Vinicius Carvalho
Hi, just would like to share a lib that I was building for the past
week: http://code.google.com/p/mapex/

There you will find a heatmap implementation, demos of it working with
some real data. And also other things like support for a selection box
on a map (something that I was in need for a while)

I intend to add more features to it, for instance clustering for
markers (I already have the algorithm in plain java for server side,
just porting it)

I'm really trying to get this working any comment would be great. I
know there's some bugs here and there, working on them, please report
them, as well features requests.

Regards

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Android weight question

2011-06-03 Thread Vinicius Carvalho
Chris, thanks for the hint but it did not work as well. I've added the
weightsum, but still once the text is bigger than a certain value,
things get messy, it's not even like the text is bigger than the
textview area.

What I have is a scrollview, and inside it I add new layouts as the
user requests, those are filters, and I have two types, a column
filter:

---
| TextView
| Spinner   |
Edit | img|
---

And a location filter:

---
|
TextView
| Img| Edit   | img|
---


When I add two column filters, if the TextView text is small (Country
and Name being good examples) they are both aligned.

But if I add one with a bigger text (Reactors under construction as an
example, although I do not believe its text will be bigger than the
area), it looses the alignment.

Any other ideas.

Best regards

PS: I put the screenshot of the app here:http://furiousbob.com/
device-2011-06-03-103847.png , actually you can notice that even for
country and name there's a small difference on the alignment



On Jun 2, 10:01 pm, Chris crehb...@gmail.com wrote:
 I see, that's a nice default.  I still had trouble getting things to look
 right on an actual device without both setting a weightSum and setting the
 layout size of the children to 0 in the direction I wanted weighting applied
 (re: my post earlier).  The layout editor in Eclipse got it right, oddly.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Android weight question

2011-06-02 Thread Vinicius Carvalho
Hi!

I'm trying to use weights on my linear layout to lay things on a fixed
width without relying on measures (px or dp).

Here's my layout:

LinearLayout
  xmlns:android=http://schemas.android.com/apk/res/android;
  android:orientation=horizontal
  android:layout_width=match_parent
  android:layout_height=match_parent
  android:background=@color/translucent_grey
TextView android:text=TextView android:id=@+id/filter_text
  android:layout_width=wrap_content
android:layout_height=wrap_content
  android:paddingLeft=15px android:layout_weight=4/
TextView
Spinner android:layout_height=wrap_content android:id=@+id/
filter_spinner android:layout_width=wrap_content
android:layout_weight=3/Spinner
EditText android:layout_height=wrap_content android:id=@+id/
editText1 android:layout_width=wrap_content
android:layout_weight=3
requestFocus/requestFocus
/EditText
ImageButton android:layout_height=wrap_content android:id=@+id/
imageButton1 android:src=@drawable/trash
android:layout_width=wrap_content
android:layout_gravity=center_vertical android:layout_weight=1/
ImageButton

/LinearLayout

So my idea is to have fixed width per component (for the spinner,
text, edit and image). But I found out that this does not work :(

My textview has a dynamic size (depending on the text added) and that
is pushing the other elements to the right.

What I was expecting is to have enough room for the text, and make it
fixed, no matter how many chars it has, the width would be fixed and
aligned.

What do I need to fix for that?

Thanks

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Permission issues

2011-05-31 Thread Vinicius Carvalho
Hi there! I'm developing an app for Honeycomb using my xoom device.

Now I got stuck, I'm using SQLite, and I need to access my db during
development, just to check if things are right.

But since this is not a rooted device, I can not access my data/data/
com.acme/databases to open my db file.

Is there any way around this?

The DDMS file explorer won't show me the files, I'm guessing that's
because I'm not rooted.

Regards

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] GLSurfaceView multi touch

2011-05-23 Thread Vinicius Carvalho
Hi there! I have a GLSurfaceView, and I'm trying to listen to multi
touch events. Basically I want to use x/y move to rotate the model
(just like the touchrotate example) but also the pinch gesture to zoom
in/out.

The problem is that it seems that the view is not sending all the
fingers pressed to the MotionEvent.

This code:

public boolean onTouchEvent(MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_POINTER_DOWN:
break;
}
}

Does not gets called at all. Only after using 6 or more
fingers ... 

I also tried to use the gesturelistener, which worked like a charm :

this.detector = new ScaleGestureDetector(context, new
ScaleListener());
public boolean onTouchEvent(MotionEvent e) {
detector.onTouchEvent(e);
}

The problem now, is that I do detect the scale, but when it hapens,
the model is being rotated on both axis at the same time. I'd like to
detect a multiple input to avoid rotating the model and let the user
only zoom, but as I said, the motionevent never returns more than one
finger pressed at the same time.

How can I solve this?

Regards

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: GLSurfaceView multi touch

2011-05-23 Thread Vinicius Carvalho
Hi, I fixed this by combining the GestureListener and
getPointerCount():

public boolean onTouchEvent(MotionEvent e) {
if(e.getPointerCount()1){
mode = ZOOM;
}
detector.onTouchEvent(e);
float x = e.getX();
float y = e.getY();
switch (e.getAction()) {

/*case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(e);
if (oldDist = 10f) {
mode = ZOOM;
Log.d(TAG, Zoom Mode);
}
break;*/

case MotionEvent.ACTION_MOVE:
/*if (mode == ZOOM) {
float newDist = spacing(e);
if(newDist = 10f){
float scale = newDist / oldDist;
Log.d(TAG,Scale is:  + scale);
}
}*/
if(mode != ZOOM){
float dx = x - mPreviousX;
float dy = y - mPreviousY;
mRenderer.mAngleX += dx * TOUCH_SCALE_FACTOR;
mRenderer.mAngleY += dy * TOUCH_SCALE_FACTOR;
}
break;

case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
Log.d(TAG, Restoring mode);
break;
case MotionEvent.ACTION_UP:
mode = NONE;
break;
}

mPreviousX = x;
mPreviousY = y;
requestRender();
return true;
}

At least it's working now :)

On May 23, 1:56 pm, Vinicius Carvalho viniciusccarva...@gmail.com
wrote:
 Hi there! I have a GLSurfaceView, and I'm trying to listen to multi
 touch events. Basically I want to use x/y move to rotate the model
 (just like the touchrotate example) but also the pinch gesture to zoom
 in/out.

 The problem is that it seems that the view is not sending all the
 fingers pressed to the MotionEvent.

 This code:

 public boolean onTouchEvent(MotionEvent e) {
 switch (e.getAction()) {
 case MotionEvent.ACTION_POINTER_DOWN:
 break;

 }
 }

 Does not gets called at all. Only after using 6 or more
 fingers ... 

 I also tried to use the gesturelistener, which worked like a charm :

 this.detector = new ScaleGestureDetector(context, new
 ScaleListener());
 public boolean onTouchEvent(MotionEvent e) {
                 detector.onTouchEvent(e);

 }

 The problem now, is that I do detect the scale, but when it hapens,
 the model is being rotated on both axis at the same time. I'd like to
 detect a multiple input to avoid rotating the model and let the user
 only zoom, but as I said, the motionevent never returns more than one
 finger pressed at the same time.

 How can I solve this?

 Regards

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Heatmap example for android

2011-05-17 Thread Vinicius Carvalho
Hi guys, just sharing a demo of a heatmap I've done:

http://blog.furiousbob.com/2011/05/12/heating-up-my-new-xoom-tablet/

An example with real data and Gmaps overlay to come next :)

BR

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] getPixels and alpha

2011-05-11 Thread Vinicius Carvalho
Hi there! I'm trying to manipulate a bitmap pixels using android
graphics api.

The idea is to create a heatmap using a black/white/alpha gradient.
Latter I'll change the color of each pixel depending on it's alpha
(red to 255 alpha, green to 0 alpha)

The problem I'm having is that all the pixels read are showing as
black opaque. Here's my code:

private void init() {
backbuffer = Bitmap.createBitmap(getWidth(), getHeight(),
Bitmap.Config.ARGB_);
myCanvas = new Canvas(backbuffer);
Paint p = new Paint();
p.setStyle(Paint.Style.FILL);
p.setColor(Color.WHITE);
myCanvas.drawRect(0, 0, getWidth(), getHeight(), p);

}

@Override
protected void onDraw(Canvas canvas) {
if (backbuffer == null) {
init();
}
canvas.drawBitmap(backbuffer, 0, 0, new
Paint(Paint.ANTI_ALIAS_FLAG));
}

public void addPoint(float x, float y) {
RadialGradient g = new RadialGradient(x, y, 20,
Color.argb(25, 0, 0, 0), Color.argb(0, 255, 
255, 255),
TileMode.CLAMP);
Paint gp = new Paint();
gp.setShader(g);
myCanvas.drawCircle(x, y, 20, gp);
addColor(x-20, y-20, 20*2);
invalidate();
}

private void addColor(float x, float y, float d) {
if (x + d  myCanvas.getWidth()) {
x = myCanvas.getWidth() - d;
}
if (x  0) {
x = 0;
}
if (y  0) {
y = 0;
}
if (y + d  myCanvas.getHeight()) {
y = myCanvas.getHeight() - d;
}
int r = 0, g = 0, b = 0, tmp = 0;
int[] pixels = new int[(int) (d * d)];
backbuffer.getPixels(pixels, 0, (int) d, (int) x, (int) y, 
(int) d,
(int) d);
for (int i=0;ipixels.length;i++) {
int alpha = pixels[i]  24;
if (alpha = 255  alpha = 235) {
tmp = 255 - alpha;
r = 255 - tmp;
g = tmp * 12;
} else if (alpha = 234  alpha = 200) {
tmp = 234 - alpha;
r = 255 - (tmp * 8);
g = 255;
} else if (alpha = 199  alpha = 150) {
tmp = 199 - alpha;
g = 255;
b = tmp * 5;
} else if (alpha = 149  alpha = 100) {
tmp = 149 - alpha;
g = 255 - (tmp * 5);
b = 255;
} else
b = 255;
pixels[i] = Color.rgb(r, g, b);
}

}

Any ideas why transparent pixels, and different alpha values not being
shown?

Regards

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en