home *** CD-ROM | disk | FTP | other *** search
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Font;
- import javax.microedition.lcdui.Graphics;
-
- class InternetTime$InternetTimeDisplay extends Canvas implements Runnable {
- private static final long MILLIS_IN_DAY = 86400000L;
- private static final long MILLIS_IN_BEAT = 86400L;
- private Thread thread;
- private int width;
- private int height;
- private int xStr;
- private int yStr;
- private long timeMs;
- private long timeBeats;
- private boolean goOn;
- private int beatsCounter;
- private long msCounter;
- private long msWhenStart;
- private Font defaultFont;
- // $FF: synthetic field
- private final InternetTime this$0;
-
- InternetTime$InternetTimeDisplay(InternetTime this$0) {
- this.this$0 = this$0;
- this.width = ((Canvas)this).getWidth();
- this.height = ((Canvas)this).getHeight();
- this.xStr = this.width / 2;
- this.yStr = this.height / 2;
- this.defaultFont = Font.getFont(64, 1, 16);
- }
-
- public void run() {
- long delta = 0L;
- this.beatsCounter = 0;
- this.msCounter = 0L;
-
- for(this.msWhenStart = System.currentTimeMillis(); this.goOn; delta = System.currentTimeMillis() - this.msWhenStart - (long)this.beatsCounter * 86400L) {
- ((Canvas)this).repaint();
- ++this.beatsCounter;
- ++this.timeBeats;
- if (this.timeBeats == 1000L) {
- this.timeBeats = 0L;
- }
-
- try {
- Thread.sleep(86400L - delta);
- } catch (Exception var4) {
- ((Throwable)var4).printStackTrace();
- }
- }
-
- }
-
- void setTimeMs(long value) {
- this.timeMs = value;
- this.timeMs %= 86400000L;
- this.timeBeats = this.timeMs / 86400L;
- this.restartThread();
- }
-
- long getTimeMs() {
- return this.timeBeats * 86400L;
- }
-
- void restartThread() {
- if (this.thread != null) {
- this.stopThread();
- }
-
- this.startThread();
- }
-
- void startThread() {
- this.goOn = true;
- this.thread = new Thread(this);
- this.thread.start();
- }
-
- void stopThread() {
- this.goOn = false;
- if (this.thread != null) {
- this.thread = null;
- }
-
- }
-
- public void paint(Graphics g) {
- g.setColor(0);
- g.fillRect(0, 0, this.width, this.height);
- g.setColor(16777215);
- g.setFont(this.defaultFont);
- g.drawString("@ " + this.timeBeats, this.xStr, this.yStr, 65);
- }
- }
-