Android overriding PointF to get something close to java Point2D.double
I have a java method that returns Point2D.double
and Android's closest class to this is PointF
. The issue is that Po开发者_开发知识库intF
returns float rather than double. Is there a way to override PointF
so that it is double rather than float?
Why dont you just convert your doubles to floats then use PointF, you could do that with a simple cast, unless you need to keep the data as doubles for some other purpose, if thats the case you could try extending the PointF class as below, it will be slower than just using PointF due to all the casting and manipulating of the doubles to floats etc but so long as your not calling it too often it should be ok!
public class pointD extends PointF{
public double x;
public double y;
public pointD(double x, double y){
this.set((float) x,(float) y);
this.x = x;
this.y = y;
}
public double Length(){
double l = (double)this.length();
return l;
}
public final void set(double x, double y){
this.set((float) x,(float) y);
this.x = x;
this.y = y;
}
}
精彩评论