<commit_before>package com.futurice.festapp;

import java.util.Timer;
import com.futurice.festapp.dao.GigDAO;
import com.futurice.festapp.domain.to.StageType;
import com.futurice.festapp.ui.map.MapAnimation;
import com.futurice.festapp.ui.map.MapAnimationCallback;
import com.futurice.festapp.ui.map.MapImageView;
import com.futurice.festapp.ui.map.SizeCallback;
import com.futurice.festapp.util.FestAppConstants;
import com.futurice.festapp.util.UIUtil;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageButton;
import android.widget.Toast;
import com.futurice.festapp.R;

/**
 * View for festival Map.
 * 
 * @author <NAME> / Futurice
 */
public class MapActivity extends Activity {
	
	private MapImageView mapImageView;
	private ImageButton zoomInButton;
	private ImageButton zoomOutButton;
	private Matrix matrix;
	private RectF sourceRect;
	private RectF destinationRect;
	private Bitmap bitmap;
	private Timer timer;
	private MapAnimation animation;
	private Toast mapToast;
	private Handler handle = new Handler();
	
	private int moveHistorySize;
	private float lastTwoXMoves[] = new float[2];
	private float lastTwoYMoves[] = new float[2];
	private long downTimer;
	
	private BitmapFactory.Options opts = new BitmapFactory.Options();

	/**************************/
	/* Configure festival map */
	/**************************/
	
	// Map image
	private int map_drawable = R.drawable.map_placeholder;
	
	// Image size
	private int mapSizeX = 2500;
	private int mapSizeY = 2000;
	
	// Clickable areas
	private static final Rect CLICKABLEAREA_STAGE = new Rect(100, 100, 200, 200);
	private static final Rect CLICKABLEAREA_TENT = new Rect(300, 300, 400, 400);
	private static final Rect CLICKABLEAREA_LOCATION = new Rect(500, 500, 600, 600);
	private static final Rect CLICKABLEAREA_AREA = new Rect(700, 700, 800, 800);
	private static final Rect CLICKABLEAREA_PLACE = new Rect(900, 900, 1000, 1000);
	
	private static final float INITIAL_SCALE = (float) 1;
	private static final float MAGNIFY_SCALE = (float) 1.9;

	private float current_scale = INITIAL_SCALE;
	private int current_centerX = mapSizeX / 2;
	private int current_centerY = mapSizeY / 2;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.map);
		opts.inScaled = false;
		mapImageView = (MapImageView) findViewById(R.id.image);
		zoomInButton = (ImageButton) findViewById(R.id.zoomIn);
		zoomOutButton = (ImageButton) findViewById(R.id.zoomOut);
		
		sourceRect = new RectF();
		destinationRect = new RectF();
		matrix = new Matrix();

		if (savedInstanceState != null) {<commit_msg>Added sampling for the map image. Sampling size is set with the SAMPLING_SIZE constant in MapActivity.java. This value has to be set on per image basis and cannot really be dynamically calculated.<commit_after>package com.futurice.festapp;

import java.util.Timer;
import com.futurice.festapp.dao.GigDAO;
import com.futurice.festapp.domain.to.StageType;
import com.futurice.festapp.ui.map.MapAnimation;
import com.futurice.festapp.ui.map.MapAnimationCallback;
import com.futurice.festapp.ui.map.MapImageView;
import com.futurice.festapp.ui.map.SizeCallback;
import com.futurice.festapp.util.FestAppConstants;
import com.futurice.festapp.util.UIUtil;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.graphics.Rect;
import android.graphics.RectF;
import android.os.Bundle;
import android.os.Handler;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.ImageButton;
import android.widget.Toast;
import com.futurice.festapp.R;

/**
 * View for festival Map.
 * 
 * @author <NAME> / Futurice
 */
public class MapActivity extends Activity {
	
	private MapImageView mapImageView;
	private ImageButton zoomInButton;
	private ImageButton zoomOutButton;
	private Matrix matrix;
	private RectF sourceRect;
	private RectF destinationRect;
	private Bitmap bitmap;
	private Timer timer;
	private MapAnimation animation;
	private Toast mapToast;
	private Handler handle = new Handler();
	
	private int moveHistorySize;
	private float lastTwoXMoves[] = new float[2];
	private float lastTwoYMoves[] = new float[2];
	private long downTimer;
	
	private BitmapFactory.Options opts = new BitmapFactory.Options();

	/**************************/
	/* Configure festival map */
	/**************************/
	
	// Map image
	private int map_drawable = R.drawable.map_placeholder;
	
	// Image size
	private int mapSizeX = 2500;
	private int mapSizeY = 2000;
	
	// Clickable areas
	private static final Rect CLICKABLEAREA_STAGE = new Rect(100, 100, 200, 200);
	private static final Rect CLICKABLEAREA_TENT = new Rect(300, 300, 400, 400);
	private static final Rect CLICKABLEAREA_LOCATION = new Rect(500, 500, 600, 600);
	private static final Rect CLICKABLEAREA_AREA = new Rect(700, 700, 800, 800);
	private static final Rect CLICKABLEAREA_PLACE = new Rect(900, 900, 1000, 1000);
	
	private static final float INITIAL_SCALE = (float) 1;
	private static final float MAGNIFY_SCALE = (float) 1.9;

	private float current_scale = INITIAL_SCALE;
	private int current_centerX = mapSizeX / 2;
	private int current_centerY = mapSizeY / 2;

	/**
	 * This constant sets the sampling size for map image.
	 * The value of this constant has to be set on per image 
	 * basic.
	 * For example, the placeholder map at the time of
	 * development could take sampling size of 2 at max, after
	 * that some of the lines disappeared.
	 */
	private static final int SAMPLING_SIZE = 2;
	
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.map);
		opts.inScaled = false;
		opts.inSampleSize = SAMPLING_SIZE;
		mapImageView = (MapImageView) findViewById(R.id.image);
		zoomInButton = (ImageButton) findViewById(R.id.zoomIn);
		zoomOutButton = (ImageButton) findViewById(R.id.zoomOut);
		
		sourceRect = new RectF();
		destinationRect = new RectF();
		matrix = new Matrix();

		if (savedInstanceState != null) {
{'fraction_non_alphanumeric': 0.10501089324618737, 'fraction_numerical': 0.022657952069716776, 'mean_word_length': 5.019230769230769, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3857968', 'n_tokens_mistral': 2344, 'n_tokens_neox': 2052, 'n_words': 607}