You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Esteban R <er...@hotmail.com> on 2019/11/27 16:47:20 UTC
TextPosition.equal() fails after getDir()
This is a simplification of a real life problem: when I compare two TextPositions, equality changes after calling getDir() in one of the TextPositions.
Code to reproduce:
Matrix m1 = new Matrix(1, 1, 1, 1, 1, 1);
Matrix m2 = new Matrix(1, 1, 1, 1, 1, 1);
TextPosition t1 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
TextPosition t2 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
System.out.println("Before getDir, equals: "+t1.equals(t2)); //true
t1.getDir(); //changes direction field!!!
System.out.println("After getDir, equals: "+t1.equals(t2)); //false!!
Esteban
Re: TextPosition.equal() fails after getDir()
Posted by Tilman Hausherr <TH...@t-online.de>.
Ouch. This is because "direction" is used in equality and it isn't
needed, because "matrix" is used as well.
Tilman
Am 27.11.2019 um 17:47 schrieb Esteban R:
> This is a simplification of a real life problem: when I compare two TextPositions, equality changes after calling getDir() in one of the TextPositions.
>
> Code to reproduce:
>
> Matrix m1 = new Matrix(1, 1, 1, 1, 1, 1);
> Matrix m2 = new Matrix(1, 1, 1, 1, 1, 1);
> TextPosition t1 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
> TextPosition t2 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
> System.out.println("Before getDir, equals: "+t1.equals(t2)); //true
> t1.getDir(); //changes direction field!!!
> System.out.println("After getDir, equals: "+t1.equals(t2)); //false!!
>
>
> Esteban
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: TextPosition.equal() fails after getDir()
Posted by Tilman Hausherr <TH...@t-online.de>.
Fixed in
https://issues.apache.org/jira/browse/PDFBOX-4701
Tilman
Am 27.11.2019 um 17:47 schrieb Esteban R:
> This is a simplification of a real life problem: when I compare two TextPositions, equality changes after calling getDir() in one of the TextPositions.
>
> Code to reproduce:
>
> Matrix m1 = new Matrix(1, 1, 1, 1, 1, 1);
> Matrix m2 = new Matrix(1, 1, 1, 1, 1, 1);
> TextPosition t1 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
> TextPosition t2 = new TextPosition(0, 1000, 1000, m2, 10, 10, 100, 10, 10, "a", null, null, 10, 10);
> System.out.println("Before getDir, equals: "+t1.equals(t2)); //true
> t1.getDir(); //changes direction field!!!
> System.out.println("After getDir, equals: "+t1.equals(t2)); //false!!
>
>
> Esteban
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org