123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- /*
- @ITMillApache2LicenseForJavaFiles@
- */
-
- package com.vaadin.demo.coverflow;
-
- import com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow;
- import com.vaadin.terminal.PaintException;
- import com.vaadin.terminal.PaintTarget;
- import com.vaadin.ui.AbstractSelect;
- import com.vaadin.ui.ClientWidget;
-
- @SuppressWarnings( { "serial", "unchecked" })
- @ClientWidget(VCoverflow.class)
- public class Coverflow extends AbstractSelect {
-
- private String backgroundGradientStart = "FFFFFF";
- private String backgroundGradientEnd = "EEEEEE";
- private boolean scrollbarVisibility = true;
-
- @Override
- public String getTag() {
- return "cover";
- }
-
- /**
- * Paints the uidl
- *
- * @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.
- *
- * @param int startR
- * @param int startG
- * @param int startB
- * @param int endR
- * @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 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;
- requestRepaint();
- }
- }
-
- }
|