From e4cda1c751ebd4ed11d698c2a70a08622207e21a Mon Sep 17 00:00:00 2001 From: Sampo Niskanen Date: Sun, 6 Jan 2013 18:10:17 +0200 Subject: [PATCH] Clamp shine parameter in range of 0..1 --- .../sf/openrocket/appearance/Appearance.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/core/src/net/sf/openrocket/appearance/Appearance.java b/core/src/net/sf/openrocket/appearance/Appearance.java index 365c81037..a421c15e8 100644 --- a/core/src/net/sf/openrocket/appearance/Appearance.java +++ b/core/src/net/sf/openrocket/appearance/Appearance.java @@ -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 */ 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 + "]"; } - + }