tags:

views:

43

answers:

3

I am Creating a Graph Plotting Software in java. As a part of process if the equation is of form of y = Sin(x) * Cos(x)

then in that case the value of y is a decimal valued points. But in Java we are allowed to plot only integer points. Is there any way to plot points in decimal format using any package ???

The Another strategy that can be used is to convert the decimal value into corresponding integer value. But that algorithm won't give me a smooth curve ...

Thanx in Advance...

+2  A: 

If your using the Graphics class to draw your picture, use a XXXX2D class rather than XXXX class with a Graphics2D. For example:

Graphics2D g=(Graphics2D)g1;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.draw(new Line2D.Double(1.000,1.22,78.98098,3.098));
(...)
Pierre
+1  A: 

I suppose the integers x, y for a plot are the pixels at which they should go.

If you can't get a nice curve by scaling your values, you should probably think of creating a larger image in memory ( perhaps twice the y scale) and paint on that, en then scaling that image back to your GUI using getScaledInstanceSampleModel.getScaledInstance on your buffered image with the hint SCALE_SMOOTH.

Though what Pierre said is possibly better.

extraneon
+1  A: 

It is possible to plot points at non integer positions. You may use Point2D.Double or Point2D.Float. See http://java.sun.com/docs/books/tutorial/2d/geometry/primitives.html for further details.

Nils Schmidt