You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Coverflow.java 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.demo.coverflow;
  5. import com.vaadin.demo.coverflow.gwt.client.ui.VCoverflow;
  6. import com.vaadin.terminal.PaintException;
  7. import com.vaadin.terminal.PaintTarget;
  8. import com.vaadin.ui.AbstractSelect;
  9. import com.vaadin.ui.ClientWidget;
  10. @SuppressWarnings( { "serial", "unchecked" })
  11. @ClientWidget(VCoverflow.class)
  12. public class Coverflow extends AbstractSelect {
  13. private String backgroundGradientStart = "FFFFFF";
  14. private String backgroundGradientEnd = "EEEEEE";
  15. private boolean scrollbarVisibility = true;
  16. @Override
  17. public String getTag() {
  18. return "cover";
  19. }
  20. /**
  21. * Paints the uidl
  22. *
  23. * @param PaintTarget
  24. * target
  25. * @throws PaintException
  26. */
  27. @Override
  28. public void paintContent(PaintTarget target) throws PaintException {
  29. // Superclass writes any common attributes in the paint target.
  30. super.paintContent(target);
  31. target.addAttribute("backgroundGradientStart", backgroundGradientStart);
  32. target.addAttribute("backgroundGradientEnd", backgroundGradientEnd);
  33. target.addAttribute("scrollbarVisibility", scrollbarVisibility);
  34. }
  35. /**
  36. * The user can specify a background gradient for the coverflow. The input
  37. * values are RGB values for the start and end gradients.
  38. *
  39. * @param int startR
  40. * @param int startG
  41. * @param int startB
  42. * @param int endR
  43. * @param int endG
  44. * @param int endB
  45. */
  46. public void setBackgroundColor(int startR, int startG, int startB,
  47. int endR, int endG, int endB) {
  48. backgroundGradientStart = "";
  49. backgroundGradientEnd = "";
  50. // Convert all integers to hexadecimal format and make sure they are two
  51. // characters long (in other words, add a zero in front if the value is
  52. // less than 16 => 0x0F)
  53. if (startR < 16) {
  54. backgroundGradientStart += "0";
  55. }
  56. backgroundGradientStart += Integer.toHexString(Math.max(Math.min(
  57. startR, 255), 0));
  58. if (startG < 16) {
  59. backgroundGradientStart += "0";
  60. }
  61. backgroundGradientStart += Integer.toHexString(Math.max(Math.min(
  62. startG, 255), 0));
  63. if (startB < 16) {
  64. backgroundGradientStart += "0";
  65. }
  66. backgroundGradientStart += Integer.toHexString(Math.max(Math.min(
  67. startB, 255), 0));
  68. if (endR < 16) {
  69. backgroundGradientEnd += "0";
  70. }
  71. backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endR,
  72. 255), 0));
  73. if (endG < 16) {
  74. backgroundGradientEnd += "0";
  75. }
  76. backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endG,
  77. 255), 0));
  78. if (endB < 16) {
  79. backgroundGradientEnd += "0";
  80. }
  81. backgroundGradientEnd += Integer.toHexString(Math.max(Math.min(endB,
  82. 255), 0));
  83. requestRepaint();
  84. }
  85. /**
  86. * The user can toggle the visibility of the scrollbar
  87. *
  88. * @param boolean visible
  89. */
  90. public void setScrollbarVisibility(boolean visible) {
  91. if (scrollbarVisibility != visible) {
  92. scrollbarVisibility = visible;
  93. requestRepaint();
  94. }
  95. }
  96. }