Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > More E-Book Readers > iRex > iRex Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 05-15-2007, 04:47 PM   #1
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
Lightbulb xlets!

I finally figured it out: rather than getting the Java Desktop environment iRex got the Java Microedition Xlet environment from the Tao Group.

Code:
root@ereader:/home/intent# clock.sh
intent (Linux boot loader)
Copyright (c) Tao Systems Ltd 1997-2000

0x564E24 bytes read
Booting image at 0x401ce000-0x405ce400
xlet: ave @ 0x000489a0 [Xlet]
xlet: app @ 0x00026d90
xlet: toolkit @ 0x0001dd80
xlet: vm @ 0x000174d0
xlet: xlet @ 0x00027690
xlet: layout @ 0x000228a8
xlet: dialog @ 0x00027790
Code for clock.sh

Code:
root@ereader:/home/intent# cat clock.sh
#!/bin/sh
EXECPATH=sys/platform/linux/taoref/er10xx
IMGPATH=$EXECPATH
export DISPLAY=:0
export ELATE_FB_TTY=/dev/tty0
#export ELATE_KTRACE=/tmp/ktrace.log
export ELATE_DEBUGSTUB=7990

cd /home/intent/
if [ ! -d /home/intent/ROOTDIR ]
then
   ln -s / ROOTDIR
fi

    OPTIONS="-capp/stdio/xlet /classes/ClockXlet "

exec $EXECPATH/elate -B $IMGPATH/target.img -g2 -l $EXECPATH "$OPTIONS"
An example Xlet

Code:
Macbook-Pro:~/Sources/iliad/xlet scotty$ cat ClockXlet.java 
import javax.microedition.xlet.*;
import java.util.*;
import java.awt.*;
import java.awt.event.*;

public class ClockXlet implements Xlet, ActionListener {

    TextField display;
    MyClock clock;
    Button pauseButton = new Button("Pause");
    Button stopButton = new Button("Stop");
    Button resumeButton = new Button("Resume");
    XletContext context;
    public void initXlet(XletContext ctx)
            throws XletStateChangeException {
        Container c;
        context = ctx;
        try {
            c = ctx.getContainer();
        } catch (UnavailableContainerException e) {
            throw new XletStateChangeException(e.getMessage());
        }
        display = new TextField(30);
        clock = new MyClock(display);
        pauseButton.addActionListener(this);
        resumeButton.addActionListener(this);
        resumeButton.setEnabled(false);
        stopButton.addActionListener(this);
        c.setSize(200, 200);
        c.setVisible(true);
        c.add(display);
        c.add(pauseButton);
        c.add(resumeButton);
        c.add(stopButton);
        clock.start();
    }

    public void startXlet() {
        clock.setPaused(false);
        resumeButton.setEnabled(false);
        pauseButton.setEnabled(true);
    }

    public void pauseXlet() {
        clock.setPaused(true);
        resumeButton.setEnabled(true);
        pauseButton.setEnabled(false);
   }

    public void destroyXlet(boolean unconditional) {
        clock.setStopped(true);
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == stopButton) {  
            clock.setStopped(true);
            context.notifyDestroyed();
        } else if (e.getSource() == pauseButton) {
            clock.setPaused(true);
            resumeButton.setEnabled(true);
            pauseButton.setEnabled(false);
            context.notifyPaused();
        } else if (e.getSource() == resumeButton) {
            context.resumeRequest();
        }
    }
}

class MyClock extends Thread {

    boolean paused, stopped;
    TextField display;

    public MyClock(TextField t) {
        display = t;
    }

    String getTime() {
        Calendar rightNow = Calendar.getInstance();
        String hour = String.valueOf(rightNow.get(Calendar.HOUR_OF_DAY));
        String min = String.valueOf(rightNow.get(Calendar.MINUTE));
        if (min.length() == 1) {
            min = "0" + min;
        }
        String sec = String.valueOf(rightNow.get(Calendar.SECOND));
        if (sec.length() == 1) {
            sec = "0" + sec;
        }
        return hour + ":" + min + ":" + sec;
    }

    public synchronized boolean isStopped() {
        return stopped;
    }

    public synchronized void setStopped(boolean value) {
        stopped = value;
        notifyAll();
    }

    public synchronized boolean isPaused() {
        return paused;
    }

    public synchronized void setPaused(boolean value) {
        paused = value;
        notifyAll();
    }

    public void run() {
        while (!isStopped()) {
            try {
                if (!isPaused()) {
                    Thread.sleep(1);
                    display.setText(getTime());
                } else {
                    synchronized (this) {
                        wait();
                    }
                }
            } catch (InterruptedException e) {
            }
        }
    }
}
Compile it

Code:
javac -source 1.2 -target 1.1 -cp ../personal.jar ClockXlet.java
The needed personal.jar can be gotten here: http://java.sun.com/products/persona.../download.html

Pull the crunchy zip apart and the juicy personal.jar core is in the lib directory.

Last edited by scotty1024; 05-15-2007 at 06:18 PM.
scotty1024 is offline   Reply With Quote
Old 05-15-2007, 05:22 PM   #2
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
I never spent any time writing xlet's so I'm peeling this onion as I go.

The profile for the Intent environment on the iLiad is: CDC-1.0\nmicroedition.profiles = PBP-1.0,FP-1.0

According to this page http://www.ericgiguere.com/articles/...-concepts.html
that's pretty good. What we're mainly wishing we had was PP 1.0 so we'd have a full set of AWT goodies.

More details on PBP can be found here: http://jcp.org/en/jsr/detail?id=129
scotty1024 is offline   Reply With Quote
 
Enthusiast
Old 05-15-2007, 06:17 PM   #3
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
So all the missing bits are explained now. Here is Sun's statement on PBP 1.0:

Code:
If the heavyweight components are missing and Swing is unavailable, you might wonder how you create a user interface. There are two possibilities.

If your application is simple enough, you can create your own components:

import java.awt.*;

/**
 * A _very_ simple UI component that draws a
 * centered text string.
 */

public class SimpleTextLabel extends Component {
    private String text;

    public SimpleTextLabel( String text ){
        this.text = text;
    }

    public void paint( Graphics g ){
        int h = getHeight();
        int w = getWidth();

        g.setColor( getBackground() );
        g.fillRect( 0, 0, w, h );

        g.setColor( getForeground() );
        FontMetrics fm = g.getFontMetrics();
        int textWidth = fm.stringWidth( text );
        int textHeight = fm.getHeight();
        int x = ( w - textWidth ) / 2;
        int y = ( h - 2 * textHeight ) / 2;
        g.drawString( text, x, y );
    }
}

At runtime, place these components directly on a Frame component:

...
Frame frame = ... // some frame you created
SimpleTextLabel label;

// Now build our user interface

label = new SimpleTextLabel( "Press a key to exit" );
label.setBackground( Color.blue );
label.setForeground( Color.yellow );
label.addKeyListener( new KeyAdapter(){
    public void keyTyped( KeyEvent e ){
	exit();
    }
  }
);

frame.add( label );

An application running under the new Xlet model uses the root container supplied by the system (available through the XletContext object passed to each Xlet on initialization) instead of creating its own frame.

The second way to create user interfaces is to use third-party lightweight user-interface toolkits. These toolkits may also be augmented by vendor-supplied classes.

Besides the lack of heavyweight components, the PBP AWT subset includes specific restrictions on what an application's user interface can do, so that PBP applications can run on systems with relatively limited UI capabilities. The most important restriction is that applications may use only a single instance of the Frame class. PBP applications built using the traditional model are responsible for creating the frame themselves. By contrast, in the Xlet model the system creates the frame on the application's behalf, and makes it (or a child container) available by way of the XletContext.getContainer() method. Other frame behavior is optional. The system is free to restrict the size, state, and position of a frame and to hide its title. There are also restrictions on cursor use and other minor details.
http://developers.sun.com/techtopics...ticles/pbp_pp/
scotty1024 is offline   Reply With Quote
Old 05-15-2007, 08:11 PM   #4
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
By the way, if you haven't made the connection yet: this is why there is no dictionary support for the Mobipocket Viewer on the iLiad.

iRex is busy writing light weight widgets for TextField etc to implement the look up features et al...

If they'd bought the UI kit from the Tao Group it all could have been done by now.
scotty1024 is offline   Reply With Quote
Old 05-16-2007, 02:49 AM   #5
tororebelde
No es el toro que piensas
tororebelde began at the beginning.
 
tororebelde's Avatar
 
Posts: 44
Karma: 10
Join Date: Mar 2007
Device: iRex iliad
Now I realize a lot of things. Never hear about Xlet and as I can see it provides with Button and TextField, and if you say it comes with all the AWT goodies, this is a good point to start, since the tao group image has a very minimal classes to do something easy (I mean something with user entry fields).

I will start to analize all the stuff you found here, this is all new to me. Bad news about swing but if this could give us new posibilities, we could do more than just reading!.

So happy about your advances Scotty!
tororebelde is offline   Reply With Quote
Old 05-16-2007, 03:10 AM   #6
Robert Marquard
Delphi-Guy
Robert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheeseRobert Marquard can extract oil from cheese
 
Robert Marquard's Avatar
 
Posts: 285
Karma: 1151
Join Date: May 2006
Location: Berlin, Germany
Device: iLiad, Palm T3
analize? ROTFL
Robert Marquard is offline   Reply With Quote
Old 05-16-2007, 04:08 AM   #7
narve
iLiad fan
narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.
 
Posts: 210
Karma: 3864
Join Date: Oct 2006
Device: iRex iLiad
Quote:
Originally Posted by Robert Marquard
analize? ROTFL
Good to see other immature people in this forum

Scotty: I started a thread on the irex forum re the Java support, and Mathijs provided various info there (including which profiles were supported). Too bad you had to figure it out yourselves, but information gained that way feels better doesn't it?

Anyways, check out that forum in case you can learn more (although iRex didn't say very much).
narve is offline   Reply With Quote
Old 05-16-2007, 05:44 AM   #8
tororebelde
No es el toro que piensas
tororebelde began at the beginning.
 
tororebelde's Avatar
 
Posts: 44
Karma: 10
Join Date: Mar 2007
Device: iRex iliad
Quote:
analize? ROTFL
Quote:
Good to see other immature people in this forum
How nice to make you people ROTFL here. Yes, "analize" a lot of abreviations scotty wrote and I have never seen before I'm just a newbie with a lot of determination
I suppose you say it with other words, it doesn't mind, I now my english is worst than yours
tororebelde is offline   Reply With Quote
Old 05-16-2007, 08:57 AM   #9
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
I cruised the iRex site and found no postings at all about the JVM.
scotty1024 is offline   Reply With Quote
Old 05-16-2007, 10:33 AM   #10
narve
iLiad fan
narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.narve can teach chickens to fly.
 
Posts: 210
Karma: 3864
Join Date: Oct 2006
Device: iRex iLiad
Quote:
Originally Posted by scotty1024
I cruised the iRex site and found no postings at all about the JVM.
Here:

http://forum.irexnet.com/viewtopic.p...+basic+profile

(and some other discussions)
narve is offline   Reply With Quote
Old 05-16-2007, 02:14 PM   #11
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
Just dis-information there.

It is a complete VM, it will run any JDK 1.3 code you throw at it.

Right now I'm attempting to work my way around the Tao Group defending the javax.swing package space from borders.

I'm probably going to have to re-package the GNU code into something like javai.swing instead of javax.swing. This would then force re-importing of any code to be ported as well. But Tao wants you to buy their UI is my guess so what can you do unless you can buy the UI from them? When I checked their web site they weren't offering individual licenses.
scotty1024 is offline   Reply With Quote
Old 05-16-2007, 03:19 PM   #12
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
Well this puts an end to the javax.swing Booster Pack.

I added a class called "dork" to the GNU Swing. Tao will load dork and let me examine it but it refuses to load JFrame (or any of the other well known swing classes.)

Code:
root@ereader:/home/intent# d.sh javax.swing.dork     
intent (Linux boot loader)
Copyright (c) Tao Systems Ltd 1997-2000

0x564E24 bytes read
Booting image at 0x401ce000-0x405ce400
Declared fields.
public int javax.swing.dork.dorkTest

Constructors
public javax.swing.dork()

Methods
root@ereader:/home/intent# d.sh javax.swing.JFrame
intent (Linux boot loader)
Copyright (c) Tao Systems Ltd 1997-2000

0x564E24 bytes read
Booting image at 0x401ce000-0x405ce400
java.lang.NoClassDefFoundError: javax.swing.JFrame
Long live javai.swing!
scotty1024 is offline   Reply With Quote
Old 05-17-2007, 01:47 AM   #13
tororebelde
No es el toro que piensas
tororebelde began at the beginning.
 
tororebelde's Avatar
 
Posts: 44
Karma: 10
Join Date: Mar 2007
Device: iRex iliad
Then, if I understand you right, there's no way to run any swing class from the Tao group image, although it was compiled and/or packaged by us?

If yes, our only way is to do our custom widget classes ...
tororebelde is offline   Reply With Quote
Old 05-17-2007, 03:46 AM   #14
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
Quote:
Originally Posted by tororebelde
Then, if I understand you right, there's no way to run any swing class from the Tao group image, although it was compiled and/or packaged by us?

If yes, our only way is to do our custom widget classes ...
Or possibly there is a signature that could be applied to the jar file to seal it and allow it to be loaded. But yeah, barring that we'd have to use some other name space.
scotty1024 is offline   Reply With Quote
Old 05-17-2007, 07:01 PM   #15
scotty1024
Banned
scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.scotty1024 is no ebook tyro.
 
Posts: 1,300
Karma: 1479
Join Date: Jul 2006
Location: Peoples Republic of Washington
Device: Reader / iPhone / Librie / Kindle
I've got java.awt.Button and java.awt.Label rendering. It was a knock down drag out battle as I wrestled with Tao Group's AWT implementation about various details.

The last detail was the clipping rectangle they were setting for light weight components. Personally I think they have a bug they don't know about as I doubt their peer'd native implementations care about the Java clipping rectangle.

There is still something curious going on during pack() with FlowLayout, which is their FlowLayout. It isn't packing correctly, probably another light weight issue to be sorted.

And event handling needs a comb run through it. Clicking on the buttons doesn't get the mouse event handled correctly. Likely another light weight issue.
scotty1024 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump


All times are GMT -4. The time now is 11:12 AM.


MobileRead.com is a privately owned, operated and funded community.