If you think the Android project NotATop listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.gg.util;
//fromwww.java2s.comimport java.util.ArrayList;
import android.view.MotionEvent;
publicclass Track {
ArrayList<TrackPoint> list;
ArrayList<TrackPoint> drawList;
private Boolean touchFlag;
privatelong startTime;
public Track() {
touchFlag = false;
list = new ArrayList<TrackPoint>();
drawList = new ArrayList<TrackPoint>();
}
public ArrayList<TrackPoint> getDrawList() {
return drawList;
}
public ArrayList<TrackPoint> getList(){
return list;
}
publicvoid onTouchDown(MotionEvent e) {
list.clear();
touchFlag = true;
startTime = System.currentTimeMillis();
TrackPoint point = new TrackPoint(e.getX() , e.getY() , System.currentTimeMillis());
list.add(point);
}
publicvoid onTouchMove(MotionEvent e) {
if((System.currentTimeMillis() - startTime) > 300){
touchFlag = false;
// list.clear();
return;
}else{
TrackPoint point = new TrackPoint(e.getX() , e.getY() , System.currentTimeMillis());
list.add(point);
setPoint(list, drawList);
}
}
publicvoid onTouchUp(MotionEvent e) {
TrackPoint point = new TrackPoint(e.getX() , e.getY() , System.currentTimeMillis());
list.add(point);
touchFlag = false;
}
publicvoid setPoint(ArrayList<TrackPoint> list, ArrayList<TrackPoint> drawList) {
drawList.clear();
long currentTime = System.currentTimeMillis();
//????????????????
for(int i = 0; i < list.size(); i ++){
if((currentTime - list.get(i).birth) > 300){
for(int j = list.size() -1 ; j > i ; j--){
list.remove(j);
}
i = list.size();
}
}
drawList.add(list.get(0));
for(int i = 0; i < list.size() - 2; i ++){
drawList.add(list.get(i).leftPoint(list.get(i), list.get(i + 1), list.get(i + 1).birth, list.get(list.size() - 1).birth));
drawList.add(list.get(i).rightPoint(list.get(i), list.get(i + 1), list.get(i + 1).birth, list.get(list.size() - 1).birth));
}
drawList.add(list.get(list.size() - 1));
}
}