mirror of
https://github.com/davpapp/PowerMiner
synced 2024-12-21 23:48:49 -05:00
Changing mousepath to delta_x delta_y based.
This commit is contained in:
parent
a3fb536210
commit
6635ed33c1
BIN
bin/Mouse.class
BIN
bin/Mouse.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -8,41 +8,69 @@ public class MousePath {
|
||||
|
||||
private ArrayList<MousePoint> path;
|
||||
private int numPoints;
|
||||
private MousePoint startingPoint;
|
||||
private MousePoint endingPoint;
|
||||
private int deltaX;
|
||||
private int deltaY;
|
||||
private int timespan;
|
||||
|
||||
private int boundUp;
|
||||
private int boundDown;
|
||||
private int boundLeft;
|
||||
private int boundRight;
|
||||
|
||||
public MousePath(ArrayList<MousePoint> _path)
|
||||
public MousePath(ArrayList<MousePoint> mousePoints)
|
||||
{
|
||||
path = new ArrayList<MousePoint>(_path.size());
|
||||
for (MousePoint point : _path) {
|
||||
MousePoint pointCopy = new MousePoint(point.getX(), point.getY(), point.getTime());
|
||||
path = new ArrayList<MousePoint>(mousePoints.size());
|
||||
int maxX = Integer.MIN_VALUE;
|
||||
int maxY = Integer.MIN_VALUE;
|
||||
int minX = Integer.MAX_VALUE;
|
||||
int minY = Integer.MAX_VALUE;
|
||||
for (MousePoint point : mousePoints) {
|
||||
int x = point.getX();
|
||||
int y = point.getY();
|
||||
maxX = Math.max(maxX, x);
|
||||
maxY = Math.max(maxY, y);
|
||||
minX = Math.min(minX, x);
|
||||
minY = Math.min(minY, y);
|
||||
MousePoint pointCopy = new MousePoint(x, y, point.getTime());
|
||||
path.add(pointCopy);
|
||||
}
|
||||
numPoints = path.size();
|
||||
startingPoint = path.get(0);
|
||||
endingPoint = path.get(numPoints - 1);
|
||||
timespan = endingPoint.getTime() - startingPoint.getTime();
|
||||
MousePoint startingPoint = path.get(0);
|
||||
boundUp = maxY - startingPoint.getY();
|
||||
boundDown = startingPoint.getY() - minY;
|
||||
boundLeft = startingPoint.getX() - minX;
|
||||
boundRight = maxX - startingPoint.getX();
|
||||
|
||||
timespan = path.get(numPoints - 1).getTime() - startingPoint.getTime();
|
||||
}
|
||||
|
||||
public ArrayList<MousePoint> getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public int getNumPoints() {
|
||||
return numPoints;
|
||||
}
|
||||
|
||||
public int getTimespan() {
|
||||
return timespan;
|
||||
}
|
||||
|
||||
public MousePoint getStartingPoint() {
|
||||
return startingPoint;
|
||||
public int getDeltaX() {
|
||||
return deltaX;
|
||||
}
|
||||
public int getDeltaY() {
|
||||
return deltaY;
|
||||
}
|
||||
|
||||
public MousePoint getEndingPoint() {
|
||||
return endingPoint;
|
||||
public int getBoundUp() {
|
||||
return boundUp;
|
||||
}
|
||||
public int getBoundDown() {
|
||||
return boundDown;
|
||||
}
|
||||
public int getBoundLeft() {
|
||||
return boundLeft;
|
||||
}
|
||||
public int getBoundRight() {
|
||||
return boundRight;
|
||||
}
|
||||
|
||||
public void display() {
|
||||
|
@ -6,25 +6,19 @@ public class MousePoint {
|
||||
private int y;
|
||||
private int time;
|
||||
|
||||
public MousePoint(int _x, int _y, int _time)
|
||||
{
|
||||
x = _x;
|
||||
y = _y;
|
||||
time = _time;
|
||||
public MousePoint(int x, int y, int time) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public int getX()
|
||||
{
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getY()
|
||||
{
|
||||
public int getY(){
|
||||
return y;
|
||||
}
|
||||
|
||||
public int getTime()
|
||||
{
|
||||
}
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
@ -35,12 +29,16 @@ public class MousePoint {
|
||||
public double distance(MousePoint p2) {
|
||||
return Math.hypot(this.x - p2.getX(), this.y - p2.getY());
|
||||
}
|
||||
|
||||
public double distance(Point p2) {
|
||||
return Math.hypot(this.x - p2.getX(), this.y - p2.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
// TODO: define window size
|
||||
public boolean isValid() {
|
||||
return (x >= 0 && x < 1920 && y >= 0 && y < 1080 && time >= 0);
|
||||
}
|
||||
/*@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
return false;
|
||||
@ -53,9 +51,6 @@ public class MousePoint {
|
||||
|
||||
// Compare the data members and return accordingly
|
||||
return (this.x == p.x && this.y == p.y && this.time == p.time);
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean isValid() {
|
||||
return (x >= 0 && x < 1920 && y >= 0 && y < 1080 && time >= 0);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user