tag archive: programming

Picture Filer: A free Java program for naming and sorting image files

I made this program to go along with my process for handling incoming digital pictures, but I hope you might find it useful also.

I copy files from my camera in to a working directory, and bulk rename them using my Nautilus script: rename-with-exif-date.sh. This gives me a bunch of files with a timestamp in YYMMDD_HHMMSS format, for example: 071125_090623.jpg.

Next I need to give them additional descriptive tags, and then sort them in to their permanent homes. I like to keep one big directory of originals for each year, and then a smaller subset sorted in to categories, which I might then crop and fix red-eye and etc. Let’s say the end result of a naming/sorting session results in these files:

~/pics/original/2007/
071125_090845 UFO Encounter- Saucer Landing.jpg
071125_090853 UFO Encounter- Saucer Landing.jpg
071125_091026 UFO Encounter- Colorful …

On the Sharing of Free Software

Hi, loyal readers. I’m still here. Last week was busy at work, and getting up at 3:30am tends to make my evenings shorter. Any time I’ve had, I’ve been working on writing a Java utility to help with naming and sorting my pictures. It’s always a battle between finding time to write blog entries and finding time to write code. I like doing both, but writing articles tends to crowd out programming time. It hasn’t been as often that writing software has crowded out blogging time. And since I really want to write free software as well as write about it, I’m going to have to work on that balance.

I’ll be sharing my program here, with some trepidation. It’s not perfect; nothing ever is. I always imagine writing some elegant and beautiful work of art, but the words on the page never match up with that ideal. Even if posting software here won’t result …

Displaying a Scaled Image with Java Swing

I’m working on a small application to help me with naming and sorting my pictures, so one of the basic things it needs to do is load and scale an image. Found lots of information here and there on this, and this post is to share what I came up with.

When searching around trying to figure stuff like this out, it’s hard to credit where you found everything. A lot of search results point to forum.java.sun.com, with discussions that are alternatively helpful and abusive to newbie questions. When I started leaning towards a solution based on overriding the “paint” method, one of the forum threads pointed to a good tutorial: “Lesson: Performing Custom Painting,” and an in-depth explanation: “Painting in AWT and Swing.”

The core of this is a class that extends javax.swing.JPanel, uses javax.imageio.ImageIO to read the file in to a java.awt.Image class, and then calls the Image.getScaledInstance() method to scale the image. We override the JPanel’s paintComponent(Graphics g) method …

NetBeans Gotcha: GUI custom component problem when package and class named the same

Let’s say you have a project with package Example, and in that package you have:

Example.java // troublemaker!
ExampleUI.java // “form” – extends JFrame
LabelExample.java // extends JLabel

One of the cool things about the Matisse GUI Editor in NetBeans is that you can add LabelExample.java as a custom component to the widget palette and then drop an instance of it on your ExampleUI.java form in design mode. NetBeans will generate the source code for you.

However, there is a little hitch. When NetBeans creates the variable declaration, it will use the fully qualified path of your class, in this case Example.LabelExample, and then the IDE (which is chanelling the compiler), will complain with:

That is, here is your generated code block:

// Variables declaration – do not modify
private Example.LabelExample labelExample1;
// End of variables declaration

And this is the error:

cannot find symbol
symbol : class LabelExample
location: class Example.Example

I guess it’s confused about which “Example” you mean, …

NetBeans Update, Briefly and Vaguely

Following up on my previous, surprisingly popular post about NetBeans, I finally wrote a Java GUI program with it. Simple program, but the writing of it confirmed my initial impression that NetBeans will be a good Java IDE for me. I’ve been avoiding the learning curve of Java GUI, but this weekend I thought of something I figured I could manage. It went pretty well, and I’ll be writing another post about the program soon. I still have a lot to learn, but I’m confident now I’ll be able to muddle my way along.

Random bullet points:

I certainly haven’t put the Matisse GUI builder through its paces yet, but I’m still impressed by how robust and full-featured it is.

The overall environment still feels comfortable to me and intuitive in a way that Eclipse hasn’t. In both IDEs, I get a sense of so many things I need to learn, but with NetBeans it has been …

Moving to NetBeans (from Eclipse)

NetBeans Projects Pane

I’m trying out NetBeans 5.5.1 as a Java IDE and I’m very impressed so far. Thought I’d cough up some related thoughts on programming environments and free software, mixed with some personal history:

MS Visual Basic

I began my corporate programming career using Visual Basic 4, and moved on up to VB6, which I continued to use at home until last year. I really liked VB for GUI programming and quickly putting together various utility programs. I’ve probably made over a hundred more or less complicated VB programs for my personal use, in addition to the huge program I worked on at my job many years ago.

Java

While still using VB on the job, I started learning Java and have done a fair amount of server-side programming with it. I’ve always wanted to learn how to do GUI in Java, but it hasn’t been easy.

I started out using Borland’s JBuilder in 1999. It had …

Confessions of a Visual Basic Programmer

Originally published in Free Software Magazine, 25 September 2006.

In my first post here at Free Software Magazine, I mentioned that I actually like using Microsoft Windows. People seemed to let this go or find it not worth commenting on, maybe because my goal is to move away from it. Not that I expected rabid opposition. Not at all. GNU/Linux users are well-known for being quite mild and reserved in their opinions. If we must go back to my drug use analogy, it could also be that readers here were supportive of my desire to seek treatment and rehabilitation and didn’t see the need to condemn me for past transgressions. (But really now, the drug metaphor has to go.) Perhaps just as egregious a violation of the principles of free software has been my use of Visual Basic over …