All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mdlaf.utils.MaterialDrawingUtils Maven / Gradle / Ivy

There is a newer version: 1.1.4
Show newest version
package mdlaf.utils;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.Toolkit;
import java.util.Map;

/**
 * @author https://github.com/vincenzopalazzo
 * @author https://github.com/atarw
 */
public class MaterialDrawingUtils {

	static {
		System.setProperty("awt.useSystemAAFontSettings", "on");
		System.setProperty("swing.aatext", "true");
		System.setProperty("sun.java2d.xrender", "true");
	}

	public static Graphics getAliasedGraphics (Graphics g) {
		Map hints = (Map) Toolkit.getDefaultToolkit ().getDesktopProperty("awt.font.desktophints");

		if(hints != null){
			hints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
			hints.put(RenderingHints.KEY_RENDERING,	RenderingHints.VALUE_RENDER_DEFAULT);
			hints.put(RenderingHints.KEY_COLOR_RENDERING,	RenderingHints.VALUE_COLOR_RENDER_DEFAULT);
			hints.put(RenderingHints.KEY_TEXT_ANTIALIASING,	RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

			Graphics2D g2d = (Graphics2D) g;
			g2d.addRenderingHints(hints);
			return g2d;
		}

		//g2d.addRenderingHints (new RenderingHints (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
		return g;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy