public static void paintAtScale1x( Graphics2D g, int x, int y, int width, int height, Painter painter ) {
		// save original transform
		AffineTransform t = g.getTransform();

		// get scale X/Y and shear X/Y
		final double scaleX = t.getScaleX();
		final double scaleY = t.getScaleY();
		final double shearX = t.getShearX();
		final double shearY = t.getShearY();

		// check whether rotated
		// (also check for negative scale X/Y because shear X/Y are zero for 180 degrees rotation)
		boolean rotated = (shearX != 0 || shearY != 0 || scaleX <= 0 || scaleY <= 0);

		// calculate non rotated scale factors
		final double realScaleX, realScaleY;
		if( rotated ) {
			// resulting scale X/Y values are always positive
			realScaleX = Math.hypot( scaleX, shearX );
			realScaleY = Math.hypot( scaleY, shearY );
		} else {
			// make scale X/Y positive
			realScaleX = Math.abs( scaleX );
			realScaleY = Math.abs( scaleY );
		}

		// check whether scaled
		if( realScaleX == 1 && realScaleY == 1 ) {
			painter.paint( g, x, y, width, height, 1 );
			return;
		}

		// calculate x and y (this is equal to t.translate( x, y ))
		double px = (x * scaleX) + (y * shearX) + t.getTranslateX();
		double py = (y * scaleY) + (x * shearY) + t.getTranslateY();

		// scale rectangle
		Rectangle2D.Double scaledRect = scale( realScaleX, realScaleY, px, py, width, height );

		try {
			// unscale to factor 1.0, keep rotation and move origin (to whole numbers)
			AffineTransform t1x;
			if( rotated ) {
				t1x = new AffineTransform( scaleX, shearY, shearX, scaleY,
					Math.floor( scaledRect.x ), Math.floor( scaledRect.y ) );
				t1x.scale( 1. / realScaleX, 1. / realScaleY );
			} else
				t1x = new AffineTransform( 1, 0, 0, 1, Math.floor( scaledRect.x ), Math.floor( scaledRect.y ) );
			g.setTransform( t1x );

			int swidth = (int) scaledRect.width;
			int sheight = (int) scaledRect.height;

			// paint
			painter.paint( g, 0, 0, swidth, sheight, realScaleX );
		} finally {
			// restore original transform
			g.setTransform( t );
		}
	}
Paint at system scale factor 1x to avoid rounding issues at 125%, 150% and 175% scaling.
<p>
Scales the given Graphics2D down to 100% and invokes the
given painter passing scaled x, y, width and height.
<p>
Uses the same scaling calculation as the JRE uses.
flatlaf-core/src/main/java/com/formdev/flatlaf/util/HiDPIUtils.java