If you want to always stretch the graph to fit the view I'd change this:
|
Code:
|
int newY = (int) ( (y - 1) * -width/2 ) |
to this:
|
Code:
|
int newY = (int) ( (y - 1) * -height/2 ) |
your height may == width now, but this may not always be the case.
If on the other hand you want to always maintain a square symmetry, then you could always check which is greater height or width and use the lesser of the two as your scaling factor.
|
Quote:
|
|
Please tell if casting this into a int is required. I thought Java coord. system only takes int values. My x & y are all double value type.
|
The methods you use should tell you when int is required. For instance many Shape object derived methods and constructors will happily use floating point variables, for instance the methods of Point2D, while most (all?) of the Graphics draw methods require ints. Here's where the Java API becomes indispensable.
|
Quote:
|
Now i want to assign newX & newY into the original x & y values.
And also use newX & newY to draw shapes into system.
How to do this?
|
I'm not sure what you're asking here. More details may help.