Guest User

Untitled

a guest
Jun 2nd, 2014
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package xenustreet.gui.control;
  6.  
  7. import com.jme3.math.Vector2f;
  8. import com.jme3.math.Vector4f;
  9. import tonegod.gui.controls.scrolling.ScrollArea;
  10. import tonegod.gui.controls.scrolling.VScrollBar;
  11. import tonegod.gui.core.Element;
  12. import tonegod.gui.core.ElementManager;
  13. import tonegod.gui.core.utils.UIDUtil;
  14.  
  15. /**
  16. *
  17. * @author root
  18. */
  19. public abstract class ScrollableRepeator extends ScrollArea {
  20. private float scrollBottom = 0;
  21.  
  22. public ScrollableRepeator(ElementManager screen, Vector2f position) {
  23. super(screen, position, false);
  24. }
  25.  
  26. public ScrollableRepeator(ElementManager screen, Vector2f position, Vector2f dimensions) {
  27. super(screen, position, dimensions, false);
  28. }
  29.  
  30. public ScrollableRepeator(ElementManager screen, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
  31. super(screen, position, dimensions, resizeBorders, defaultImg, false);
  32. }
  33.  
  34. public ScrollableRepeator(ElementManager screen, String UID, Vector2f position) {
  35. super(screen, UID, position, false);
  36. }
  37.  
  38. public ScrollableRepeator(ElementManager screen, String UID, Vector2f position, Vector2f dimensions) {
  39. super(screen, UID, position, dimensions, false);
  40. }
  41.  
  42. public ScrollableRepeator(ElementManager screen, String UID, Vector2f position, Vector2f dimensions, Vector4f resizeBorders, String defaultImg) {
  43. super(screen, UID, position, dimensions, resizeBorders, defaultImg, false);
  44. }
  45.  
  46. /**
  47. * adds a child to the scrollable repeator, modifying it to fit.
  48. * @param child
  49. */
  50. @Override
  51. public void addScrollableChild(Element child) {
  52. VScrollBar vSC = getVScrollBar();
  53. Vector2f childDimensions = child.getDimensions();
  54. float ratio = this.getScrollableArea().getWidth() / childDimensions.x;
  55. float height = childDimensions.y * ratio;
  56. child.setDimensions(childDimensions.x * ratio, height);
  57. child.setPosition(new Vector2f(0f, scrollBottom));
  58. scrollBottom += child.getHeight();
  59. super.addScrollableChild(child);
  60. }
  61.  
  62.  
  63. }
Advertisement
Add Comment
Please, Sign In to add comment