Posted By

jerryvig on 07/07/12


Tagged

example gwt Animations


Versions (?)

Easy GWT Animations


 / Published in: Java
 

An example for how to do animations using the GWT framework.

  1. public void updateHighlightPanels( double widgetWidth ) {
  2. lager.log(Level.SEVERE, "in updateHighlightPanels()");
  3. double highlightLeft = Double.parseDouble( focusPanel.getElement().getStyle().getLeft().replace("px","") );
  4.  
  5. BarAnimation topAnim = new BarAnimation( topHighlightPanel.getElement(),
  6. Double.parseDouble(topHighlightPanel.getElement().getStyle().getWidth().replace("px","")),
  7. widgetWidth,
  8. Double.parseDouble(topHighlightPanel.getElement().getStyle().getLeft().replace("px","")),
  9. highlightLeft );
  10. BarAnimation bottomAnim = new BarAnimation( bottomHighlightPanel.getElement(),
  11. Double.parseDouble(bottomHighlightPanel.getElement().getStyle().getWidth().replace("px","")),
  12. widgetWidth,
  13. Double.parseDouble(bottomHighlightPanel.getElement().getStyle().getLeft().replace("px","")),
  14. highlightLeft );
  15.  
  16. topAnim.run(600);
  17. bottomAnim.run(600);
  18. }
  19.  
  20. public void updateModuleDivPositions() {
  21.  
  22. }
  23. }
  24.  
  25. private class BarAnimation extends Animation {
  26. private final Element e;
  27. private double widthStart;
  28. private double widthStop;
  29. private double leftStart;
  30. private double leftStop;
  31.  
  32. public BarAnimation( Element _e, double _widthStart, double _widthStop, double _leftStart, double _leftStop ) {
  33. e = _e;
  34. widthStart = _widthStart;
  35. widthStop = _widthStop;
  36. leftStart = _leftStart;
  37. leftStop = _leftStop;
  38. }
  39.  
  40. @Override
  41. protected void onUpdate(double prog) {
  42. double width = widthStart+(widthStop-widthStart)*prog;
  43. double left = leftStart+(leftStop-leftStart)*prog;
  44. e.getStyle().setWidth(width, Style.Unit.PX);
  45. e.getStyle().setLeft(left,Style.Unit.PX);
  46. }
  47. }

Report this snippet  

You need to login to post a comment.