Thursday, July 27, 2017

Is it possible in Java2D to move the coordinate system?

down vote accepted
You can change your coordinate system using the translate() function. For example:
Graphics2D g;                    // Assume this is already initialized
g.drawLine(100, 100, 200, 200);  // Draw in the default coordinate system
g.translate(100.0, 100.0);       // Move the origin down and to the right
g.drawLine(0, 0, 100, 100);      // Draw the same line relative to new origin
You can also use scale(), rotate() and shear() for more powerful transformations of the coordinate system. For more information check this page: http://docstore.mik.ua/orelly/java-ent/jfc/ch04_03.htm

No comments:

Post a Comment