CoordPair.java
4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
* Decompiled with CFR 0_118.
*/
package com.adobe.xfa.ut;
import com.adobe.xfa.ut.Angle;
import com.adobe.xfa.ut.UnitSpan;
public final class CoordPair {
public static final CoordPair ZERO_ZERO = new CoordPair();
private final UnitSpan mX;
private final UnitSpan mY;
public CoordPair() {
this.mX = UnitSpan.ZERO;
this.mY = UnitSpan.ZERO;
}
public CoordPair(CoordPair source) {
this.mX = source.x();
this.mY = source.y();
}
public CoordPair(UnitSpan x, UnitSpan y) {
this.mX = x;
this.mY = y;
}
public CoordPair grid(CoordPair grid) {
return new CoordPair(this.mX.grid(grid.x()), this.mY.grid(grid.y()));
}
public CoordPair round(CoordPair round) {
return new CoordPair(this.mX.round(round.x()), this.mY.round(round.y()));
}
public UnitSpan x() {
return this.mX;
}
public UnitSpan y() {
return this.mY;
}
public CoordPair rotatePoint(CoordPair oRPoint, Angle oAngle) {
int degrees = oAngle.degrees();
if (degrees == 0) {
return this;
}
UnitSpan oTX = new UnitSpan(3, this.mX.units(), this.mX.value());
UnitSpan oTY = new UnitSpan(3, this.mY.units(), this.mY.value());
UnitSpan oRPX = new UnitSpan(3, oRPoint.x().units(), oRPoint.x().value());
UnitSpan oRPY = new UnitSpan(3, oRPoint.y().units(), oRPoint.y().value());
int lX = oTX.value();
int lY = - oTY.value();
int lXR = oRPX.value();
int lYR = - oRPY.value();
switch (degrees) {
case 90: {
oTX = new UnitSpan(3, lXR - (lY - lYR));
oTY = new UnitSpan(3, - lYR + (lX - lXR));
break;
}
case 180: {
oTX = new UnitSpan(3, lXR - (lX - lXR));
oTY = new UnitSpan(3, - lYR - (lY - lYR));
break;
}
case 270: {
oTX = new UnitSpan(3, lXR + (lY - lYR));
oTY = new UnitSpan(3, - lYR - (lX - lXR));
break;
}
default: {
double dRadians = (double)oAngle.degrees() * 0.017453292519943295;
double dCosAngle = Math.cos(dRadians);
double dSinAngle = Math.sin(dRadians);
oTX = new UnitSpan(3, (int)Math.round((double)lXR + (double)(lX - lXR) * dCosAngle - (double)(lY - lYR) * dSinAngle));
oTY = new UnitSpan(3, (int)(- Math.round((double)lYR + (double)(lY - lYR) * dCosAngle + (double)(lX - lXR) * dSinAngle)));
}
}
return new CoordPair(oTX, oTY);
}
public boolean equals(Object object) {
if (this == object) {
return true;
}
if (object == null) {
return false;
}
if (object.getClass() != this.getClass()) {
return false;
}
CoordPair cmp = (CoordPair)object;
return this.mX.equals(cmp.mX) && this.mY.equals(cmp.mY);
}
public int hashCode() {
int hash = 11;
hash = hash * 31 ^ this.mX.hashCode();
hash = hash * 31 ^ this.mY.hashCode();
return hash;
}
public boolean notEquals(Object compare) {
return !this.equals(compare);
}
public CoordPair add(CoordPair add) {
return new CoordPair(this.mX.add(add.mX), this.mY.add(add.mY));
}
public CoordPair subtract(CoordPair subtract) {
return new CoordPair(this.mX.subtract(subtract.mX), this.mY.subtract(subtract.mY));
}
public CoordPair scale(double dXScale, double dYScale) {
return new CoordPair(this.mX.multiply(dXScale), this.mY.multiply(dYScale));
}
public boolean gt(CoordPair compare) {
if (this.mY.gt(compare.mY)) {
return true;
}
if (this.mY.lt(compare.mY)) {
return false;
}
return this.mX.gt(compare.mX);
}
public boolean lt(CoordPair compare) {
if (this.mY.lt(compare.mY)) {
return true;
}
if (this.mY.gt(compare.mY)) {
return false;
}
return this.mX.lt(compare.mX);
}
public static CoordPair zeroZero() {
return ZERO_ZERO;
}
}