jMonkeyEngine / jmonkeyengine

A complete 3-D game development suite written in Java.
http://jmonkeyengine.org
BSD 3-Clause "New" or "Revised" License
3.78k stars 1.12k forks source link

Picture: Add methods getWidth, getHeight. #2015

Closed capdevon closed 1 year ago

capdevon commented 1 year ago

The Pictureclass has the setter methods on the widthand heightattributes, but there are no getter methods. Would you please add them? They would come in handy. Thank you.

https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-core/src/main/java/com/jme3/ui/Picture.java#L51

public class Picture extends Geometry {

    private float width  = 1f;
    private float height = 1f;

    // -----------------------------------------------
    // >>> The getter methods are missing <<<
    // -----------------------------------------------
    [...]

    /**
     * Set the width in pixels of the picture, if the width
     * does not match the texture's width, then the texture will
     * be scaled to fit the picture.
     * 
     * @param width the width to set.
     */
    public void setWidth(float width){
        this.width = width;
        setLocalScale(new Vector3f(width, height, 1f));
    }

    /**
     * Set the height in pixels of the picture, if the height
     * does not match the texture's height, then the texture will
     * be scaled to fit the picture.
     * 
     * @param height the height to set.
     */
    public void setHeight(float height){
        this.height = height;
        setLocalScale(new Vector3f(width, height, 1f));
    }

}
stephengold commented 1 year ago

Good idea. I'll implement the methods.