Coordinate system of java | Graphics2D coordinate system | Razsoft Education
As we all know java follows WORA(Write Once Run Anywhere) principle. So, in this process it may encounter many different size and type of output devices. To give the same user experience to users across all devices java manages two different coordinate system.
1. User space coordinate system
2. Device space coordinate system
1. User space coordinate system :- It's a device independent coordinate system also called logical coordinate system. Which is used by developers to draw and set elements in application. It's relative to the application. In java to do all the graphical drawing we use this coordinate system.
In user space top left corner is 0,0 position. The x- coordinate goes horizontally from left to right, and y-coordinate moves from top to bottom. And a point is defined by first x - coordinate followed by y- coordinate.
2. Device space coordinate system :- It's a device dependent coordinate system. Defined by device i.e. how device manages it's own coordinate system to render elements. It varies device to device as screen size and device type changes the coordinate system also changes. All the geometric primitives or element we see it transformed from user coordinate to device coordinate. These conversion takes place automatically and invisible to the application.
Java 2D API defines three levels of configuration information to encapsulate conversion information from user coordinate to device coordinate. Usually programmers don't need this but some special purpose we can access these information from these three classes.
1. GraphicsEnvironment
2. GraphicsDevice
3. GraphicsConfiguration
Comments
Post a Comment