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

devutility.internal.awt.Graphics2DUtils Maven / Gradle / Ivy

There is a newer version: 1.3.8.1
Show newest version
package devutility.internal.awt;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;

public class Graphics2DUtils {
	public static void drawString(Graphics2D graphics, Font font, Color color, AlphaComposite alphaComposite, String text, float positionX, float positionY) {
		graphics.setFont(font);
		graphics.setColor(color);
		graphics.setComposite(alphaComposite);
		graphics.drawString(text, positionX, positionY);
	}

	public static void drawString(Graphics2D graphics, Font font, Color color, float alpha, String text, float positionX, float positionY) {
		drawString(graphics, font, color, AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha), text, positionX, positionY);
	}

	public static void rotate(Graphics2D graphics, int width, int height, int slopeAngle) {
		if (slopeAngle > 0) {
			graphics.rotate(Math.toRadians(slopeAngle), width / 2, height / 2);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy