< prev index next >
core/JemmyCore/src/org/jemmy/Vector.java
Print this page
*** 32,133 ****
public class Vector {
private double x;
private double y;
- /**
- *
- * @param x
- * @param y
- */
public Vector(double x, double y) {
this.x = x;
this.y = y;
}
- /**
- *
- * @param from
- * @param to
- */
public Vector(Point from, Point to) {
x = to.x - from.x;
y = to.y - from.y;
}
- /**
- *
- * @return
- */
public double getX() {
return x;
}
- /**
- *
- * @return
- */
public double getY() {
return y;
}
- /**
- *
- * @return
- */
public double lenght() {
return Math.sqrt(x*x + y*y);
}
- /**
- *
- * @param newLenght
- * @return self
- */
public Vector setLenght(double newLenght) {
double lenght = lenght();
x = x * newLenght / lenght;
y = y * newLenght / lenght;
return this;
}
- /**
- * @param multiplier
- * @return self
- */
public Vector multiply(double multiplier) {
x*=multiplier;
y*=multiplier;
return this;
}
/**
! *
! * @return a clone
*/
@Override
public Vector clone() {
return new Vector(x, y);
}
/**
! *
! * @return
*/
@Override
public String toString() {
return "(" + x + "," + y + ")";
}
- /**
- * Adds another vector <code>(x1 + x2, y1 + y2)</code>
- * @param v
- * @return self
- */
public Vector add(Vector v) {
x+=v.x;
y+=v.y;
return this;
}
-
}
--- 32,94 ----
public class Vector {
private double x;
private double y;
public Vector(double x, double y) {
this.x = x;
this.y = y;
}
public Vector(Point from, Point to) {
x = to.x - from.x;
y = to.y - from.y;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double lenght() {
return Math.sqrt(x*x + y*y);
}
public Vector setLenght(double newLenght) {
double lenght = lenght();
x = x * newLenght / lenght;
y = y * newLenght / lenght;
return this;
}
public Vector multiply(double multiplier) {
x*=multiplier;
y*=multiplier;
return this;
}
/**
! * {@inheritDoc}
*/
@Override
public Vector clone() {
return new Vector(x, y);
}
/**
! * {@inheritDoc}
*/
@Override
public String toString() {
return "(" + x + "," + y + ")";
}
public Vector add(Vector v) {
x+=v.x;
y+=v.y;
return this;
}
}
< prev index next >