diff options
Diffstat (limited to 'src/com/vaadin/demo/coverflow/Coverflow.java')
-rw-r--r-- | src/com/vaadin/demo/coverflow/Coverflow.java | 117 |
1 files changed, 69 insertions, 48 deletions
diff --git a/src/com/vaadin/demo/coverflow/Coverflow.java b/src/com/vaadin/demo/coverflow/Coverflow.java index 5c8e9403c2..dfd2b4fbe6 100644 --- a/src/com/vaadin/demo/coverflow/Coverflow.java +++ b/src/com/vaadin/demo/coverflow/Coverflow.java @@ -8,33 +8,39 @@ import com.vaadin.terminal.PaintException; import com.vaadin.terminal.PaintTarget; import com.vaadin.ui.AbstractSelect; +@SuppressWarnings("serial") public class Coverflow extends AbstractSelect { - private String backgroundGradientStart = "FFFFFF"; - private String backgroundGradientEnd = "EEEEEE"; - private boolean scrollbarVisibility = true; - + private String backgroundGradientStart = "FFFFFF"; + private String backgroundGradientEnd = "EEEEEE"; + private boolean scrollbarVisibility = true; + + @Override public String getTag() { - return "cover"; + return "cover"; } - + /** * Paints the uidl - * @param PaintTarget target + * + * @param PaintTarget + * target * @throws PaintException */ + @Override public void paintContent(PaintTarget target) throws PaintException { // Superclass writes any common attributes in the paint target. super.paintContent(target); - + target.addAttribute("backgroundGradientStart", backgroundGradientStart); target.addAttribute("backgroundGradientEnd", backgroundGradientEnd); target.addAttribute("scrollbarVisibility", scrollbarVisibility); } - + /** - * The user can specify a background gradient for the coverflow. The input values - * are RGB values for the start and end gradients. + * The user can specify a background gradient for the coverflow. The input + * values are RGB values for the start and end gradients. + * * @param int startR * @param int startG * @param int startB @@ -42,48 +48,63 @@ public class Coverflow extends AbstractSelect { * @param int endG * @param int endB */ - public void setBackgroundColor(int startR, int startG, int startB, int endR, int endG, int endB) { - backgroundGradientStart = ""; - backgroundGradientEnd = ""; - - // Convert all integers to hexadecimal format and make sure they are two characters long (in - // other words, add a zero infront if the value is less than 16 => 0x0F - if(startR < 16) - backgroundGradientStart += "0"; - backgroundGradientStart += Integer.toHexString(Math.max(Math.min(startR,255),0)); - - if(startG < 16) - backgroundGradientStart += "0"; - backgroundGradientStart += Integer.toHexString(Math.max(Math.min(startG,255),0)); - - if(startB < 16) - backgroundGradientStart += "0"; - backgroundGradientStart += Integer.toHexString(Math.max(Math.min(startB,255),0)); - - if(endR < 16) - backgroundGradientEnd += "0"; - backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endR,255),0)); - - if(endG < 16) - backgroundGradientEnd += "0"; - backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endG,255),0)); - - if(endB < 16) - backgroundGradientEnd += "0"; - backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endB,255),0)); - - this.requestRepaint(); + public void setBackgroundColor(int startR, int startG, int startB, + int endR, int endG, int endB) { + backgroundGradientStart = ""; + backgroundGradientEnd = ""; + + // Convert all integers to hexadecimal format and make sure they are two + // characters long (in other words, add a zero in front if the value is + // less than 16 => 0x0F) + if (startR < 16) { + backgroundGradientStart += "0"; + } + backgroundGradientStart += Integer.toHexString(Math.max(Math.min( + startR, 255), 0)); + + if (startG < 16) { + backgroundGradientStart += "0"; + } + backgroundGradientStart += Integer.toHexString(Math.max(Math.min( + startG, 255), 0)); + + if (startB < 16) { + backgroundGradientStart += "0"; + } + backgroundGradientStart += Integer.toHexString(Math.max(Math.min( + startB, 255), 0)); + + if (endR < 16) { + backgroundGradientEnd += "0"; + } + backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endR, + 255), 0)); + + if (endG < 16) { + backgroundGradientEnd += "0"; + } + backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endG, + 255), 0)); + + if (endB < 16) { + backgroundGradientEnd += "0"; + } + backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endB, + 255), 0)); + + requestRepaint(); } - + /** * The user can toggle the visibility of the scrollbar + * * @param boolean visible */ public void setScrollbarVisibility(boolean visible) { - if(scrollbarVisibility != visible) { - scrollbarVisibility = visible; - this.requestRepaint(); - } + if (scrollbarVisibility != visible) { + scrollbarVisibility = visible; + requestRepaint(); + } } - + } |