J
joe pribele
For some reason you can't change the location of the points in a line
directly. Yes I know there are methods in Line2D to set the location
but they take both Points and I was being lazy and only wanted to
change one.
I doesn't say anywhere in the docs that the points are read only.
Here is a short app that demonstrate the problem.
import java.awt.geom.*;
public class Test {
public static void main(String[] args ) {
Line2D.Float f = new Line2D.Float( 10,10,5,55 );
System.out.println( "p1=" + f.getP1() );
System.out.println( "p2=" + f.getP2() ); // 5, 55
f.getP2().setLocation( 66,66 );
System.out.println( "p2=" + f.getP2() ); // 5, 55 not 66,66 as
expected
}
}
directly. Yes I know there are methods in Line2D to set the location
but they take both Points and I was being lazy and only wanted to
change one.
I doesn't say anywhere in the docs that the points are read only.
Here is a short app that demonstrate the problem.
import java.awt.geom.*;
public class Test {
public static void main(String[] args ) {
Line2D.Float f = new Line2D.Float( 10,10,5,55 );
System.out.println( "p1=" + f.getP1() );
System.out.println( "p2=" + f.getP2() ); // 5, 55
f.getP2().setLocation( 66,66 );
System.out.println( "p2=" + f.getP2() ); // 5, 55 not 66,66 as
expected
}
}