<commit_before>package panaimin.pdfmarker;

/***
 Copyright (C) <2015>  <<NAME>>

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 of the
 License, or (at your option) any later version.

 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;
import android.widget.Scroller;

public class PageTurner extends FrameLayout {

	static final String TAG = "PDFMarker.Turner";

	private static final int	TURNING_NONE = 0;
	private static final int	TURNING_NEXT_MANUAL = 1;
	private static final int	TURNING_NEXT_AUTO = 2;
	private static final int	TURNING_PREV_MANUAL = -1;
	private static final int	TURNING_PREV_AUTO = -2;
	private static final int	EDGE_WIDTH = 50;
	private static final int	LEFT_SHADOW_DARK = 0xff404040;
	private static final int[]	LEFT_SHADOW_COLORS = new int[] { 0, LEFT_SHADOW_DARK };
	private static final int[]	RIGHT_SHADOW_COLORS = new int[] { 0xff000000, 0};
	private static final int[]	BACK1_COLORS = new int[] { 0xffd0d0d0, 0xff404040 };
	private static final float	SCROLL_TIME = 2000f;

	// I try to simulate pulling the page edge
	// but unfortunately solving this equation is an advanced topic
	// angle = ( WIDTH - orient ) / RADIUS
	// leftMost = orient + sin(angle)
	// so I use a map from leftMost to orient to simulate
	private static int[]		_leftMost2Orient = null;
	private static float[]		_leftMost2Angle = null;
	// the leftMost point is from -_width to +_width, so use 2 array (try not to use map)
	private static int[]		_leftMost2Orient_minus = null;
	private static float[]		_leftMost2Angle_minus = null;

	private PageActivity		_activity;
	SVGView						_current;
	SVGView						_previous;
	SVGView						_next;
	private int					_pageId;
	private int					_turning = TURNING_NONE;
	private GradientDrawable 	_leftShadow;
	private GradientDrawable	_rightShadow;
	private GradientDrawable	_leftBack;
	private Scroller			_scroller = null;
	private int					_width;
	private int					_height;
	private float				_radius;
	private float				_leftMost;
	private float				_rightMost;
	private int					_orient;

	public PageTurner(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public PageTurner(Context context) {
		super(context);
	}

	void initView() {
		_activity = (PageActivity)getContext();
		_scroller = new Scroller(_activity, new AccelerateInterpolator());
		int fileId = _activity._fileId;
		_pageId = PDFMaster.instance().currentPage();
		// current
		_current = new SVGView(_activity);
		addView(_current);
		_current.setPage(fileId, _pageId);
		// previous
		_previous = new SVGView(_activity);
		_previous.setVisibility(View.INVISIBLE);
		addView(_previous);
		if (_pageId > 0)
			_previous.setPage(fileId, _pageId - 1);
		// next
		_next = new SVGView(_activity);
		_next.setVisibility(View.INVISIBLE);<commit_msg>use linear interpolator<commit_after>package panaimin.pdfmarker;

/***
 Copyright (C) <2015>  <<NAME>>

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU Affero General Public License as
 published by the Free Software Foundation, either version 3 of the
 License, or (at your option) any later version.

 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 Affero General Public License for more details.

 You should have received a copy of the GNU Affero General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.graphics.Region;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.Scroller;

public class PageTurner extends FrameLayout {

	static final String TAG = "PDFMarker.Turner";

	private static final int	TURNING_NONE = 0;
	private static final int	TURNING_NEXT_MANUAL = 1;
	private static final int	TURNING_NEXT_AUTO = 2;
	private static final int	TURNING_PREV_MANUAL = -1;
	private static final int	TURNING_PREV_AUTO = -2;
	private static final int	EDGE_WIDTH = 50;
	private static final int	LEFT_SHADOW_DARK = 0xff404040;
	private static final int[]	LEFT_SHADOW_COLORS = new int[] { 0, LEFT_SHADOW_DARK };
	private static final int[]	RIGHT_SHADOW_COLORS = new int[] { 0xff000000, 0};
	private static final int[]	BACK1_COLORS = new int[] { 0xffd0d0d0, 0xff404040 };
	private static final float	SCROLL_TIME = 2000f;

	// I try to simulate pulling the page edge
	// but unfortunately solving this equation is an advanced topic
	// angle = ( WIDTH - orient ) / RADIUS
	// leftMost = orient + sin(angle)
	// so I use a map from leftMost to orient to simulate
	private static int[]		_leftMost2Orient = null;
	private static float[]		_leftMost2Angle = null;
	// the leftMost point is from -_width to +_width, so use 2 array (try not to use map)
	private static int[]		_leftMost2Orient_minus = null;
	private static float[]		_leftMost2Angle_minus = null;

	private PageActivity		_activity;
	SVGView						_current;
	SVGView						_previous;
	SVGView						_next;
	private int					_pageId;
	private int					_turning = TURNING_NONE;
	private GradientDrawable 	_leftShadow;
	private GradientDrawable	_rightShadow;
	private GradientDrawable	_leftBack;
	private Scroller			_scroller = null;
	private int					_width;
	private int					_height;
	private float				_radius;
	private float				_leftMost;
	private float				_rightMost;
	private int					_orient;

	public PageTurner(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public PageTurner(Context context) {
		super(context);
	}

	void initView() {
		_activity = (PageActivity)getContext();
		_scroller = new Scroller(_activity, new LinearInterpolator());
		int fileId = _activity._fileId;
		_pageId = PDFMaster.instance().currentPage();
		// current
		_current = new SVGView(_activity);
		addView(_current);
		_current.setPage(fileId, _pageId);
		// previous
		_previous = new SVGView(_activity);
		_previous.setVisibility(View.INVISIBLE);
		addView(_previous);
		if (_pageId > 0)
			_previous.setPage(fileId, _pageId - 1);
		// next
		_next = new SVGView(_activity);
		_next.setVisibility(View.INVISIBLE);
{'fraction_non_alphanumeric': 0.0774018944519621, 'fraction_numerical': 0.013802435723951286, 'mean_word_length': 4.406730065837601, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3133676', 'n_tokens_mistral': 2482, 'n_tokens_neox': 2277, 'n_words': 775}