Graphics2D
Graphics2D is a class in the Java AWT and Swing libraries that provides enhanced control over two-dimensional rendering. It is a subclass of Graphics and a centerpiece of the Java 2D API, offering precise drawing of shapes, text, and images with configurable painting, transforms, and transparency.
Its core capabilities include affine transformations, stroke definitions, and paint management. Graphics2D supports complex painting through
In typical Swing painting code, a component overrides paintComponent(Graphics g) and obtains a Graphics2D instance by
This transformation system uses an AffineTransform to map user-space coordinates to device coordinates, allowing rotation, scaling,
Graphics2D integrates with Paint, Stroke, and Composite to control appearance. Paint selects colors or patterns, Stroke
Usage note: Graphics2D contexts are tied to a specific drawing surface. If a method modifies the graphics