/******************************************************************************* * Copyright (c) 2011 Michel DAVID mimah35-at-gmail.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. ******************************************************************************/ package fr.gotorennes.view; import android.content.Context; import android.graphics.Bitmap; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import fr.gotorennes.R; public class MapDrawable extends LayerDrawable { public MapDrawable( Context context, int res ) { super(new Drawable[]{context.getResources().getDrawable(R.drawable.map_rond), context.getResources().getDrawable(res)} ); Drawable pin = getDrawable(0); Drawable icon = getDrawable(1); setBounds(0, -62, 50, 0); pin.setBounds(0, -62, 50, 0); icon.setBounds(5, -57, 45, -17); } public MapDrawable( Context context, Bitmap bitmap, boolean carre ) { super(new Drawable[]{context.getResources().getDrawable(carre ? R.drawable.map_carre : R.drawable.map_rond), new BitmapDrawable(bitmap)} ); Drawable pin = getDrawable(0); Drawable icon = getDrawable(1); setBounds(0, -62, 50, 0); pin.setBounds(0, -62, 50, 0); if(carre) { icon.setBounds(9, -57, 45, -21); } else { icon.setBounds(5, -57, 45, -17); } } }