aspose file tools*
The moose likes Java in General and the fly likes How to change a parameter type of a API class? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to change a parameter type of a API class?" Watch "How to change a parameter type of a API class?" New topic
Author

How to change a parameter type of a API class?

Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Okay what I mean is I am trying to fill/draw in my paint method using Floats, but it only accepts integers..



Basically

Anything with a 1 after it i.e., y1 is an int, and the 'x' is a float.

Normally everything is a float, but I had to convert it using x1 = (int) x;

to get the fillRect/drawRect to work... Now I rather not have to change these, so is there a way I can keep them as a float and use the g2 class? Do I just override the fillRect/drawRect methods to accept floats instead, or is there another way.


Also

What exactly is it doing here? It seems that we are setting g2 to Graphics g, because g2 is a subclass of g. I also tried
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2851
    
  11

You can cast them as you make the call, like:



But why do you want things that measure pixels to be floats?
Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Greg Charles wrote:You can cast them as you make the call, like:



But why do you want things that measure pixels to be floats?


That's casting them to an int tho... I want to keep them as a float..

I'm not sure why exactly, I'm importing something using floats, I'm going to meet someone now and ask... thanks.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2851
    
  11

Jay Orsaw wrote:
That's casting them to an int tho...


That's true. In that case, the answer is no. There is no way to pass floats as parameters to a method that declares those parameters to be ints.
Jay Orsaw
Ranch Hand

Joined: Jun 14, 2011
Posts: 356

Greg Charles wrote:
Jay Orsaw wrote:
That's casting them to an int tho...


That's true. In that case, the answer is no. There is no way to pass floats as parameters to a method that declares those parameters to be ints.


Without implementing the class and overriding right?

So figured out they can be ints and what I needed to do, for the floats....



SO now I'm just curious about the Graphics initiation...

Oh and what's special about an abstract class?
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2851
    
  11

Jay Orsaw wrote:
Without implementing the class and overriding right?


Subclassing, you mean? No, if you override a method in a subclass, it has to have the same signature (i.e., parameter types) as in the parent class. You can overload a method to give it a different signature, but that's really a different method.

Jay Orsaw wrote:
Oh and what's special about an abstract class?


An abstract class cannot be directly instantiated. It must be subclassed by a concrete class for an instance to be created.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change a parameter type of a API class?