Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Peter Cheung Newsgroups: comp.lang.java.programmer Subject: Re: JOutlookBar Date: Sat, 28 Apr 2012 03:10:30 -0700 (PDT) Organization: http://groups.google.com Lines: 114 Message-ID: <32783489.320.1335607830761.JavaMail.geo-discussion-forums@pbbpz9> References: <33049662.264.1335479370702.JavaMail.geo-discussion-forums@pbcnk4> <15997725.898.1335482389670.JavaMail.geo-discussion-forums@pbbps5> <7588566.806.1335496661608.JavaMail.geo-discussion-forums@pbqv7> <29372748.3.1335559861001.JavaMail.geo-discussion-forums@pbfk7> NNTP-Posting-Host: 210.5.164.14 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1335607831 13794 127.0.0.1 (28 Apr 2012 10:10:31 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sat, 28 Apr 2012 10:10:31 +0000 (UTC) In-Reply-To: <29372748.3.1335559861001.JavaMail.geo-discussion-forums@pbfk7> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=210.5.164.14; posting-account=10LjMwkAAAAVcy8G3B3qqGRpk0olXjxD User-Agent: G2/1.0 Xref: csiph.com comp.lang.java.programmer:13961 Lew=E6=96=BC 2012=E5=B9=B44=E6=9C=8828=E6=97=A5=E6=98=9F=E6=9C=9F=E5=85=ADU= TC+8=E4=B8=8A=E5=8D=884=E6=99=8251=E5=88=8600=E7=A7=92=E5=AF=AB=E9=81=93=EF= =BC=9A > markspace wrote: > > Daniel Pitts wrote: > >> Peter Cheung wrote: > >>> I already set it to 1ms, but it still runs slowly. > >>> > >>> So the animation is not smooth. > >=20 > >=20 > >> You're timer simply calls draw. Also, 1ms is really too fast, and will > >> cause more harm than good. You should aim for closer to 30hz->60hz. Tr= y > >> around 33ms timer. > >=20 > >=20 > > I happen to know a little about animation (graphics is a personal hobby= =20 > > of mine). The gold standard in animation is 25 frames per second, or 4= 0=20 > > ms in between frames. > >=20 > > However, as a practical matter, much lower frames rates are acceptable.= =20 > > Some cheaper animation, like some of the early so-called=20 > > "japanimation," used as little as 4 or 6 frames per second in parts of= =20 > > their work. > >=20 > > I'd start at 250 ms. 1 ms will clearly overwhelm any normal desktop=20 > > system with too much work. Get 250 ms working, then see if it can be= =20 > > improved. > >=20 > >=20 > >> Ideally, the "work" for your animation should be done in the timer > >> handler too (so that your state changes on the timer, not just a redra= w). > >=20 > > This. > >=20 > > Peter, what I've looked at in your code base is pretty bad. Most of it= =20 > > is really ugly generated code. Nothing has comments. There's no test= =20 > > harness that I saw. You need to slow down and write some code by hand,= =20 > > try to understand what is really going on. One good class is better=20 > > than 100 cruddy classes, and it is certainly my impression that the=20 > > latter is what you have. >=20 > Looking at this part of your code, Peter: >=20 > public class OutlookBarLayout implements LayoutManager2, java.io.Serializ= able, ActionListener=20 >=20 > // Why not import Serializable? > // Where is the 'serialVersionUID'? >=20 > { > public Hashtable components =3D new Hashtable<= String, Component>(); >=20 > // Don't use Hashtable >=20 > public int buttonHeight =3D 31; > private int separatorHeight =3D 8; >=20 > private int totalHeight; > private int noOfButtonLeft; > private int top; > private int left; >=20 > // bad scope, AFAICT, should be a local variable - how is this part of th= e instance state? >=20 > private int right; > private Timer timer =3D new Timer(1, this); >=20 > // Shouldn't this be 'final'? >=20 > private Container target; > private int currentY; >=20 > public OutlookBarLayout() { > } > ...=20 >=20 > You don't need to specify a no-argument, empty constructor. >=20 > Where are your Javadoc comments? >=20 > Have you gone over every line of this class and gained comprehension of w= hat it does? >=20 > Please answer the questions in detail. >=20 > --=20 > Lew I don't have any javadoc, all the documents I wrote are in here http://code= .google.com/p/peter-swing/w/list I use Jigloo plugins to generate the UI code for pas few years, comfortable= with it and I usually won't review the generated-code.=20 I was a traditional-java-programmer, I write all swing code by myself and d= idn't use any plugins to generate code. But now I changed, I use plugin to = generate UI code. I don't care much about the generated-code by Jigloo plug= in, if it works, everything fine to me. peter-swing's components and theme seems working, so i don't brother jigloo= 's code.