de.lessvoid.nifty.elements.render.ImageRenderer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of nifty Show documentation
Show all versions of nifty Show documentation
Nifty GUI is a Java Library that supports the building of interactive user interfaces for games or similar applications. It utilizes OpenGL for rendering and it can be easily integrated into many rendering systems. The configuration of the GUI is stored in xml files with little supporting Java code. In short Nifty helps you to layout stuff, display it in a cool way and interact with it :)
package de.lessvoid.nifty.elements.render;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.render.NiftyImage;
import de.lessvoid.nifty.render.NiftyRenderEngine;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
/**
* Image Renderer.
*
* @author void
*/
public class ImageRenderer implements ElementRenderer {
@Nullable
private NiftyImage image;
private int inset = 0;
/**
* Set Insert.
*/
public void setInset(final int insetParam) {
inset = insetParam;
}
/**
* render it.
*
* @param element the element this ElementRenderer connects to
* @param r the RenderDevice
*/
@Override
public final void render(@Nonnull final Element element, @Nonnull final NiftyRenderEngine r) {
if (image != null) {
r.renderImage(
image,
element.getX() + inset,
element.getY() + inset,
element.getWidth() - inset * 2,
element.getHeight() - inset * 2);
}
}
/**
* Get the contained Image.
*
* @return the Image
*/
@Nullable
public NiftyImage getImage() {
return image;
}
/**
* Set a new image.
*
* @param newImage new image
*/
public void setImage(@Nullable final NiftyImage newImage) {
image = newImage;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy