diff --git a/bin/Mouse.class b/bin/Mouse.class index 0832cf5..2070652 100644 Binary files a/bin/Mouse.class and b/bin/Mouse.class differ diff --git a/bin/MousePath.class b/bin/MousePath.class index f8d4651..0db453a 100644 Binary files a/bin/MousePath.class and b/bin/MousePath.class differ diff --git a/bin/MousePoint.class b/bin/MousePoint.class index e39c03c..f1186aa 100644 Binary files a/bin/MousePoint.class and b/bin/MousePoint.class differ diff --git a/src/MousePath.java b/src/MousePath.java index f79663b..1dc52a7 100644 --- a/src/MousePath.java +++ b/src/MousePath.java @@ -8,41 +8,69 @@ public class MousePath { private ArrayList 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 _path) + public MousePath(ArrayList mousePoints) { - path = new ArrayList(_path.size()); - for (MousePoint point : _path) { - MousePoint pointCopy = new MousePoint(point.getX(), point.getY(), point.getTime()); + path = new ArrayList(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 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() { diff --git a/src/MousePoint.java b/src/MousePoint.java index e9e1918..95abcc0 100644 --- a/src/MousePoint.java +++ b/src/MousePoint.java @@ -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); - } } \ No newline at end of file