the Graphics2D object's Tranform attribute g2d.scale(10, 10); // sets the Graphics2D object's Stroke attribute g2d.setStroke(new BasicStroke(1.5f)); Assuming there are no other scaling transforms added to the
Graphics2D
object, the resulting line will be approximately 15 pixels wide. As the example code demonstrates, a floating-point line offers better precision, especially when large transforms are used with a
Graphics2D
object. When a line is diagonal, the exact width depends on how the rendering pipeline chooses which pixels to fill as it traces the theoretical widened outline. The choice of which pixels to turn on is affected by the antialiasing attribute because the antialiasing rendering pipeline can choose to color partially-covered pixels.
For more information on the user space coordinate system and the rendering process, see the Graphics2D
class comments.
@see Graphics2D
@version 1.43, 03/09/06
@author Jim Graham