<commit_before><commit_msg>add GroundOverlay2<commit_after>package org.osmdroid.views.overlay;

import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;

import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
import org.osmdroid.views.Projection;

/**
 * A ground overlay is an image that is fixed to 2 corners on a map.
 * @author pasniak inspired by zkhan's code in Avare
 *
 */
@SuppressWarnings("WeakerAccess")
public class GroundOverlay2 extends Overlay {

    private float   mLonL,
                    mLatU,
                    mLonR,
                    mLatD;
    protected Bitmap mImage;
	protected float mBearing;
	protected float mTransparency;
    private Matrix mStretchToFitTransformationMatrix;

	public GroundOverlay2() {
		super();
		mBearing = 0.0f;
		mTransparency = 0.0f;
        mStretchToFitTransformationMatrix = new Matrix();
	}

	public void setImage(Bitmap image){
		mImage = image;
	}

	public Bitmap getImage(){
		return mImage;
	}

	public void setPosition(GeoPoint UL, GeoPoint RD)
    {
        mLatU = (float)UL.getLatitude();
        mLonL = (float)UL.getLongitude();
        mLatD = (float)RD.getLatitude();
        mLonR = (float)RD.getLongitude();
	}

	public float getBearing(){
		return mBearing;
	}
	
	public void setBearing(float bearing){
		mBearing = bearing;
	}
	
	public void setTransparency(float transparency){
		mTransparency = transparency;
	}
	
	public float getTransparency(){
		return mTransparency;
	}
	

    @Override
    public void draw(Canvas canvas, MapView mapView, boolean shadow)
    {
		if(null == mImage) {
			return;
		}

        final Projection pj = mapView.getProjection();

        long x0 = pj.getLongPixelXFromLongitude(mLonL),
             y0 = pj.getLongPixelYFromLatitude(mLatU),
             x1 = pj.getLongPixelXFromLongitude(mLonR),
             y1 = pj.getLongPixelYFromLatitude(mLatD);

		float scaleX = (float)(x1 - x0) / mImage.getWidth(),
		      scaleY = (float)(y1 - y0) / mImage.getHeight();
        mStretchToFitTransformationMatrix.setScale(scaleX, scaleY);
        mStretchToFitTransformationMatrix.postTranslate(x0, y0);

        Paint paint = new Paint();
        paint.setAlpha(255-(int)(mTransparency * 255));
		canvas.drawBitmap(mImage, mStretchToFitTransformationMatrix, paint);
	}
}

{'fraction_non_alphanumeric': 0.09902666102412187, 'fraction_numerical': 0.010156580617858655, 'mean_word_length': 3.236559139784946, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2018308', 'n_tokens_mistral': 824, 'n_tokens_neox': 756, 'n_words': 168}