Produced by Araxis Merge on 12/5/2017 12:06:41 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\Hi5\src\gov\va\med\imaging\hi5\client | AffineTransform.java | Mon Dec 4 21:34:28 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\Hi5\src\gov\va\med\imaging\hi5\client | AffineTransform.java | Mon Dec 4 22:00:51 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 1014 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /** | |
| 2 | * | |
| 3 | */ | |
| 4 | package go v.va.med.i maging.hi5 .client; | |
| 5 | ||
| 6 | import org .apache.lo gging.log4 j.LogManag er; | |
| 7 | import org .apache.lo gging.log4 j.Logger; | |
| 8 | ||
| 9 | import com .google.gw t.canvas.d om.client. CanvasPixe lArray; | |
| 10 | import com .google.gw t.touch.cl ient.Point ; | |
| 11 | ||
| 12 | /** | |
| 13 | * @author
|
|
| 14 | * | |
| 15 | * see http: //en.wikip edia.org/w iki/Affine _transform ation -or- | |
| 16 | * http://ww w.w3.org/T R/2dcontex t/#transfo rmations | |
| 17 | * | |
| 18 | * The formu la is : x' =m11 * x + m12 * y + dx y'=m21 * x + m22 * y + dy | |
| 19 | * | |
| 20 | */ | |
| 21 | public cla ss AffineT ransform | |
| 22 | { | |
| 23 | public final sta tic double SIN_RIGHT _ANGLE = 1 .0; | |
| 24 | public final sta tic double COS_RIGHT _ANGLE = 0 .0; | |
| 25 | ||
| 26 | privat e Logger l ogger = Lo gManager.g etLogger(" AffineTran sformation "); | |
| 27 | ||
| 28 | privat e final Im ageStatist ics imageS tats; | |
| 29 | privat e final in t firstRow ; | |
| 30 | privat e final in t lastRow; | |
| 31 | privat e final in t firstCol umn; | |
| 32 | privat e final in t lastColu mn; | |
| 33 | ||
| 34 | // the translati on and sca ling trans formation matrix, or ganized as follows: | |
| 35 | // m11 , m12 | |
| 36 | // m21 , m22 | |
| 37 | // dx, dy | |
| 38 | privat e AffineTr ansformati onMatrix t ranslation Matrix = n ew AffineT ransformat ionMatrix( ); | |
| 39 | privat e AffineTr ansformati onMatrix r otationMat rix = new AffineTran sformation Matrix(); | |
| 40 | ||
| 41 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 42 | // Con structor ( note that instances of this cl ass are im age specif ic | |
| 43 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 44 | public AffineTra nsform(Ima geStatisti cs imageSt ats) | |
| 45 | { | |
| 46 | th is.imageSt ats = imag eStats; | |
| 47 | th is.firstRo w = (int) -(imageSta ts.getHeig ht() / 2.0 ); | |
| 48 | th is.lastRow = (int) ( imageStats .getHeight () / 2.0 + (imageSta ts.getHeig ht() / 2.0 == 0.0 ? 0.0 : 1.0) ); | |
| 49 | th is.firstCo lumn = (in t) -(image Stats.getW idth() / 2 .0); | |
| 50 | th is.lastCol umn = (int ) (imageSt ats.getWid th() / 2.0 + (imageS tats.getWi dth() / 2. 0 > 0.1 ? 1.0 : 0.0) ); | |
| 51 | } | |
| 52 | ||
| 53 | public ImageStat istics get ImageStats () | |
| 54 | { | |
| 55 | re turn image Stats; | |
| 56 | } | |
| 57 | ||
| 58 | public int getFi rstRow() | |
| 59 | { | |
| 60 | re turn first Row; | |
| 61 | } | |
| 62 | ||
| 63 | public int getLa stRow() | |
| 64 | { | |
| 65 | re turn lastR ow; | |
| 66 | } | |
| 67 | ||
| 68 | public int getFi rstColumn( ) | |
| 69 | { | |
| 70 | re turn first Column; | |
| 71 | } | |
| 72 | ||
| 73 | public int getLa stColumn() | |
| 74 | { | |
| 75 | re turn lastC olumn; | |
| 76 | } | |
| 77 | ||
| 78 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 79 | // Gen eric Trans formation methods | |
| 80 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 81 | ||
| 82 | /** | |
| 83 | * | |
| 84 | */ | |
| 85 | public void reve rt() | |
| 86 | { | |
| 87 | lo gger.info( "revert() start " + toString() ); | |
| 88 | th is.transla tionMatrix .revert(); | |
| 89 | th is.rotatio nMatrix.re vert(); | |
| 90 | ||
| 91 | lo gger.info( "revert() complete " + toStrin g()); | |
| 92 | } | |
| 93 | ||
| 94 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 95 | // Tra nslation m ethods | |
| 96 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 97 | /** | |
| 98 | * | |
| 99 | * @pa ram dx | |
| 100 | * @pa ram dy | |
| 101 | */ | |
| 102 | public final voi d setTrans late(doubl e dx, doub le dy) | |
| 103 | { | |
| 104 | th is.transla tionMatrix .setDX(dx) ; | |
| 105 | th is.transla tionMatrix .setDY(dy) ; | |
| 106 | } | |
| 107 | ||
| 108 | public final voi d translat e(double d x, double dy) | |
| 109 | { | |
| 110 | th is.transla tionMatrix .addDX(dx) ; | |
| 111 | th is.transla tionMatrix .addDY(dy) ; | |
| 112 | } | |
| 113 | ||
| 114 | public final voi d setTrans lateToOrig in() | |
| 115 | { | |
| 116 | th is.transla tionMatrix .setDX(0.0 ); | |
| 117 | th is.transla tionMatrix .setDY(0.0 ); | |
| 118 | } | |
| 119 | ||
| 120 | public final voi d flip() | |
| 121 | { | |
| 122 | th is.transla tionMatrix .multiplyM 22(-1.0); | |
| 123 | } | |
| 124 | ||
| 125 | public final voi d mirror() | |
| 126 | { | |
| 127 | th is.transla tionMatrix .multiplyM 11(-1.0); | |
| 128 | } | |
| 129 | ||
| 130 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 131 | // Sca le method | |
| 132 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 133 | public final voi d setScale (double s) | |
| 134 | { | |
| 135 | se tScale(s, s); | |
| 136 | } | |
| 137 | public final voi d scale(do uble s) | |
| 138 | { | |
| 139 | sc ale(s, s); | |
| 140 | } | |
| 141 | ||
| 142 | /** | |
| 143 | * | |
| 144 | * @pa ram dx | |
| 145 | * @pa ram dy | |
| 146 | */ | |
| 147 | public final voi d setScale (double sx , double s y) | |
| 148 | { | |
| 149 | th is.transla tionMatrix .setM11(sx ); | |
| 150 | th is.transla tionMatrix .setM22(sy ); | |
| 151 | } | |
| 152 | public final voi d scale(do uble sx, d ouble sy) | |
| 153 | { | |
| 154 | th is.transla tionMatrix .multiplyM 11(sx); | |
| 155 | th is.transla tionMatrix .multiplyM 22(sy); | |
| 156 | } | |
| 157 | ||
| 158 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 159 | // Rot ation meth od | |
| 160 | // === ========== ========== ========== ========== ========== ========== ========== ========== = | |
| 161 | privat e double t heta = 0.0 ; | |
| 162 | ||
| 163 | public double ge tRotationA ngle() | |
| 164 | { | |
| 165 | re turn theta ; | |
| 166 | } | |
| 167 | ||
| 168 | public final voi d rotate(d ouble thet a) | |
| 169 | { | |
| 170 | th is.theta = this.thet a + theta; | |
| 171 | th is.rotate( ); | |
| 172 | } | |
| 173 | ||
| 174 | public final voi d setRotat e(double t heta) | |
| 175 | { | |
| 176 | th is.theta = theta; | |
| 177 | th is.rotate( ); | |
| 178 | } | |
| 179 | ||
| 180 | privat e final vo id rotate( ) | |
| 181 | { | |
| 182 | Af fineTransf ormationMa trix atm = new Affin eTransform ationMatri x( | |
| 183 | Math .cos(getRo tationAngl e()), -Mat h.sin(getR otationAng le()), | |
| 184 | Math .sin(getRo tationAngl e()), Math .cos(getRo tationAngl e()), | |
| 185 | 0.0, 0.0); | |
| 186 | th is.rotatio nMatrix.se t(atm); | |
| 187 | } | |
| 188 | ||
| 189 | /** | |
| 190 | * | |
| 191 | * @re turn | |
| 192 | */ | |
| 193 | public boolean i sIdentityT ransform() | |
| 194 | { | |
| 195 | re turn this. translatio nMatrix.eq uals(IDENT ITY_TRANSF ORM) && th is.rotatio nMatrix.eq uals(IDENT ITY_TRANSF ORM); | |
| 196 | } | |
| 197 | ||
| 198 | /** | |
| 199 | * Tra nsform an entire ima ge given t he current transform ation matr ix. Does | |
| 200 | * not hing if th e current transforma tion matri x is the i dentity ma trix. | |
| 201 | * | |
| 202 | * @pa ram cpa | |
| 203 | * @pa ram height | |
| 204 | * @pa ram width | |
| 205 | * @pa ram bitDep th | |
| 206 | * | |
| 207 | * Th e formula is : | |
| 208 | * x' = m11 * x + m12 * y + dx | |
| 209 | * y' = m21 * x + m22 * y + dy | |
| 210 | */ | |
| 211 | public void exec ute(Canvas PixelArray cpa, doub le height, double wi dth, | |
| 212 | int bitD epth) | |
| 213 | { | |
| 214 | St ring msg = ""; | |
| 215 | ||
| 216 | ms g = "Affin eTransform is: " + t oString(); | |
| 217 | ||
| 218 | if (!isIdent ityTransfo rm()) | |
| 219 | { | |
| 220 | int[] bu ffer = new int[cpa.g etLength() ]; | |
| 221 | ||
| 222 | // the m atrix math used to e xpress the affine tr ansform as sumes that | |
| 223 | // the | |
| 224 | // pixel array (a matrix) ha s its orig in in the center of the array, | |
| 225 | // where as the | |
| 226 | // "real " origin i s at the t op left. T hat is why the follo wing loops | |
| 227 | // start at | |
| 228 | // a neg ative numb er and are transform ed into th e "real" a rray | |
| 229 | // offse ts. | |
| 230 | ||
| 231 | // itera te in imag e matrix t erms | |
| 232 | for (int y = getFi rstRow(); y < getLas tRow(); ++ y) | |
| 233 | for (int x = g etFirstCol umn(); x < getLastCo lumn(); ++ x) | |
| 234 | { | |
| 235 | Point p = new Point( x, y); | |
| 236 | Point p1 = transform Point(p); | |
| 237 | ||
| 238 | int origin PixelOffse t = (int) (((y + (-g etFirstRow ())) * get ImageStats () | |
| 239 | .g etWidth()) + (x + (- getFirstCo lumn()))); | |
| 240 | int destin ationPixel Offset = ( int) (((p1 .getY() + (-getFirst Row())) * imageStats | |
| 241 | .g etWidth()) + (p1.get X() + (-ge tFirstColu mn()))); | |
| 242 | ||
| 243 | // msg = m sg + " " | |
| 244 | // + x + " ," + y + " (" + origi nPixelOffs et + ")" | |
| 245 | // + x1 + "," + y1 + "(" + des tinationPi xelOffset + ")"; | |
| 246 | ||
| 247 | buffer[4 * destinati onPixelOff set + 0] = cpa.get(4 * originP ixelOffset + 0); | |
| 248 | buffer[4 * destinati onPixelOff set + 1] = cpa.get(4 * originP ixelOffset + 1); | |
| 249 | buffer[4 * destinati onPixelOff set + 2] = cpa.get(4 * originP ixelOffset + 2); | |
| 250 | buffer[4 * destinati onPixelOff set + 3] = cpa.get(4 * originP ixelOffset + 3); | |
| 251 | } | |
| 252 | ||
| 253 | for (int index = 0 ; index < cpa.getLen gth(); ++i ndex) | |
| 254 | cpa. set(index, buffer[in dex]); | |
| 255 | } else | |
| 256 | msg = "A ffineTrans form is id entity tra nsform, sk ipping."; | |
| 257 | ||
| 258 | lo gger.info( msg); | |
| 259 | } | |
| 260 | ||
| 261 | /** | |
| 262 | * Giv en an offs et in the origin pix el array, return a p oint in a coordinate | |
| 263 | * sys tem with t he origin at the cen ter of the image. | |
| 264 | * | |
| 265 | * @pa ram origin Offset | |
| 266 | * @re turn | |
| 267 | */ | |
| 268 | public Point ori ginPoint(i nt originO ffset) | |
| 269 | { | |
| 270 | in t y = orig inOffset / getImageS tats().get Width(); | |
| 271 | in t x = orig inOffset % getImageS tats().get Width(); | |
| 272 | ||
| 273 | y = y + getF irstRow(); // note: g etFirstRow () returns a negativ e number | |
| 274 | x = x + getF irstColumn (); // note: g etFirstCol umn() retu rns a nega tive numbe r | |
| 275 | re turn new P oint(x, y) ; | |
| 276 | } | |
| 277 | ||
| 278 | /** | |
| 279 | * Giv en a point in a coor dinate sys tem with t he origin at the cen ter of the | |
| 280 | * ima ge, return the trans formed poi nt in the same coord inate syst em. | |
| 281 | * | |
| 282 | * @pa ram p | |
| 283 | * @re turn | |
| 284 | */ | |
| 285 | public Point tra nsformPoin t(Point p) | |
| 286 | { | |
| 287 | Po int transl ated = tra nslatePoin t(p); | |
| 288 | Po int rotate d = rotate Point(tran slated); | |
| 289 | ||
| 290 | re turn rotat ed; | |
| 291 | } | |
| 292 | ||
| 293 | public Point tra nslatePoin t(Point p) | |
| 294 | { | |
| 295 | do uble x1 = ((this.tra nslationMa trix.getM1 1() * p.ge tX()) + (t his.transl ationMatri x.getM12() * p.getY( )) + this. translatio nMatrix.ge tDX()); | |
| 296 | do uble y1 = ((this.tra nslationMa trix.getM2 1() * p.ge tX()) + (t his.transl ationMatri x.getM22() * p.getY( )) + this. translatio nMatrix.ge tDY()); | |
| 297 | re turn new P oint(x1, y 1); | |
| 298 | } | |
| 299 | ||
| 300 | public Point rot atePoint(P oint p) | |
| 301 | { | |
| 302 | do uble x1 = (this.rota tionMatrix .getM11() * p.getX() ) + (this. rotationMa trix.getM1 2() * p.ge tY()); | |
| 303 | do uble y1 = (this.rota tionMatrix .getM21() * p.getX() ) + (this. rotationMa trix.getM2 2() * p.ge tY()); | |
| 304 | re turn new P oint(x1, y 1); | |
| 305 | } | |
| 306 | ||
| 307 | /** | |
| 308 | * | |
| 309 | * @pa ram p | |
| 310 | * @re turn | |
| 311 | */ | |
| 312 | public int origi nCPAPixelO ffset(Poin t p) | |
| 313 | { | |
| 314 | re turn RGBPi xel.PIXEL_ STORAGE_SI ZE * (int) ( | |
| 315 | ((p.getY () + (-get FirstRow() )) * getIm ageStats() .getWidth( )) | |
| 316 | + (p.get X() + (-ge tFirstColu mn())) | |
| 317 | ); | |
| 318 | } | |
| 319 | ||
| 320 | /** | |
| 321 | * | |
| 322 | * @pa ram p | |
| 323 | * @re turn | |
| 324 | */ | |
| 325 | public int desti nationCPAP ixelOffset (Point p) | |
| 326 | { | |
| 327 | re turn RGBPi xel.PIXEL_ STORAGE_SI ZE * (int) ( | |
| 328 | ((p.getY () + (-get FirstRow() )) * getIm ageStats() .getWidth( )) | |
| 329 | + (p.get X() + (-ge tFirstColu mn())) | |
| 330 | ); | |
| 331 | } | |
| 332 | ||
| 333 | @Overr ide | |
| 334 | public String to String() | |
| 335 | { | |
| 336 | re turn this. translatio nMatrix.to String() + this.rota tionMatrix .toString( ); | |
| 337 | } | |
| 338 | ||
| 339 | /** | |
| 340 | * | |
| 341 | * @author
|
|
| 342 | * | |
| 343 | */ | |
| 344 | class AffineTran sformation Matrix | |
| 345 | { | |
| 346 | pr ivate doub le[][] mat rix = new double[3][ 2]; | |
| 347 | ||
| 348 | pu blic Affin eTransform ationMatri x() | |
| 349 | { | |
| 350 | revert() ; | |
| 351 | } | |
| 352 | ||
| 353 | Af fineTransf ormationMa trix(doubl e[][] elem ents) | |
| 354 | { | |
| 355 | matrix[0 ][0] = ele ments[0][0 ]; | |
| 356 | matrix[0 ][1] = ele ments[0][1 ]; | |
| 357 | matrix[1 ][0] = ele ments[1][0 ]; | |
| 358 | matrix[1 ][1] = ele ments[1][1 ]; | |
| 359 | matrix[2 ][0] = ele ments[2][0 ]; | |
| 360 | matrix[2 ][1] = ele ments[2][1 ]; | |
| 361 | } | |
| 362 | ||
| 363 | Af fineTransf ormationMa trix(doubl e[] elemen ts) | |
| 364 | { | |
| 365 | matrix[0 ][0] = ele ments[0]; | |
| 366 | matrix[0 ][1] = ele ments[1]; | |
| 367 | matrix[1 ][0] = ele ments[2]; | |
| 368 | matrix[1 ][1] = ele ments[3]; | |
| 369 | matrix[2 ][0] = ele ments[4]; | |
| 370 | matrix[2 ][1] = ele ments[5]; | |
| 371 | } | |
| 372 | ||
| 373 | Af fineTransf ormationMa trix(doubl e m11, dou ble m12, d ouble m21, double m2 2, double dx, double dy ) | |
| 374 | { | |
| 375 | matrix[0 ][0] = m11 ; | |
| 376 | matrix[0 ][1] = m12 ; | |
| 377 | matrix[1 ][0] = m21 ; | |
| 378 | matrix[1 ][1] = m22 ; | |
| 379 | matrix[2 ][0] = dx; | |
| 380 | matrix[2 ][1] = dy; | |
| 381 | } | |
| 382 | ||
| 383 | pu blic void revert() | |
| 384 | { | |
| 385 | matrix[0 ][0] = 1.0 ; | |
| 386 | matrix[0 ][1] = 0.0 ; | |
| 387 | matrix[1 ][0] = 0.0 ; | |
| 388 | matrix[1 ][1] = 1.0 ; | |
| 389 | matrix[2 ][0] = 0.0 ; | |
| 390 | matrix[2 ][1] = 0.0 ; | |
| 391 | } | |
| 392 | ||
| 393 | do uble getM1 1(){return matrix[0] [0];} | |
| 394 | do uble getM1 2(){return matrix[0] [1];} | |
| 395 | do uble getM2 1(){return matrix[1] [0];} | |
| 396 | do uble getM2 2(){return matrix[1] [1];} | |
| 397 | do uble getDX (){return matrix[2][ 0];} | |
| 398 | do uble getDY (){return matrix[2][ 1];} | |
| 399 | ||
| 400 | vo id setM11( double v){ matrix[0][ 0] = v;} | |
| 401 | vo id setM12( double v){ matrix[0][ 1] = v;} | |
| 402 | vo id setM21( double v){ matrix[1][ 0] = v;} | |
| 403 | vo id setM22( double v){ matrix[1][ 1] = v;} | |
| 404 | vo id setDX(d ouble v){m atrix[2][0 ] = v;} | |
| 405 | vo id setDY(d ouble v){m atrix[2][1 ] = v;} | |
| 406 | ||
| 407 | vo id addM11( double v){ matrix[0][ 0] = matri x[0][0] + v;} | |
| 408 | vo id addM12( double v){ matrix[0][ 1] = matri x[0][1] + v;} | |
| 409 | vo id addM21( double v){ matrix[1][ 0] = matri x[1][0] + v;} | |
| 410 | vo id addM22( double v){ matrix[1][ 1] = matri x[1][1] + v;} | |
| 411 | vo id addDX(d ouble v){m atrix[2][0 ] = matrix [2][0] + v ;} | |
| 412 | vo id addDY(d ouble v){m atrix[2][1 ] = matrix [2][1] + v ;} | |
| 413 | ||
| 414 | vo id multipl yM11(doubl e v){matri x[0][0] = matrix[0][ 0] * v;} | |
| 415 | vo id multipl yM12(doubl e v){matri x[0][1] = matrix[0][ 1] * v;} | |
| 416 | vo id multipl yM21(doubl e v){matri x[1][0] = matrix[1][ 0] * v;} | |
| 417 | vo id multipl yM22(doubl e v){matri x[1][1] = matrix[1][ 1] * v;} | |
| 418 | vo id multipl yDX(double v){matrix [2][0] = m atrix[2][0 ] * v;} | |
| 419 | vo id multipl yDY(double v){matrix [2][1] = m atrix[2][1 ] * v;} | |
| 420 | ||
| 421 | vo id add(Aff ineTransfo rmationMat rix m2) | |
| 422 | { | |
| 423 | matrix[0 ][0] = mat rix[0][0] + m2.matri x[0][0]; | |
| 424 | matrix[0 ][1] = mat rix[0][1] + m2.matri x[0][1]; | |
| 425 | matrix[1 ][0] = mat rix[1][0] + m2.matri x[1][0]; | |
| 426 | matrix[1 ][1] = mat rix[1][1] + m2.matri x[1][1]; | |
| 427 | matrix[2 ][0] = mat rix[2][0] + m2.matri x[2][0]; | |
| 428 | matrix[2 ][1] = mat rix[2][1] + m2.matri x[2][1]; | |
| 429 | } | |
| 430 | ||
| 431 | vo id multipl y(AffineTr ansformati onMatrix m 2) | |
| 432 | { | |
| 433 | matrix[0 ][0] = mat rix[0][0] * m2.matri x[0][0]; | |
| 434 | matrix[0 ][1] = mat rix[0][1] * m2.matri x[0][1]; | |
| 435 | matrix[1 ][0] = mat rix[1][0] * m2.matri x[1][0]; | |
| 436 | matrix[1 ][1] = mat rix[1][1] * m2.matri x[1][1]; | |
| 437 | matrix[2 ][0] = mat rix[2][0] * m2.matri x[2][0]; | |
| 438 | matrix[2 ][1] = mat rix[2][1] * m2.matri x[2][1]; | |
| 439 | } | |
| 440 | ||
| 441 | vo id set(Aff ineTransfo rmationMat rix m2) | |
| 442 | { | |
| 443 | matrix[0 ][0] = m2. matrix[0][ 0]; | |
| 444 | matrix[0 ][1] = m2. matrix[0][ 1]; | |
| 445 | matrix[1 ][0] = m2. matrix[1][ 0]; | |
| 446 | matrix[1 ][1] = m2. matrix[1][ 1]; | |
| 447 | matrix[2 ][0] = m2. matrix[2][ 0]; | |
| 448 | matrix[2 ][1] = m2. matrix[2][ 1]; | |
| 449 | } | |
| 450 | ||
| 451 | @O verride | |
| 452 | pu blic Strin g toString () | |
| 453 | { | |
| 454 | return | |
| 455 | "m11 = " + this.ma trix[0][0] | |
| 456 | + ", m12 = " + thi s.matrix[0 ][1] | |
| 457 | + ", m21 = " + thi s.matrix[1 ][0] | |
| 458 | + ", m22 = " + thi s.matrix[1 ][1] | |
| 459 | + "dx = " + this.m atrix[2][0 ] | |
| 460 | + "dy = " + this.m atrix[2][1 ]; | |
| 461 | } | |
| 462 | ||
| 463 | @O verride | |
| 464 | pu blic boole an equals( Object obj ) | |
| 465 | { | |
| 466 | if(obj i nstanceof AffineTran sformation Matrix) | |
| 467 | { | |
| 468 | Affin eTransform ationMatri x that = ( AffineTran sformation Matrix)obj ; | |
| 469 | retur n | |
| 470 | t his.getM11 () == that .getM11() | |
| 471 | & & this.get M12() == t hat.getM12 () | |
| 472 | & & this.get M21() == t hat.getM21 () | |
| 473 | & & this.get M22() == t hat.getM22 () | |
| 474 | & & this.get DX() == th at.getDX() | |
| 475 | & & this.get DY() == th at.getDY() ; | |
| 476 | } | |
| 477 | else if( obj instan ceof doubl e[][]) | |
| 478 | { | |
| 479 | doub le[][] tha t = (doubl e[][])obj; | |
| 480 | retu rn | |
| 481 | this.getM1 1() == tha t[0][0] | |
| 482 | && this.ge tM12() == that[0][1] | |
| 483 | && this.ge tM21() == that[1][0] | |
| 484 | && this.ge tM22() == that[1][1] | |
| 485 | && this.ge tDX() == t hat[2][0] | |
| 486 | && this.ge tDY() == t hat[2][1]; | |
| 487 | } | |
| 488 | else if( obj instan ceof doubl e[]) | |
| 489 | { | |
| 490 | doub le[] that = (double[ ])obj; | |
| 491 | retu rn | |
| 492 | this.getM1 1() == tha t[0] | |
| 493 | && this.ge tM12() == that[1] | |
| 494 | && this.ge tM21() == that[2] | |
| 495 | && this.ge tM22() == that[3] | |
| 496 | && this.ge tDX() == t hat[4] | |
| 497 | && this.ge tDY() == t hat[5]; | |
| 498 | } | |
| 499 | return f alse; | |
| 500 | } | |
| 501 | } | |
| 502 | ||
| 503 | public static do uble[][] I DENTITY_TR ANSFORM = new double [][] | |
| 504 | { | |
| 505 | { 1 .0, 0.0 }, | |
| 506 | { 0 .0, 1.0 }, | |
| 507 | { 0 .0, 0.0 } | |
| 508 | }; | |
| 509 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.