JOutlookBar

P

Peter Cheung


how to make swing timer run faster? I use swing timer to draw the animation, but it runs slowly.
 
L

Lew

how to make swing [sic] timer run faster?
I use swing [sic] timer to draw the animation, but it runs slowly.

Please provide code.

Best is to prepare a Simple, Self-Contained Compilable Example.
http://sscce.org/

Unless you show us the code, here in the newsgroup, in an example that isolates the issue, it can be difficult to diagnose your problem.

I would need to see how you're using the timer now to see what might be wrong. It could be a concurrency issue, or you might be running other things on the Event Dispatch Thread (EDT) that you shouldn't, there might be other demands on the system (e.g., from the video recording software), or you simply might not have enough computing power to run it faster.

The solutions for those issues, if any of them pertain, is to make your code thread-safe, take things off the EDT, shut down other software and services while you record your video, or use a faster computer, respectively.
 
P

Peter Cheung

Lewæ–¼ 2012å¹´4月27日星期五UTC+8上åˆ7時19分49秒寫é“:
how to make swing [sic] timer run faster?
I use swing [sic] timer to draw the animation, but it runs slowly.

Please provide code.

Best is to prepare a Simple, Self-Contained Compilable Example.
http://sscce.org/

Unless you show us the code, here in the newsgroup, in an example that isolates the issue, it can be difficult to diagnose your problem.

I would need to see how you're using the timer now to see what might be wrong. It could be a concurrency issue, or you might be running other thingson the Event Dispatch Thread (EDT) that you shouldn't, there might be other demands on the system (e.g., from the video recording software), or you simply might not have enough computing power to run it faster.

The solutions for those issues, if any of them pertain, is to make your code thread-safe, take things off the EDT, shut down other software and services while you record your video, or use a faster computer, respectively.

The Swing timer is in here:
http://code.google.com/p/peter-swin...dvancedswing/outlookbar/OutlookBarLayout.java

I already set it to 1ms, but it still runs slowly.

So the animation is not smooth.

thanks
 
D

Daniel Pitts

Lewæ–¼ 2012å¹´4月27日星期五UTC+8上åˆ7時19分49秒寫é“:
how to make swing [sic] timer run faster?
I use swing [sic] timer to draw the animation, but it runs slowly.

Please provide code.

Best is to prepare a Simple, Self-Contained Compilable Example.
http://sscce.org/

Unless you show us the code, here in the newsgroup, in an example that isolates the issue, it can be difficult to diagnose your problem.

I would need to see how you're using the timer now to see what might be wrong. It could be a concurrency issue, or you might be running other things on the Event Dispatch Thread (EDT) that you shouldn't, there might be other demands on the system (e.g., from the video recording software), or you simply might not have enough computing power to run it faster.

The solutions for those issues, if any of them pertain, is to make your code thread-safe, take things off the EDT, shut down other software and services while you record your video, or use a faster computer, respectively.

The Swing timer is in here:
http://code.google.com/p/peter-swin...dvancedswing/outlookbar/OutlookBarLayout.java

I already set it to 1ms, but it still runs slowly.

So the animation is not smooth.

thanks

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. Try
around 33ms timer.

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 redraw).
 
M

markspace

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. Try
around 33ms timer.


I happen to know a little about animation (graphics is a personal hobby
of mine). The gold standard in animation is 25 frames per second, or 40
ms in between frames.

However, as a practical matter, much lower frames rates are acceptable.
Some cheaper animation, like some of the early so-called
"japanimation," used as little as 4 or 6 frames per second in parts of
their work.

I'd start at 250 ms. 1 ms will clearly overwhelm any normal desktop
system with too much work. Get 250 ms working, then see if it can be
improved.

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 redraw).


This.

Peter, what I've looked at in your code base is pretty bad. Most of it
is really ugly generated code. Nothing has comments. There's no test
harness that I saw. You need to slow down and write some code by hand,
try to understand what is really going on. One good class is better
than 100 cruddy classes, and it is certainly my impression that the
latter is what you have.
 
L

Lew

markspace said:
I happen to know a little about animation (graphics is a personal hobby
of mine). The gold standard in animation is 25 frames per second, or 40
ms in between frames.

However, as a practical matter, much lower frames rates are acceptable.
Some cheaper animation, like some of the early so-called
"japanimation," used as little as 4 or 6 frames per second in parts of
their work.

I'd start at 250 ms. 1 ms will clearly overwhelm any normal desktop
system with too much work. Get 250 ms working, then see if it can be
improved.



This.

Peter, what I've looked at in your code base is pretty bad. Most of it
is really ugly generated code. Nothing has comments. There's no test
harness that I saw. You need to slow down and write some code by hand,
try to understand what is really going on. One good class is better
than 100 cruddy classes, and it is certainly my impression that the
latter is what you have.

Looking at this part of your code, Peter:

public class OutlookBarLayout implements LayoutManager2, java.io.Serializable, ActionListener

// Why not import Serializable?
// Where is the 'serialVersionUID'?

{
public Hashtable<String, Component> components = new Hashtable<String, Component>();

// Don't use Hashtable

public int buttonHeight = 31;
private int separatorHeight = 8;

private int totalHeight;
private int noOfButtonLeft;
private int top;
private int left;

// bad scope, AFAICT, should be a local variable - how is this part of the instance state?

private int right;
private Timer timer = new Timer(1, this);

// Shouldn't this be 'final'?

private Container target;
private int currentY;

public OutlookBarLayout() {
}
....

You don't need to specify a no-argument, empty constructor.

Where are your Javadoc comments?

Have you gone over every line of this class and gained comprehension of what it does?

Please answer the questions in detail.
 
P

Peter Cheung

markspaceæ–¼ 2012å¹´4月28日星期六UTC+8上åˆ3時33分00秒寫é“:
I happen to know a little about animation (graphics is a personal hobby
of mine). The gold standard in animation is 25 frames per second, or 40
ms in between frames.

However, as a practical matter, much lower frames rates are acceptable.
Some cheaper animation, like some of the early so-called
"japanimation," used as little as 4 or 6 frames per second in parts of
their work.

I'd start at 250 ms. 1 ms will clearly overwhelm any normal desktop
system with too much work. Get 250 ms working, then see if it can be
improved.




This.

Peter, what I've looked at in your code base is pretty bad. Most of it
is really ugly generated code. Nothing has comments. There's no test
harness that I saw. You need to slow down and write some code by hand,
try to understand what is really going on. One good class is better
than 100 cruddy classes, and it is certainly my impression that the
latter is what you have.

I changed to use Runnable, animation become smooth now.
I use Jigloo plugins to generate UI code, I am happy with that plugin and its generated code, so I would like to stay with it. thanks
 
P

Peter Cheung

Lewæ–¼ 2012å¹´4月28日星期六UTC+8上åˆ4時51分00秒寫é“:
Looking at this part of your code, Peter:

public class OutlookBarLayout implements LayoutManager2, java.io.Serializable, ActionListener

// Why not import Serializable?
// Where is the 'serialVersionUID'?

{
public Hashtable<String, Component> components = new Hashtable<String, Component>();

// Don't use Hashtable

public int buttonHeight = 31;
private int separatorHeight = 8;

private int totalHeight;
private int noOfButtonLeft;
private int top;
private int left;

// bad scope, AFAICT, should be a local variable - how is this part of the instance state?

private int right;
private Timer timer = new Timer(1, this);

// Shouldn't this be 'final'?

private Container target;
private int currentY;

public OutlookBarLayout() {
}
...

You don't need to specify a no-argument, empty constructor.

Where are your Javadoc comments?

Have you gone over every line of this class and gained comprehension of what it does?

Please answer the questions in detail.

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, comfortablewith it and I usually won't review the generated-code.

I was a traditional-java-programmer, I write all swing code by myself and didn'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 plugin, if it works, everything fine to me.

peter-swing's components and theme seems working, so i don't brother jigloo's code.
 
A

Arne Vajhøj

Lewæ–¼ 2012å¹´4月28日星期六UTC+8上åˆ4時51分00秒寫é“:
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.

I was a traditional-java-programmer, I write all swing code by myself
and didn'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 plugin, if it works, everything fine to me.

But it did not work.

In which case you should actually read your code before
asking other people to read the code.

Arne
 
D

Daniel Pitts

I use Jigloo plugins to generate UI code, I am happy with that plugin and its generated code, so I would like to stay with it. thanks

I read that as "I have no idea what I'm really doing, and I'm happy with
that."

God help me if I ever become that willfully ignorant.
 
L

Lew

I read that as "I have no idea what I'm really doing, and I'm happy with that."

God help me if I ever become that willfully ignorant.

It seems unlikely in your case.

Peter, Daniel raises an important point that will help you if you take it. The
art of programming requires learning, and not superstition. If you don't know
what Jigloo does, and others have pointed out that it isn't working, then you
are helpless and powerless.

You also completely avoid the issue of the lack of documentation, the
plagiarism which turns out not even to be necessary in the first place, and
the general lack of utility of the project. These are serious issues, and
resolving them will go a long way to making you a good programmer.

Refusing to resolve them, and taking the sort of negative attitude towards the
universal advice you're receiving, are bad habits and will destroy your
capabilities.

Just sayin' ...
 
P

Peter Cheung

Lewæ–¼ 2012å¹´4月29日星期日UTC+8下åˆ12時08分46秒寫é“:
It seems unlikely in your case.

Peter, Daniel raises an important point that will help you if you take it.. The
art of programming requires learning, and not superstition. If you don't know
what Jigloo does, and others have pointed out that it isn't working, thenyou
are helpless and powerless.

You also completely avoid the issue of the lack of documentation, the
plagiarism which turns out not even to be necessary in the first place, and
the general lack of utility of the project. These are serious issues, and
resolving them will go a long way to making you a good programmer.

Refusing to resolve them, and taking the sort of negative attitude towards the
universal advice you're receiving, are bad habits and will destroy your
capabilities.

Just sayin' ...

Thanks, let me finish my project first.
 
P

Peter Cheung

Peter Cheungæ–¼ 2012å¹´4月29日星期日UTC+8下åˆ3時13分55秒寫é“:
Lewæ–¼ 2012å¹´4月29日星期日UTC+8下åˆ12時08分46秒寫é“:

Thanks, let me finish my project first.

why people in the forum look like angering something on me?
 
L

Lew

Peter said:
why people in the forum look like angering something on me?

There are several reasons, and it's a fair question.

In the first place, I doubt that anyone is actually angry with you. There is a
difference between harshness and anger, although few people pay attention to
the difference. You have triggered some harsh reactions, but people really are
trying to impart information to help you. The thing you do right is to engage
with the conversation, to keep responding to people and trying to understand.
As long as you do that no one should actually be angry with you.

What people have been telling you is important information. There are high
standards to professional programming, and they are rigorous. Early on you
showed some resistance to the information people gave you. This is especially
important in the area of ethics, which you violated. Besides that, you did not
respond to the comments regarding engineering flaws in your code. Your
responses to other comments, namely the lack of Javadocs and a build script,
were dismissive and constituted little more than, "I'm not doing that." We
know you're not doing that, we pointed out that you're not doing that. More
importantly we pointed out that you should be doing that, advice that you
ignore at your own cost.

Basically you have not shown interest in the wisdom and expertise that the
several very smart and knowledgeable people like Patricia Shanahan, Daniel
Pitts, markspace and Arne Vajhøj, to name a few, have shared. You don't give
reasons or logic for your decisions. You seem unaware and uninterested in
respect for copyrights. Instead of taking coding advice, you say, "Let me
finish my project," indicating that you are going to follow bad code with even
more bad code.

So people aren't so much angry with you as contemptuous of your behavior. Not
of you, necessarily - I cannot imagine Ms. Dr. Shanahan showing less than
exquisite courtesy and respect to any human being, for example - but certainly
of actions that will harm your ability to put together good software.

It's not good to be emotional or defensive about one's work in this business.
The results have to work, and work in accordance with expectations. That is
what it is beyond all wishing or superstition or resistance to brutally honest
advice. Take the advice - respect for your behavior is far less important than
success in software development. Following the advice of those wiser in this
arena will lead to both.
 
P

Peter Cheung

Lewæ–¼ 2012å¹´4月29日星期日UTC+8下åˆ4時56分50秒寫é“:
There are several reasons, and it's a fair question.

In the first place, I doubt that anyone is actually angry with you. Thereis a
difference between harshness and anger, although few people pay attentionto
the difference. You have triggered some harsh reactions, but people really are
trying to impart information to help you. The thing you do right is to engage
with the conversation, to keep responding to people and trying to understand.
As long as you do that no one should actually be angry with you.

I cannot really identify harshness/anger from english text, english is not my first language.
What people have been telling you is important information. There are high
standards to professional programming, and they are rigorous. Early on you
showed some resistance to the information people gave you. This is especially
important in the area of ethics, which you violated. Besides that, you did not
respond to the comments regarding engineering flaws in your code. Your
responses to other comments, namely the lack of Javadocs and a build script,
were dismissive and constituted little more than, "I'm not doing that." We
know you're not doing that, we pointed out that you're not doing that. More
importantly we pointed out that you should be doing that, advice that you
ignore at your own cost.

There is only one developer to develop peter-swing, yes, its me. The primary goal for peter-swing is to make a new theme for my other project http://code.google.com/p/peter-bochs/ . If it is working, i don't want to spend time on writing comment, i would like to spend time on peter-bochs rather.

I really don't need a build script, because eclipse can build. Eclipse can build a executable jar, it is enough for me. I don't know how hurt is my sentence "I'm not doing that", but in chinese, that sentence is not a offensive sentence.
But the words "Wow, shame on you, Peter", it is very offensive in my point of view.
Basically you have not shown interest in the wisdom and expertise that the
several very smart and knowledgeable people like Patricia Shanahan, Daniel
Pitts, markspace and Arne Vajhøj, to name a few, have shared. You don't give
reasons or logic for your decisions. You seem unaware and uninterested in
respect for copyrights. Instead of taking coding advice, you say, "Let me
finish my project," indicating that you are going to follow bad code witheven
more bad code.

I create components and theme for people use, that is the only wisdom i have in peter-swing project. If you think peter-swing project is bad enough, just leave it.
I really didn't steal somebody code, The class metalbump in my project, actually I don't use it. I have removed it.
 
L

Lew

Peter said:
There is only one developer to develop peter-swing, yes, its me.
The primary goal for peter-swing is to make a new theme for my other project ...
If it is working, i don't want to spend time on writing comment,
i would like to spend time on peter-bochs rather.

And yet you told the public about it.

Do you steal code for your other project, too?

Why did you feel the need to copy a class that was already present anyway?
I've asked this question several times and you've *never* answered.
I really don't need a build script, because eclipse can build. Eclipse can build a executable jar, it is enough for me. I don't know how hurt is my sentence "I'm not doing that", but in chinese, that sentence is not a offensive sentence.
But the words "Wow, shame on you, Peter", it is very offensive in my point of view.

If you think you are wiser than everyone who's answered you here to where you
can reject our advice out of hand, that's fine, but understand that the odds
are against that judgment.

As for being offended, get over yourself. We're here to make each other a
better programmer, and nobody has insulted you here, so leave your ego out of
it. Besides, if anyone in this discussion has offered offense it's been you
for dismissing our advice, failing to respond to our question, avoiding
responsibility, and resorting to acting aggrieved when the appropriate
response should have been dispassionate. If you earn the "Shame on you,
Peter", how is that offensive? You have done things that deserve the
criticism, objectively deserve it, and shown no sign whatsoever of remorse for
it. You should be ashamed of those behaviors. So rather than be offended, you
should be grateful for the honesty and respect that people have shown in
giving you the truth.

Take the advice offered here, and do not be a namby-pamby.
 
A

Arne Vajhøj

Peter Cheungæ–¼ 2012å¹´4月29日星期日UTC+8下åˆ3時13分55秒寫é“:

why people in the forum look like angering something on me?

Most developers do not like copyright violations.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top