E
Eustace
Instead of having the x and y coordinates start at the top right corner,
I prefer them to start either at the center of the window. This I can do
with:
....
class CustomPanel extends JPanel {
public void paintComponent(Graphics painter) {
painter2D = (Graphics2D)painter;
painter2D.translate(width/2, height/2);
....
But I would also prefer the positive values across the y axis to be
positive above the base line and negative below.
I could use
painter2D.rotate(-Math.PI/2);
but then of course the x axis and the y axis replace each other, so then
I have to use, for example,
Rectangle 2D frame = new Rectangle2D.Double(y, x, h, w);
instead of
Rectangle 2D frame = new Rectangle2D.Double(x, y, w, h);
As I see it my choices are:
(a) Get used to the y axis moving downwards.
(b) Use rotation and learn to remember that y replaces x etc.
(c) Use (b) and overwrite the constructors that use x, y, w, h.
I would like to hear what the solution of experienced programmers is. I
tend to accept (a), hoping that after some time it will seem natural.
But is there a (d) option of reversing the direction of the y axis?
Thanks,
emf
I prefer them to start either at the center of the window. This I can do
with:
....
class CustomPanel extends JPanel {
public void paintComponent(Graphics painter) {
painter2D = (Graphics2D)painter;
painter2D.translate(width/2, height/2);
....
But I would also prefer the positive values across the y axis to be
positive above the base line and negative below.
I could use
painter2D.rotate(-Math.PI/2);
but then of course the x axis and the y axis replace each other, so then
I have to use, for example,
Rectangle 2D frame = new Rectangle2D.Double(y, x, h, w);
instead of
Rectangle 2D frame = new Rectangle2D.Double(x, y, w, h);
As I see it my choices are:
(a) Get used to the y axis moving downwards.
(b) Use rotation and learn to remember that y replaces x etc.
(c) Use (b) and overwrite the constructors that use x, y, w, h.
I would like to hear what the solution of experienced programmers is. I
tend to accept (a), hoping that after some time it will seem natural.
But is there a (d) option of reversing the direction of the y axis?
Thanks,
emf