Clamp shine parameter in range of 0..1

This commit is contained in:
Sampo Niskanen 2013-01-06 18:10:17 +02:00
parent 31f620d1bd
commit e4cda1c751

View File

@ -1,6 +1,7 @@
package net.sf.openrocket.appearance;
import net.sf.openrocket.util.Color;
import net.sf.openrocket.util.MathUtil;
/**
* A component appearance.
@ -9,40 +10,40 @@ import net.sf.openrocket.util.Color;
* @author Bill Kuker <bkuker@billkuker.com>
*/
public class Appearance {
public static final Appearance MISSING = new Appearance(new Color(0,0,0), 100, null);
public static final Appearance MISSING = new Appearance(new Color(0, 0, 0), 100, null);
private final Color paint;
private final double shine;
private final Decal texture;
Appearance(final Color paint, final double shine, final Decal texture){
Appearance(final Color paint, final double shine, final Decal texture) {
this.paint = paint;
this.shine = shine;
this.shine = MathUtil.clamp(shine, 0, 1);
this.texture = texture;
}
Appearance(final Color paint, final double shine){
Appearance(final Color paint, final double shine) {
this.paint = paint;
this.shine = shine;
this.shine = MathUtil.clamp(shine, 0, 1);
this.texture = null;
}
public Color getPaint() {
return paint;
}
public double getShine() {
return shine;
}
public Decal getTexture() {
return texture;
}
@Override
public String toString() {
return "Appearance [paint=" + paint + ", shine="
+ shine + ", texture=" + texture + "]";
}
}