The Source for Java Technology Collaboration
User: Password:



Tim Boudreau's Blog

February 2005 Archives


POV-Ray support for NetBeans...and pix from the road

Posted by timboudreau on February 19, 2005 at 01:17 AM | Permalink | Comments (3)

I'm doing a NetBeans module-building presentation inside Sun next week. POV-Ray scene language makes a nice demo for explaining how to do some things. So NetBeans now has POV-Ray support...
povshot.png

POV-Ray is pretty cool - I used it years ago in my brief period doing commercial graphics work. Unlike most 3D rendering software, rather than a modeller (though Moray is a good one), it uses a "scene language", so you enter things like sphere <0, 0, 0> to define what's there. And since it's working with mathematically perfect geometric primitives, rather than triangle-meshes, you don't end up with weirdness if you zoom in too close.

It will work well to demonstrate some basic NetBeans concepts like how to recognize and edit file-types, how to write a basic project type, and do loose coupling between the two. The sources are now uploaded into NetBeans CVS in the contrib project. To try it on Windows, it's worth getting a non-GUI version of POV-Ray.

If you're saying to yourself, I want that NetBeans module-building tutorial! Why is it only for Sun people?!, you can get it. This is the shake-down-cruise for doing this - we'll do it for more people around JavaONE, and elsewhere. Of course, if you're interested, please comment to this blog - gauging interest is a good thing.

And after a month on the road demoing NetBeans, I'm back in rainy Palo Alto. A few people commented that they liked the pictures in the last blog about my travels, so I'll share a few more. My last stop was a great dinner with Ben Galbraith and a bunch of folks from the Utah Java Users Group in Salt Lake City. I'll be back there to talk about NetBeans to the full group on March 17th. Please come!

The pictures below were shot on my drive across Utah and Nevada, on the next to last day of driving. Yes, polarizing sunglasses can be used as a filter on a digital camera :-)

The Great Salt Lake
saltLake.jpg

Hills with shadow
hillsNshadow.jpg

A power plant at dusk
chimneys1.jpg



How to start writing apps for TiVO in NetBeans, in 5 minutes or less

Posted by timboudreau on February 04, 2005 at 01:07 PM | Permalink | Comments (4)

The TiVO folks have a Java SDK for writing applications that run on a TiVO (well actually the code runs on the server, and the visualization happens on the user's TV), along with a simulator that lets you run and debug applications on your computer. Here's how to very simply set up NetBeans to run/debug TiVO applications.

These instructions are for a current NetBeans 4.1 development build, but the process is very similar for NetBeans 4.0.

First, you will need to download the TiVO SDK , and unpack it to, e.g., /tivo

Now, in NetBeans:

  1. Select File | New Project to open the New Project Wizard.
  2. Select the General category in the left-hand pane, and Java Application in the right-hand pane, and press Next . On the next pane of the wizard name the project TivoTest , and press Finish to create the project.
  3. Right click the TivoTest node in the Projects tab of the Explorer window (to the left of the editor) and choose Properties from the popup menu that appears, to show the Project Properties dialog.
  4. Select the Build | Compiling Sources node in the left-hand pane of that dialog, and Click the Add Library button on the right. This displays a list of libraries NetBeans already knows about. If this is the first time you've used the TiVO SDK, you'll need to set it up as a library; otherwise, steps 5 through 7 can be skipped.
  5. Click the Manage Libraries button in this dialog. In the next dialog, click New Library at the bottom left. In the New Library dialog, type Tivo and press enter to close the dialog.
  6. The Library Manager dialog will now show a new library on the left called Tivo, with no contents. Click the Add Jar/Folder button on the left. In the file dialog that appears, navigate to wherever you unpacked the TiVO SDK. Select hme.jar and simulator.jar , and press the Add JAR/Folder button at the bottom of the file dialog to accept them.
  7. Now switch to the Sources tab, and click its Add JAR/Folder button, and add src.zip , so javadoc comments will be visible with code completion for the TiVO SDK classes. Future projects can simply be pointed at the library which you have just created.
  8. Click the Add Library at the bottom of the Add Library dialog button to add the new TiVO library to your project. Click OK to close the Project Properties dialog.
  9. Now that all the dialogs are closed, you should be looking at the Main class that was generated by the New Project Wizard. Change the superclass to be Application . Press Alt-Shift-F (Ctrl-Shift-F on Macintosh) to auto-import com.tivo.hme.sdk.Application , the superclass.
  10. Insert the following code into the Main class (don't delete the main (String[] args) method!):
        protected void init(Context context) {
            root.setResource(createText("default-36-bold.font",
                Color.white, "Hello from an application!"));
        }
    
  11. Now just insert the following line in the existing main (String[] args) method:
        Simulator.main(new String[] {Main.class.getName()});
    
Press F6 to run the app, press F5 to debug it.

For anybody interested, they appear to be running a developer contest .

Now if there were just something on TV aside from plastic surgery, car makeovers and Law and Order...is it just me or did American television go completely insane over the five years I was living overseas?

JNN just got prettier (at least on the mac)

Posted by timboudreau on February 04, 2005 at 11:26 AM | Permalink | Comments (7)

Having a couple evenings to kill in a hotel room, and needing to do a bit of coding to keep myself sane, I wrote some UI and keyboard usability improvements to JNN, James Gosling's RSS reader (screenshot in blog). I hope you'll agree the results are pretty slick.

I got involved in JNN a year ago, when I downloaded it, and noticed it had some "border build-up" problems in the UI - it was a little ugly. And since I'd been doing some similar fixes for NetBeans, I spent a Saturday afternoon putting together some patches, and ended up being a committer on the project.

JNN is just a handy RSS reader - it's become sort of my news source when I'm online. And I'd done a bunch of work over the last year making NetBeans look really nice on the macintosh, so I figured I'd apply those skills to JNN and make it seem a little more at home on the macintosh desktop. Here's a screenshot (yes, this is a pure Java app!):

jnn.png

It's not quite as pretty on Windows or Linux yet - but if I can tear myself away from my mac, it should be possible to do something similar there - or maybe someone else will. Some of the inspiration for the shadows and the color of the RSS list came from iTunes.

I mentioned improvements in keyboard navigability - here's what's new:

  • Ctrl (Command on mac) - up/down will navigate RSS feeds - no need to tab to the list
  • Up/Down arrows navigate messages even if keyboard focus is in the message area
  • Enter from anywhere will open the top link of the current message in a browser - no mouse needed
  • +/- will adjust the font size

Now for how the shadows and rounded outlines work: Only two things actually changed in the UI - using the system property apple.awt.brushMetalLook to set the main window background, and using a custom Border class on the mac. The painting is all Java2D to do the shadows and such. The shadows are simply taking a RoundedRectangle2D.Double and painting it repeatedly with lighter colors, while setting the clipping area so it doesn't paint at the bottom of the rounded rectangle - and then doing the same thing for the bottom with lighter colors. The point being that getting these nice effects is really quite simple - here's the painting code that does it:

    private static final int ARC = 22;

    public void paintBorder(Component component, Graphics g, int a,
                                    int b, int c, int d) {

        Graphics2D g2d = (Graphics2D) g;
        RoundRectangle2D.Double r =
            new RoundRectangle2D.Double (a+(ARC / 2), b+(ARC/2), c-ARC, d-ARC,
            ARC, ARC);

        if (component instanceof JScrollPane) {
            component = ((JScrollPane) component).getViewport().getView();
        }
        Color bg = component.getBackground();

        Color outer = UIManager.getColor("control");

        g2d.setRenderingHints(HINTS);

        g2d.setColor (outer);
        g2d.fillRect (a, b, c, d);

        g2d.setPaint (bg);
        g2d.fill(r);

        Shape clip = g2d.getClip();

        Rectangle withoutBottom = new Rectangle (a, b, c, d - ARC);

        if (clip != null) {
            Area area = new Area (clip);
            area.intersect(new Area(withoutBottom));
            g.setClip (area);
        } else {
            g.setClip (withoutBottom);
        }

        double amt = 0.65d;
        int blu = 5;

        int[] colors = new int[] { 125, 160, 180, 215, 232, 242 };
        int red = bg.getRed();
        int green = bg.getGreen();
        int blue = bg.getBlue();
        double ttl = 0;
        Color first = null;
        for (int i=0; i < colors.length; i++) {
            g2d.translate (0d, amt);
            ttl += amt;
            int ra = red - (255 - colors[i]);
            int ga = green - (255 - colors[i]);
            int ba = blue - (255 - colors[i]) + blu;
            Color col = new Color (ra, ga, ba);
            g2d.setPaint (col);
            g2d.draw(r);
            if (i == colors.length /2) {
                first = col;
            }
        }
        g2d.translate (0d, -ttl);

        Rectangle bottom = new Rectangle (a, b + (d - ARC), c, ARC/2);

        if (clip != null) {
            Area area = new Area (clip);
            area.intersect(new Area(bottom));
            g.setClip (area);
        } else {
            g.setClip (bottom);
        }
        g2d.translate (0, -amt);
        g2d.setPaint (new GradientPaint (0, (b+d)-ARC, first, 0, b+(d-(ARC/2)), Color.WHITE));
        g2d.draw(r);

        Composite comp = g2d.getComposite();
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));

        g2d.translate (0, -amt);
        g2d.setPaint (new GradientPaint (0, (b+d)-ARC, first, 0, b+(d-(ARC/2)), Color.WHITE));
        g2d.draw(r);

        g2d.setClip (clip);
        g2d.translate (0, amt * 2);
        g2d.setComposite (comp);
    }

    private static final Map HINTS = new HashMap();
    static {
        HINTS.put (RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    }


NetBeans on the Road

Posted by timboudreau on February 03, 2005 at 07:07 PM | Permalink | Comments (3)

So I moved from Prague to California. And I had this car in Massachusetts. What better way to get it to California, than to drive, with lots of stops to demo NetBeans for people?

It's been an interesting trip - thus far I'm in Dallas, Texas. I've been to a bunch of Sun field offices, and learned a lot about this company and its customers - working in Prague is a bit like working for a different company, so it's good to learn more about how the mother ship runs.

It also meant getting caught in New York City for the blizzard that hit the midwest and the northeast of the U.S. a few weeks ago. I've never been in New York when it was silent before. So the couple days afterward looked like this:

newJerseyHighway.JPG

One thing that's always fun to demo is the Mobility Pack for NetBeans - people are just gaga about it. When I demoed this stuff at Javapolis back in December, I asked a question for the +/-100 people in the audience: "How many of you have ever developed a J2ME app?" Three people raised their hands. "Okay, how many of you would try it if it were really easy?" Everybody raised their hands. And it really does make it easy. So I've got a feeling this is going to take off.

So tomorrow it's more meetings, then a visit to the Telephone Pioneers Museum in Dallas - my grandfather worked all his life for the telephone company, and I have a collection of circa 1918 test equipment in mint condition, which I would donate if I knew it would not be thrown away. After that it's on to Colorado!

Just to show the road isn't all snow:

SunsetInOhio.JPG




Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds