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

com.sshtools.icongenerator.javafx.JavaFXCanvasGenerator Maven / Gradle / Ivy

Go to download

This extension to icon-generator will generate JavaFX icons drawn on a canvas. Simply add it to your classpath and a new generator will be available for javafx.scene.canvas.Canvas objects.

There is a newer version: 1.4.3
Show newest version
package com.sshtools.icongenerator.javafx;

import com.sshtools.icongenerator.IconBuilder;
import com.sshtools.icongenerator.IconGenerator;

import javafx.scene.canvas.Canvas;

/**
 * Icon generator for Java. Produces a {@link Canvas}
 */
public class JavaFXCanvasGenerator implements IconGenerator {

	@Override
	public Class getIconClass() {
		return Canvas.class;
	}

	@Override
	public Canvas generate(IconBuilder builder, Object... args) {
		JavaFXIconCanvas iconCanvas = new JavaFXIconCanvas(builder);
		Canvas canvas = new Canvas(builder.width(), builder.height());
		iconCanvas.draw(canvas.getGraphicsContext2D());
		return canvas;
	}

	@Override
	public boolean isValid() {
		try {
			getClass().getClassLoader().loadClass("javafx.scene.canvas.Canvas");
			return true;
		} catch (Exception e) {
			return false;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy