Differences between drawing an Ellipse in Android and Java?

For the override part, I don't thing it would be a good idea since RectF isn't only used for ellipses.

For the override part, I don't thing it would be a good idea since RectF isn't only used for ellipses. You can easily write a method that draw the Oval by passing the data the way you prefer... something like: public RectF myOval(float width, float height, float x, float y){ float halfW = width/2; float halfH = height/2; return new RectF(x-halfW, y-halfH, x+halfW, y+halfH); } canvas. DrawOval(myOval(width, height, x, y), paint).

Thank you for the response, I believe you and Atreys are correct in saying that I just have to create a small function to handle the conversion for me – StartingGroovy Aug 1 '11 at 20:58.

To keep in the x, y, width, height thinking, you can construct a utility function to build a RectF with the coordinates in the order you like to think of them: public static RectF buildRectF(double x, double y, double width, double height) { // r(l,t,r,b) RectF rectf = new RectF(x-width/2, y-height/2, x+width/2, y+height/2); return rectf; } It is unclear what you are trying to do with the code sample you have. Ellipse2D. Double takes 4 values: x, y, width and height.It looks like you are setting width to be (centerX-x)*2; this will ensure that the width is twice the distance from the center of the component your code resides in to the point (100,120), if the center is to the right of the point (100, 120).

If your component gets too small, though, you will assign a negative width, which could be awkward. Also, you are using hardcoded values in your RectF example, and combining 120 (the y?) and 100 (the x? ) in the same arguments to RectF, which is most likely not what you want to do.

I'd suggest drawing a picture on a piece of paper, label the coordinates with the values you think they should be, then write your code. You should be able to more clearly see what your top left bottom and right (or x, y, width and height) values should be.

I apologize, the example was simply made up and after reading your post, I realized that I mixed up the order of the parameters in Ellipse2D. All I'm wanting to do is be able to create a RectF that can take the same parameters as Ellipse2D. So I believe you and BrainCrash are correct in saying I need to create a utility function to do the work for me.

I was just confused on how to do the conversion correctly, I assume that both your methods are the correct way of doing this? – StartingGroovy Aug 1 '11 at 20:56 Yes, they are equivalent. – Atreys Aug 2 '11 at 12:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions