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

org.webswing.toolkit.WebCursor Maven / Gradle / Ivy

There is a newer version: 20.2.4
Show newest version
package org.webswing.toolkit;

import org.webswing.toolkit.util.Util;

import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.image.BufferedImage;

public class WebCursor extends Cursor {

	private static final long serialVersionUID = -7369225579337480240L;
	private Image image;
	private Point hotSpot;

	public WebCursor(Image cursor, Point hotSpot, String name) {
		super(name);
		this.image = cursor;
		this.hotSpot = hotSpot;
	}

	public BufferedImage getImage() {
		if (image instanceof BufferedImage) {
			return (BufferedImage) image;
		} else {
			Util.waitForImage(image);
			BufferedImage bimg = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
			Graphics g = bimg.getGraphics();
			g.drawImage(image, 0, 0, null);
			g.dispose();
			image = bimg;
			return bimg;
		}
	}

	public Point getHotSpot() {
		return hotSpot;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy