If you think the Android project slider 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 de.devisnik.sliding;
/*fromwww.java2s.com*/publicclass Point {
publicstatic Point diff(Point left, Point right) {
returnnew Point(left.x - right.x, left.y - right.y);
}
publicstatic Point divide(int width, int height, Point size) {
returnnew Point(width / size.x, height / size.y);
}
publicstatic Point divide(Point left, Point right) {
returnnew Point(left.x / right.x, left.y / right.y);
}
publicstatic Point divide(Point left, int number) {
returnnew Point(left.x / number, left.y / number);
}
publicstatic Point sum(Point point, int x, int y) {
returnnew Point(point.x + x, point.y + y);
}
publicstatic Point times(Point point, float factor) {
returnnew Point(Math.round(factor * point.x), Math.round(factor * point.y));
}
publicstatic Point times(Point point, int factor) {
returnnew Point(factor * point.x, factor * point.y);
}
publicstatic Point times(Point left, Point right) {
returnnew Point(left.x * right.x, left.y * right.y);
}
publicint x;
publicint y;
public Point() {
this(0, 0);
}
public Point(int x, int y) {
this.x = x;
this.y = y;
}
public Point add(Point point) {
x += point.x;
y += point.y;
returnthis;
}
public Point set(Point point) {
this.x = point.x;
this.y = point.y;
returnthis;
}
publicint min() {
return Math.min(x, y);
}
publicint max() {
return Math.max(x, y);
}
publicfloat ratio() {
return ((float) x) / y;
}
public Point flip() {
int mem = x;
x = y;
y = mem;
returnthis;
}
@Override
publicboolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Point other = (Point) obj;
if (x != other.x)
return false;
if (y != other.y)
return false;
return true;
}
@Override
publicint hashCode() {
finalint prime = 31;
int result = 1;
result = prime * result + x;
result = prime * result + y;
return result;
}
@Override
public String toString() {
return"(" + x + "," + y + ")";
}
public Point divideBy(Point point) {
x /= point.x;
y /= point.y;
returnthis;
}
public Point multiplyBy(Point point) {
x *= point.x;
y *= point.y;
returnthis;
}
public Point minus(Point point) {
x -= point.x;
y -= point.y;
returnthis;
}
public Point divideBy(int number) {
x /= number;
y /= number;
returnthis;
}
public Point copy() {
returnnew Point(x, y);
}
}