~paparazzi-uav/paparazzi/v5.0-manual

« back to all changes in this revision

Viewing changes to sw/ext/opencv_bebop/opencv/modules/core/misc/java/src/java/core+Size.java

  • Committer: Paparazzi buildbot
  • Date: 2016-05-18 15:00:29 UTC
  • Revision ID: felix.ruess+docbot@gmail.com-20160518150029-e8lgzi5kvb4p7un9
Manual import commit 4b8bbb730080dac23cf816b98908dacfabe2a8ec from v5.0 branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.opencv.core;
 
2
 
 
3
//javadoc:Size_
 
4
public class Size {
 
5
 
 
6
    public double width, height;
 
7
 
 
8
    public Size(double width, double height) {
 
9
        this.width = width;
 
10
        this.height = height;
 
11
    }
 
12
 
 
13
    public Size() {
 
14
        this(0, 0);
 
15
    }
 
16
 
 
17
    public Size(Point p) {
 
18
        width = p.x;
 
19
        height = p.y;
 
20
    }
 
21
 
 
22
    public Size(double[] vals) {
 
23
        set(vals);
 
24
    }
 
25
 
 
26
    public void set(double[] vals) {
 
27
        if (vals != null) {
 
28
            width = vals.length > 0 ? vals[0] : 0;
 
29
            height = vals.length > 1 ? vals[1] : 0;
 
30
        } else {
 
31
            width = 0;
 
32
            height = 0;
 
33
        }
 
34
    }
 
35
 
 
36
    public double area() {
 
37
        return width * height;
 
38
    }
 
39
 
 
40
    public Size clone() {
 
41
        return new Size(width, height);
 
42
    }
 
43
 
 
44
    @Override
 
45
    public int hashCode() {
 
46
        final int prime = 31;
 
47
        int result = 1;
 
48
        long temp;
 
49
        temp = Double.doubleToLongBits(height);
 
50
        result = prime * result + (int) (temp ^ (temp >>> 32));
 
51
        temp = Double.doubleToLongBits(width);
 
52
        result = prime * result + (int) (temp ^ (temp >>> 32));
 
53
        return result;
 
54
    }
 
55
 
 
56
    @Override
 
57
    public boolean equals(Object obj) {
 
58
        if (this == obj) return true;
 
59
        if (!(obj instanceof Size)) return false;
 
60
        Size it = (Size) obj;
 
61
        return width == it.width && height == it.height;
 
62
    }
 
63
 
 
64
    @Override
 
65
    public String toString() {
 
66
        return (int)width + "x" + (int)height;
 
67
    }
 
68
 
 
69
}