Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

drawRect( double,double,double,double)

Status
Not open for further replies.

darine

Programmer
Jun 23, 2000
28
US
Hi all<br>I'm trying to draw rectangles or any objects with passing parameters other than integeres to drawRect() or to object.setBounds() methods.The problem is i can't found a similar methods to accept floats or doubles .<br>i tried to use parse methods and convert my flots or doubles to integers and round() to round those nubers to the nearst int values,but when look into the graphs i see the same level<br>for all values that have decimal points between 0.5 to 0.9 and the same as 0.1 to 0.5.<br>I hope someone will help me with this.<br>thanks alot.
 
As you can see in the Javadoc at <A HREF=" TARGET="_new"> for Graphics.drawRect(), the parameters are of type int. The only thing I can suggest is to scale- if you have one rectangle at 3.5 and another at 4, make the first one 7 and the second one 8. I think things are hopeless beyond that... if you can tell me why exactly you need to draw rectangles with doubles and floats, I might be able to come up with a different solution. If you are doing graphs as you say, you might be able to use the JChart Swing stuff.<br><br>Good luck.. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
It doesn't make any sense for the drawRect method to accept doubles or floats. Think about it this way, the integers are used to specify pixels. A pixel on a display can not be a fraction, ie float or double, it just doesn't make sense to allow the input of half a pixel when a you can physical lite up half a pixel. <br><br>As Liam said in the above, you would need some sort of scalling method. I have not yet attempted to display information graphically yet, So I can't give you much more then some advice. <br><br>Try <A HREF=" TARGET="_new"> and look under the 2d graphics section, there you may be able to download source code to what you are looking for.<br><br> <p> fenris<br><a href=mailto:fenris@hotmail.com>fenris@hotmail.com</a><br><a href= > </a><br>
 
Thanks for your time.<br>what i'm trying to do is ,use a setBounds() to control displaying a Panels or Canvas as bars in Chart of bars.<br>the problem is that method accepts integers and i want ot control the height of those bars(panel or canvas objects)<br>based on floats or double values.<br>i'm trying to think about scale,but that maybe will affect my other codes or the height of my applet.<br>thanks again.<br>
 
I don't recognize setBounds() off the top of my head... what class is that coming from? You mentioned &quot;object&quot;, which would lead me to believe that it is a method straight from the Object class, but I checked the API specifications (<A HREF=" TARGET="_new"> that's a great link if you haven't seen it before) and I didn't see it under Object. What setBounds() method are you referring to? <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
wow, there is a rectangle with doubles. I didn't know this. I really need to go take a look at Java 2 stuff more often, there's so much I haven't been looking at. If you take a look at <A HREF=" TARGET="_new"> , you'll see - there really is a rectangle that has doubles for arguments. I don't know the internals of it.. but it makes sense, I guess. <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top