Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problem with Timer object

3 views
Skip to first unread message

tkt...@gmail.com

unread,
Sep 21, 2008, 12:20:42 PM9/21/08
to
Hi bros. I am encountering with a problem about Timer .
I am simulating a elevator using Java GUI . My elevator includes an
rectangular elevator and a ButtonPanel (an array of buttons which
indicate the floors ) . The elevator runs up and down between the
storeys . What i want is when i press a button in the buttonPanel ie
button number 5 , the elevator will stop when it reachs storey 5 for
an amount of time and continue moving after that . I use timer but the
elevator can't stop .Here is the code .please help me . Thanks in
advance .


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;

//The main class
public class Elevator_Simulation extends JFrame{
public JLabel state; // display the state of the elevator
private JLabel id; //your name and group
public ButtonPanel control; //the button control panel
private Elevator elevator; // the elevator area
private final int width = 400;
private final int height = 500;
public Container elevatorPanel;
private int delay ;

//constructor
public Elevator_Simulation() {
// Create GUI
setTitle("Elvator Simulation");
setSize(width,height);
setVisible(true);
setDefaultCloseOperation(EXIT_ON_CLOSE); buildPanel();
elevator = new Elevator(this);
elevator.beginOperation();

}

public void buildPanel(){
id = new JLabel("MyName SE6",JLabel.CENTER);
elevatorPanel = getContentPane();
control = new ButtonPanel();
elevatorPanel.setLayout(new BorderLayout());
elevatorPanel.add(control,BorderLayout.WEST);
elevatorPanel.add(id,BorderLayout.NORTH);
}
....
// Main method
public static void main(String[] args) throws InterruptedException{
// Create a frame and display it
new Elevator_Simulation();
}

} //the end of Elevator_Simulation class

// The elevator class draws the elevator area and simulates elevator
movement

class Elevator extends JPanel implements ActionListener {
// parameters ....
private Timer tm ;
private final int delay = 200 ;
final private int speed = 40 ;

private Elevator_Simulation app;
// Paint elevator area

public Elevator(Elevator_Simulation app){
// set the parameters of the elevator
}
public void beginOperation(){
tm = new Timer(delay/speed,this);
tm.start();
}
public void paintComponent(Graphics g) {
// paint the elevator
}

//Handle the timer events
public void actionPerformed(ActionEvent e) {
tm.setDelay(delay/speed);
height = getHeight()/8;
int curFloor = 7-yco/height ;
if (yco % height == 0 && app.control.bp[curFloor])
{
tm.stop();
new Pause();
tm.start();
app.control.restoreButtonState(curFloor);
}
.....
}

// i use this class to pause the elevator
class Pause implements ActionListener
{
Timer tmpTimer ;
int times;
public Pause(){
int delayTime = (delay*50)/speed; tmpTimer = new
Timer(delayTime,this); times = 1;
}
public void actionPerformed(ActionEvent e) {
if (times==2){
tmpTimer.stop();
}
else times++;
}
}
} // end of the elevator class

John B. Matthews

unread,
Sep 21, 2008, 5:27:06 PM9/21/08
to
In article
<a2505f0b-b930-4c39...@25g2000prz.googlegroups.com>,
tkt...@gmail.com wrote:
[...]
> I am encountering a problem [with] Timer. I am simulating an elevator
> using Java GUI. My elevator includes a rectangular elevator and a
> ButtonPanel (an array of buttons[,] which indicate the floors). The
> elevator runs up and down between the stor[ie]s. [Here is] what [I]
> want: when [I] press a button in the buttonPanel, i.e. button number
> 5, the elevator will stop when it reachs story 5 for [a short] time
> and continue moving after that. I use [T]imer, but the elevator
> [wo]n't stop. Here is the code. [P]lease help me. Thanks in advance.
[...]

I can't follow your code, partly because it's incomplete:

<http://pscode.org/sscce.html>

Your pause() method appears to use another Timer to create a delay. As
Timer runs asynchronously, no delay will be apparent. One Timer instance
should be enough.

Instead, have your action listener invoke your painting method to draw
the elevator at the current floor and then increment the value of
curFloor. Adjust the Timer's delay to change the speed of the elevator.
When curFloor == destFloor, change the Timer's initial delay and invoke
restart() to make it stay on destFloor longer.

Here's more information on javax.swing.Timer:

<http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html>

--
John B. Matthews
trashgod at gmail dot com
home dot woh dot rr dot com slash jbmatthews

Knute Johnson

unread,
Sep 21, 2008, 9:43:04 PM9/21/08
to
tkt...@gmail.com wrote:
> Hi bros. I am encountering with a problem about Timer .
> I am simulating a elevator using Java GUI . My elevator includes an
> rectangular elevator and a ButtonPanel (an array of buttons which
> indicate the floors ) . The elevator runs up and down between the
> storeys . What i want is when i press a button in the buttonPanel ie
> button number 5 , the elevator will stop when it reachs storey 5 for
> an amount of time and continue moving after that . I use timer but the
> elevator can't stop .Here is the code .please help me . Thanks in
> advance .

Your code is a mess and I can't tell what you are up to with that.

But I will give you some direction, I would go at the basic design in
the following general method.

Set up a drawing timer that just draws the building and the elevators
every few milliseconds (30 frames per second is a good rate). Then
based upon the calls I would calculate the locations of the elevators so
that they were painted in the correct position the next time a paint
event happened.

Elevator algorithms are fairly complex so you will probably need some
simplified control code. I don't know if there are any algorithms
published anywhere for elevator management.

--

Knute Johnson
email s/nospam/knute2008/

--
Posted via NewsDemon.com - Premium Uncensored Newsgroup Service
------->>>>>>http://www.NewsDemon.com<<<<<<------
Unlimited Access, Anonymous Accounts, Uncensored Broadband Access

tomaszewski.p

unread,
Sep 21, 2008, 11:51:44 PM9/21/08
to
On 21 Wrz, 18:20, tkt...@gmail.com wrote:
> Hi bros. I am encountering with a problem about Timer .
> I am simulating a elevator using Java GUI . My elevator includes an
> rectangular elevator and a ButtonPanel (an array of buttons which
> indicate the floors ) . The elevator runs up and down between the
> storeys . What i want is when i press a button in the buttonPanel ie
> button number 5 , the elevator will stop when it reachs storey 5 for
> an amount of time and continue moving after that . I use timer but the
> elevator can't stop .Here is the code .please help me . Thanks in
> advance .
>
[...]

>  } // end of the elevator class

Doing it as Knute Johnson has written in his post is good idea.
To help you with timers, I have written small snippet:

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

public class SwingTimerTest {
static class TestPanel extends JPanel implements ActionListener{
private static final int MOVE_DELAY = 2000;
private static final int PAUSE_DELAY = 500;

enum Mode {
MOVE,
PAUSE
}

private Timer timer;
private Mode mode;

public TestPanel() {
super();
JButton runButton = new JButton("Run");
runButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
runTest();
}
});
add(runButton);
}

@Override
public void actionPerformed(ActionEvent event) {
switch (mode) {
case MOVE:
System.out.println("Pauses...");
mode = Mode.PAUSE;
timer.setInitialDelay(PAUSE_DELAY);
timer.start();
break;
case PAUSE:
System.out.println("Moves...");
mode = Mode.MOVE;
timer.setInitialDelay(MOVE_DELAY);
timer.start();
break;
}
}

private void runTest() {
mode = Mode.MOVE;
timer = new Timer(MOVE_DELAY, this);
timer.setRepeats(false);
timer.start();
}
}

public static void main(String[] args) {
TestPanel panel = new TestPanel();
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(panel);
frame.pack();
frame.setVisible(true);
}
}

Przmek

tkt...@gmail.com

unread,
Sep 22, 2008, 11:24:58 AM9/22/08
to
Hi , Sorry for that mess . I use tab and space when I typed the code
into the Google window and at the end it displayed like that . My
problem is how to pause the elevator when it reachs a chosen floor
(picked by pressing one button on the button panel). My idea is to
use another Pause( contains another timer ) class to do this . When
the current floor is the destination floor , I use this code segment

tm.stop();
new Pause(); // call the pause so that the elevator will pause
for a short time
tm.start(); // restart Timer tm so that the elevator continues
running
but it doesn't work . This afternoon when i passed tm into Pause
That means new Pause(Timer tm) and restart the tm inside Pause's
actionPerformed it surprisingly worked . The elevator could pause.
That maked me confused .
I post all of my code here . Thank all for your help and advice .

}

public ButtonPanel getButtonPanel(){
return control ;
}

// Main method
public static void main(String[] args) {


// Create a frame and display it
new Elevator_Simulation();
}

} //the end of Elevator_Simulation class


public class Elevator extends JPanel implements ActionListener {
private boolean up ; // the elevator is moving up or down
private int width; // Elevator width
private int height; // Elevator height
private int xco; // The x coordinate of the elevator's
upper left corner
private int yco; // The y coordinate of the elevator's
upper left corner
private int dy0; // Moving interval
private int topy; //the y coordinate of the top level
private int bottomy; // the y coordinate of the bottom level
public Timer tm; //the timer to drive the elevator movement


private final int delay = 200 ;

private int speed = 40 ;

private Elevator_Simulation app;
// Paint elevator area

public Elevator(Elevator_Simulation app){
setSize(300,400);
dy0 = 1 ;
bottomy = getHeight()*7/8;
yco = bottomy;
this.app = app ;
up = true;


}
public void beginOperation(){
tm = new Timer(delay/speed,this);
tm.start();
}
public void paintComponent(Graphics g) {

super.paintComponent(g);
width = getWidth()/8;
height =getHeight()/8;
for (int i=0;i<=8;i++){
g.drawLine(0,height*i,width*8,height*i);
}
xco = getWidth()/2;


g.setColor(Color.black);
g.drawRect(xco,yco,width,height);
g.drawLine(xco+width/2,yco,xco+width/2,yco+height);
app.getContentPane().add(this,BorderLayout.CENTER);
app.setVisible(true);
}

//Handle the timer events
public void actionPerformed(ActionEvent e) {
tm.setDelay(delay/speed);
height = getHeight()/8;
int curFloor = 7-yco/height ;

// Check if the curFloor == the destFloor


if (yco % height == 0 && app.control.bp[curFloor])
{
tm.stop();
new Pause();
tm.start();

app.getButtonPanel().restoreButtonState(curFloor);
}
if (up){
if (yco>=dy0)
yco -=dy0;
else up=false ;
}
else {
if (yco<(getHeight()*7/8-dy0))
yco +=dy0;
else up=true;
}
repaint();
app.elevatorPanel.add(this,BorderLayout.CENTER);
app.setVisible(true);
}


class Pause implements ActionListener
{
Timer tmpTimer ;
int times;
public Pause(){

int delayTime = delay/speed*50;
tmpTimer = new Timer(delayTime,this);
tmpTimer.start();
times = 1;
}

public void actionPerformed(ActionEvent e) {
if (times==2){ tmpTimer.stop();
}
else times++;
}
}
}

public class ButtonPanel extends JPanel {
public JButton b[] = new JButton[8]; // 8 Buttons
public boolean bp[] = new boolean[8]; // the state of
buttons, pressed or not

//constructor
public ButtonPanel() {
//create GUI
GridLayout gLayout = new GridLayout(8,1);
setLayout(gLayout);
for (int i=7;i>=0;i--) {
b[i] = new JButton("Storey "+(i+1));
b[i].addActionListener(new ButtonAction());
add(b[i]);
bp[i]= false;
}
}

public void restoreButtonState(int i){
bp[i] = false;
b[i].setBackground(Color.white);
}

class ButtonAction extends JFrame implements ActionListener{
public void actionPerformed(ActionEvent e) {
//handle the button pressing events
JButton button = (JButton)e.getSource();
button.setBackground(Color.red);
String actionCommand = e.getActionCommand();
int num =
Integer.parseInt(actionCommand.charAt(actionCommand.length()-1)+"");
bp[num-1] = true;

}
}
} //the end of ButtonPanel class

John B. Matthews

unread,
Sep 22, 2008, 1:40:14 PM9/22/08
to
In article
<f8171d0e-bd94-45a9...@z6g2000pre.googlegroups.com>,
tkt...@gmail.com wrote:

> Hi , Sorry for that mess . I use tab and space when I typed the code
> into the Google window and at the end it displayed like that . My
> problem is how to pause the elevator when it reachs a chosen floor
> (picked by pressing one button on the button panel). My idea is to
> use another Pause( contains another timer ) class to do this . When

> the current floor is the destination floor, I use this code segment
>
> tm.stop();
> new Pause();
> tm.start();


>
> but it doesn't work . This afternoon when i passed tm into Pause That
> means new Pause(Timer tm) and restart the tm inside Pause's
> actionPerformed it surprisingly worked . The elevator could pause.
> That maked me confused . I post all of my code here . Thank all for
> your help and advice .

[...]

As suggested upthread, delete class Pause. Replace new Pause() with this:

tm.stop();
//new Pause();
tm.setInitialDelay(1000);
tm.restart();
app.getButtonPanel().restoreButtonState(curFloor);

Your application has more serious flaws:

1. You really need to start on the EDT:

<http://java.sun.com/docs/books/tutorial/uiswing/concurrency/initial.html>

2. Don't add the same components repeatedly; add them once and redraw the
content in each animation frame:

<http://java.sun.com/docs/books/tutorial/uiswing/painting/index.html>

Knute Johnson

unread,
Sep 22, 2008, 1:49:20 PM9/22/08
to
tkt...@gmail.com wrote:
> Hi , Sorry for that mess . I use tab and space when I typed the code
> into the Google window and at the end it displayed like that . My
> problem is how to pause the elevator when it reachs a chosen floor
> (picked by pressing one button on the button panel). My idea is to
> use another Pause( contains another timer ) class to do this . When
> the current floor is the destination floor , I use this code segment

Your code was still not compilable and I don't have the time to play
with it. I still think you should try a different approach rather than
all the timers. Animation can be tricky to get working well. I wrote
you an example of how I think you should approach your problem. Adding
pauses for door opening/closing should be just a matter of adding some
new states to the Direction enum and some more logic code to the run()
method and paint the doors.

Note: I used the European convention for the floors. The first floor
above the ground floor is 1.

import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;

public class test99 extends JPanel implements ActionListener, Runnable {
// start with car on fifth floor
volatile int Y = 150;
volatile int floor = 150;
enum Direction { UP, DOWN, STOP };
Direction dir = Direction.STOP;

public test99() {
setPreferredSize(new Dimension(200,200));
}

public void start() {
new Thread(this).start();
}

public void actionPerformed(ActionEvent ae) {
String ac = ae.getActionCommand();
if (ac.equals("4")) {
if (dir == Direction.STOP)
floor = 120;
if (Y < floor)
dir = Direction.UP;
else
dir = Direction.DOWN;
} else if (ac.equals("G")) {
if (dir == Direction.STOP) {
floor = 0;
if (Y > floor)
dir = Direction.DOWN;
}
}
}

public void run() {
while (true) {
// 25 frames per second delay
try {
Thread.sleep(40);
} catch (InterruptedException ie) { }

switch (dir) {
case UP: Y += 1; break;
case DOWN: Y -= 1; break;
case STOP: break;
}
// stop car if on correct floor
if (Y == floor)
dir = Direction.STOP;
repaint();
}
}

public void paintComponent(Graphics g2D) {
// need Graphics2D for the stroke
Graphics2D g = (Graphics2D)g2D;
// draw background
g.setColor(getBackground());
g.fillRect(0,0,getWidth(),getHeight());
// draw car
g.setColor(Color.BLUE);
g.fillRect(13,164-Y,19,22);
// draw shaft
g.setColor(getForeground());
Stroke s = g.getStroke();
g.setStroke(new BasicStroke(4.0f));
for (int i=0; i<6; i++)
g.drawRect(10,10+i*30,25,30);
}

public static void main(String[] args) {

EventQueue.invokeLater(new Runnable() {
public void run() {
test99 t99 = new test99();
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(t99,BorderLayout.CENTER);
JPanel p = new JPanel();
JButton b = new JButton("4");
b.addActionListener(t99);
p.add(b);
b = new JButton("G");
b.addActionListener(t99);
p.add(b);
f.add(p,BorderLayout.SOUTH);
f.pack();
f.setVisible(true);
t99.start();
}
});

John B. Matthews

unread,
Sep 23, 2008, 5:18:00 PM9/23/08
to
In article <48d7da9b$0$28801$b9f6...@news.newsdemon.com>,
Knute Johnson <nos...@rabbitbrush.frazmtn.com> wrote:

> tkt...@gmail.com wrote:
> > Hi , Sorry for that mess . I use tab and space when I typed the code
> > into the Google window and at the end it displayed like that . My
> > problem is how to pause the elevator when it reachs a chosen floor
> > (picked by pressing one button on the button panel). My idea is to
> > use another Pause( contains another timer ) class to do this . When
> > the current floor is the destination floor , I use this code segment
>
> Your code was still not compilable and I don't have the time to play
> with it. I still think you should try a different approach rather than
> all the timers. Animation can be tricky to get working well. I wrote
> you an example of how I think you should approach your problem. Adding
> pauses for door opening/closing should be just a matter of adding some
> new states to the Direction enum and some more logic code to the run()
> method and paint the doors.
>
> Note: I used the European convention for the floors. The first floor
> above the ground floor is 1.

[...]

OP: I would highlight two, related features of Knute's excellent example
to consider as you update your own code. First, Knute's main() creates
all the GUI components on the EDT, using EventQueue.invokeLater().
Without this, an unfortunate choice for the initial delay in a Timer can
lead to null pointer exceptions that are platform dependent. Second,
notice how Knute's paintComponent() redraws the entire component without
adding any components.

Knute: I was intrigued by your example's implementation of runnable. I
have come to like using javax.swing.Timer, as I can adjust the animation
easily in the same code that handles other aspects of the model. I'd be
grateful for any insights you can offer on one approach versus the
other. As an example, here's a subway simulation driven by a Timer:

<code>
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.Random;
import javax.swing.*;

/** @author John B. Matthews */
public class Subway extends JFrame {

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {

new Subway();
}
});
}

public Subway() {
this.setTitle("Subway Simulation");
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
ButtonPanel control = new ButtonPanel();
SubwayPanel subway = new SubwayPanel(control);
this.setLayout(new BorderLayout(0, 8));
this.add(Box.createVerticalStrut(8), BorderLayout.NORTH);
this.add(subway, BorderLayout.CENTER);
this.add(control, BorderLayout.SOUTH);
this.pack();
this.setVisible(true);
subway.beginOperation();
}
}

class SubwayPanel extends JPanel implements ActionListener {
public static final int MAX = 8; // Max stops
private static final int DX = 4; // Initial velocity
private static final int DOOR = 100; // Preferred width
private int dx = DX;
private int xx = 0;
private int yy = 0;
private Timer timer = new Timer(40, this); // ~25 Hz
private ButtonPanel control;
private boolean loading;

public SubwayPanel(ButtonPanel control) {
this.control = control;
setPreferredSize(
new Dimension(MAX * DOOR, DOOR * 162 / 100 + 16));
}

public void beginOperation() {
timer.setInitialDelay(200);
timer.start();
timer.setInitialDelay(1000);
}

@Override public void paintComponent(Graphics g) {
super.paintComponent(g);
int width = getWidth() / MAX;
int height = getHeight();
int w2 = width / 2;
g.setColor(Color.gray);
g.fillRect(xx, yy, width, height);
g.setColor(Color.black);
g.drawRect(xx, yy, width, height - 1);
if (loading) g.fillRect(xx + w2 / 2, yy, w2, height);
else g.drawLine(xx + w2, yy, xx + w2, yy + height);
}

// Handle Timer events
public void actionPerformed(ActionEvent e) {
int width = getWidth() / MAX;
int height = getHeight();
int curStop = Math.min(xx / width, MAX - 1);
boolean selected = control.getButton(curStop);
if (Math.abs(xx % width) < DX && selected) {
timer.restart();
control.clearButton(curStop);
loading = true;
} else {
xx += dx;
if (xx < 0) {
dx = -dx;
xx = 0;
}
if (xx > (MAX - 1) * width) {
dx = -dx;
xx = (MAX - 1) * width;
}
loading = false;
}
control.randomButton();
this.repaint();
}
}

class ButtonPanel extends JPanel implements ActionListener {
private static final int MAX = SubwayPanel.MAX;
private static final Random rnd = new Random();
private ArrayList<JToggleButton> stops =
new ArrayList<JToggleButton>();

public ButtonPanel() {
this.setLayout(new GridLayout(1, MAX));
for (int i = 0; i < MAX; i++) {
JToggleButton tb = new JToggleButton("Stop " + (i + 1));
tb.addActionListener(this);
if ((i > 0)) tb.setSelected(rnd.nextBoolean());
stops.add(tb);
this.add(tb);
}
}

public boolean getButton(int i) {
return stops.get(i).isSelected();
}

public void clearButton(int i) {
stops.get(i).setSelected(false);
}

public void randomButton() {
if (rnd.nextGaussian() > 2.0537) // ~2%
stops.get(rnd.nextInt(MAX)).setSelected(true);
}

public void actionPerformed(ActionEvent e) {
JToggleButton button = (JToggleButton)e.getSource();
button.setSelected(true);
}
}
</code>

Knute Johnson

unread,
Sep 24, 2008, 1:19:24 AM9/24/08
to

For the elevator example the Runnable was the simplest way to implement
the animation and to be able extend it.

I've been on a forever quest for more speed and smoothness in animation.
java.util.Timer is not very consistent in its intervals.
javax.swing.Timer is a little better but if you are doing much on the
EDT that doesn't hold true either. And it has a larger practical
minimum interval than java.util.Timer. Thread.sleep() is probably the
best of those three although it can still vary considerably too. For
some things I've been doing lately that require exceptional smoothness
I've been using a loop and System.nanoTime(). I've been playing with a
very small sleep, 1ms or so, in the loop but it is smoother without it.
This uses a lot of processor and will only really work on
multi-processor machines but it is the smoothest I've found so far.

The other issue in animation performance is draw time. The newer
compilers are much faster but direct rendering using a BufferStrategy on
a Panel or Window/JWindow, under Windows XP anyway, is very very fast.
All of my work animation has been on Windows machines and I know that it
is a completely different game under Linux. And really most of what
I've been doing isn't animation like a movie, but has been scrolling
text or images.

We are doing a project in Las Vegas in a new casino that has three huge
rear projection screens in their Race and Sports Book. On the bottom
they have a scrolling window like the ticker windows on CNN or some of
the news stations. I have spent a huge amount of time getting that to
be smooth. Turns out your eye is very sensitive to jerky motion in a
horizontal direction, much more so than vertical. My biggest concern
now is computer life running the processors at 90% 24/7. I'm afraid
that the heat will shorten their life but I guess I won't know until it
breaks :-).

So for most things, the java.util.Timer will be perfect. Sometimes the
implementation is slightly simpler with a runnable loop as was the
elevator case.

John B. Matthews

unread,
Sep 24, 2008, 8:17:10 AM9/24/08
to
In article <48d9cddc$0$5195$b9f6...@news.newsdemon.com>,
Knute Johnson <nos...@rabbitbrush.frazmtn.com> wrote:
[...]

> I've been on a forever quest for more speed and smoothness in
> animation. java.util.Timer is not very consistent in its intervals.
> javax.swing.Timer is a little better but if you are doing much on the
> EDT that doesn't hold true either. And it has a larger practical
> minimum interval than java.util.Timer. Thread.sleep() is probably
> the best of those three although it can still vary considerably too.
> For some things I've been doing lately that require exceptional
> smoothness I've been using a loop and System.nanoTime(). I've been
> playing with a very small sleep, 1ms or so, in the loop but it is
> smoother without it. This uses a lot of processor and will only
> really work on multi-processor machines but it is the smoothest I've
> found so far.
>
> The other issue in animation performance is draw time. The newer
> compilers are much faster but direct rendering using a BufferStrategy
> on a Panel or Window/JWindow, under Windows XP anyway, is very very
> fast. All of my work animation has been on Windows machines and I
> know that it is a completely different game under Linux. And really
> most of what I've been doing isn't animation like a movie, but has
> been scrolling text or images.

Ah, I see. I've been doing simulation where the moving objects are small
and I can control the EDT load.

> We are doing a project in Las Vegas in a new casino that has three huge
> rear projection screens in their Race and Sports Book. On the bottom
> they have a scrolling window like the ticker windows on CNN or some of
> the news stations. I have spent a huge amount of time getting that to
> be smooth. Turns out your eye is very sensitive to jerky motion in a
> horizontal direction, much more so than vertical.

Sounds like you've learned first-hand how fatigue and habituation affect
saccadic eye movements. I can't watch those crawlers more than few
minutes at a time.

> My biggest concern now is computer life running the processors at 90%
> 24/7. I'm afraid that the heat will shorten their life but I guess I
> won't know until it breaks :-).
>
> So for most things, the java.util.Timer will be perfect. Sometimes the
> implementation is slightly simpler with a runnable loop as was the
> elevator case.

I appreciate your insights. Thanks!

0 new messages