Rewrite: Marker bitmap / drawable

133 views
Skip to first unread message

emux

unread,
Apr 29, 2013, 3:43:11 AM4/29/13
to mapsfo...@googlegroups.com
Hi Thilo,

At main branch Marker class uses Drawable for storing its icon. Now at rewrite branch is uses Bitmap for its icon. Why that change?

I see that at new Marker constructor there are dx, dy for offsets. But the old implementation, in my opinion, was more flexible.
We were able to call getDrawable and get with the icon and its bounds as there are stored in Drawable class.
Now with getBitmap we only get a simple bitmap with no knowledge of how it is supposed to draw itself relative to marker lat,long.

Regards.

Thilo Mühlberg

unread,
May 4, 2013, 3:26:34 AM5/4/13
to mapsfo...@googlegroups.com
There are several reasons why a drawable is no longer used in the
rewrite branch. First, Drawable is a very specific Android class which
makes it impossible to write Layers that can be integrated in the
AWT/Swing based map application as well.

Second, in order for a drawable to appear correctly, its bounds had to
be set correctly. We had many bug reports and discussions where people
failed to do that correctly. During the actual drawing the bounds of the
Drawable had to be modified and restored afterwards. There is no way to
do that in a thread safe way as everybody with a reference to the
drawable can modify the bounds at the same time. Besides that, getting
and setting the bounds twice at each redraw iteration simply sucks and
degrades the performance. But mainly the fact that a drawable is neither
immutable nor thread safe disqualifies it for this purpose. The Drawable
was only used because we tried to mimic Google's API.

I think the current API is easier to understand and still flexible. A
bitmap should be a well known concept for any (Android) developer.
Passing two integer offsets to modify the alignment is also straight
forward and allows for arbitrary positioning relative to the LatLon.

Greetings,
Thilo
> --
> You received this message because you are subscribed to the Google
> Groups "mapsforge-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mapsforge-de...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>


signature.asc
Message has been deleted

Thilo Mühlberg

unread,
May 4, 2013, 5:05:20 AM5/4/13
to mapsfo...@googlegroups.com
The LatLon is the center position of the bitmap. If desired the bitmap
can be shifted horizontally and vertically by an arbitrary amount of
pixels. For instance, if you have a needle pin and want the bottom
center to point at the LatLon instead of the center of the needle image,
you can simply use getHeight() / -2 as vertical offset.

Greetings,
Thilo

On 04/05/13 10:48, emux wrote:
> I see, can we have then getDx & getDy methods which with the existing
> getBitmap method would give us from a Marker its icon and is relative
> position?
> > an email to mapsforge-de...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
signature.asc

emux

unread,
May 4, 2013, 5:05:32 AM5/4/13
to mapsfo...@googlegroups.com
Thanks for your explanation.

Can we have then get / set methods for dx and dy (together with the existing getBitmap, setBitmap)?

So it could be possible to get from a marker its bitmap with its relative position, but also possible to change to a marker its bitmap and its relative position.

Regards.



On Saturday, May 4, 2013 10:26:34 AM UTC+3, Thilo wrote:

Thilo Mühlberg

unread,
May 5, 2013, 8:16:06 AM5/5/13
to mapsfo...@googlegroups.com
Good idea, I just changed that in commit 30cf96be5a.

Greetings,
Thilo
> > an email to mapsforge-de...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
signature.asc
Reply all
Reply to author
Forward
0 new messages