Added setters to Java API

This commit is contained in:
Leonid Beynenson 2011-07-15 11:09:23 +00:00
parent c1dab7bf6e
commit 8625b5689d
8 changed files with 163 additions and 97 deletions

View File

@ -16,12 +16,19 @@ public class Point {
public Point(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
x = vals.length>0 ? vals[0] : 0;
y = vals.length>1 ? vals[1] : 0;
} else {
x = 0;
y = 0;
}
}
public Point clone() {
return new Point(x, y);
}

View File

@ -23,10 +23,17 @@ public class Point3 {
public Point3(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
x = vals.length>0 ? vals[0] : 0;
y = vals.length>1 ? vals[1] : 0;
z = vals.length>2 ? vals[2] : 0;
} else {
x = 0;
y = 0;
z = 0;
}
}

View File

@ -13,6 +13,20 @@ public class Range {
public Range() {
this(0, 0);
}
public Range(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
start = vals.length>0 ? (int)vals[0] : 0;
end = vals.length>1 ? (int)vals[1] : 0;
} else {
start = 0;
end = 0;
}
}
public int size() {
return end-start;

View File

@ -29,11 +29,19 @@ public class Rect {
public Rect(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
x = vals.length>0 ? (int)vals[0] : 0;
y = vals.length>1 ? (int)vals[1] : 0;
width = vals.length>2 ? (int)vals[2] : 0;
height = vals.length>3 ? (int)vals[3] : 0;
} else {
x = 0;
y = 0;
width = 0;
height = 0;
}
}

View File

@ -19,12 +19,21 @@ public class RotatedRect {
public RotatedRect(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
center.x = vals.length>0 ? (int)vals[0] : 0;
center.x = vals.length>1 ? (int)vals[1] : 0;
size.width = vals.length>2 ? (int)vals[2] : 0;
size.height = vals.length>3 ? (int)vals[3] : 0;
angle = vals.length>4 ? (int)vals[4] : 0;
} else {
center.x = 0;
center.x = 0;
size.width = 0;
size.height = 0;
angle = 0;
}
}

View File

@ -25,11 +25,19 @@ public class Scalar {
}
public Scalar(double[] vals) {
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
v0 = vals.length>0 ? (int)vals[0] : 0;
v1 = vals.length>1 ? (int)vals[1] : 0;
v2 = vals.length>2 ? (int)vals[2] : 0;
v3 = vals.length>3 ? (int)vals[3] : 0;
} else {
v0 = 0;
v1 = 0;
v2 = 0;
v3 = 0;
}
}

View File

@ -21,9 +21,15 @@ public class Size {
public Size(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
width = vals.length>0 ? vals[0] : 0;
height = vals.length>1 ? vals[1] : 0;
} else {
width = 0;
height = 0;
}
}

View File

@ -19,10 +19,17 @@ public class TermCriteria {
public TermCriteria(double[] vals) {
this();
set(vals);
}
public void set(double[] vals) {
if(vals!=null) {
type = vals.length>0 ? (int)vals[0] : 0;
maxCount = vals.length>1 ? (int)vals[1] : 0;
epsilon = vals.length>2 ? (double)vals[2] : 0;
} else {
type = 0;
maxCount = 0;
epsilon = 0;
}
}