Monthly Archives: June 2006

Windows Multimedia Video Capture

On my computer the WIA (Windows Image Acquisition) API is SLOOOOOW. So i decided to give the Windows Multimedia Video Capture API a try. I didn’t take long to create the prototypes in Managed Code and call the DLL functions. Everything runs really smooth now… As always, feel free to download the testavicap32 sources now!

Windows Image Acquisition

Earlier today i decided to toy around with my webcam. A couple of websearches later i ended up at WIA (Windows Image Acquisition). I found a couple of articles (eg: here and here) that showed how to capture images. I wanted to display the caputered image in a PictureBox. Unfortunately everybody seems to save the WIA.ImageFile to a file and then load the imagefile into a PictureBox. It’s obvious that i don’t want to save the image into a file first. Here is my workaround:

// Load the ImageFile into a PictureBox
pbImage.Image = Image.FromStream(new MemorySteam((byte[]) imgf.FileData.get_BinaryData()));

Experimenting with LINQ Preview (May 2006)

Today i downloaded and installed LINQ Preview (May 2006). Well, that was the plan anyway:

error with linq preview installer

A couple of minutes later i found this page and was able to solve the problem by adding the following users with administrative rights: Power Users, Users and Creator Owner.

A TableModel for Entity Beans

For my graduation project i needed a component that could display a list of Entity Beans. I found that JTable is such a component and with the help of custom TableCellRenderer and TableCellEditor components i was able to customize the rendering to my needs. In order to get the data into the JTable i implemented a custom TableModel, namely EntityTableModel. Now i can easily generate a JTable that displays Entity Beans:

// fetch the elements we want to display
Object[] elements = employeeController
  .getEntityManager()
  .createNamedQuery("findEmployees")
  .getResultList()
  .toArray();

// build map with column name, entity attribute pairs
HashMap<string, String> colAttrs = new LinkedHashMap<string, String>();
colAttrs.put("First Name", "firstName");
colAttrs.put("Last Name", "lastName");

// build collection with editable attributes
Collection<string> editables = new ArrayList<string>();

// initialise the tablemodel
TableModel tableModel = new EntityTableModel(elements, colAttrs, editables);

// initialise the table
JTable table = new JTable(tableModel);

BBCode for Graphics2D

For my graduation project we needed the ability to print a couple of bills etc. Printing lines was pretty simple with the LinesPrinter i blogged about a while ago. We had two choices: either implement a specific print method for each module or implement a reusable markup system. Obviously we went for the second option and came up with something alike BBCode. The codes we implemented are:

  • [b]..[/b] for bold
  • [i]..[/i] for italic
  • [color=x]..[/color] for color x
  • ..

    for centered text

  • [r]..[/r] for right aligned text
  • [ll=x]..[/ll] for left aligned text starting from the x-th column at the left
  • [lr=x]..[/lr] for left aligned text starting from the x-th column at the right
  • [rl=x]..[/ll] for right aligned text starting from the x-th column at the left
  • [rr=x]..[/ll] for right aligned text starting from the x-th column at the right

Since the code is written to work on a Graphics2D device you can also render the formatted text on a jpanel etc instead of a printer device. Here is a screenshot of a generated bill (on a jpanel):

rpcode

Feel free to download, try and improve the rpcode.zip package.

Couple of screenshots of my graduation project

Here are a couple of screenshots of my graduation project i’ve been working on last couple of weeks. The GUI is built with Swing, the bussiness rules make extensive use of the Apache BeanUtils and Hibernate Validators packages and with PostgreSQL we have a solid database. Since it takes a while to load the EntityManagerFactory we’ve added a simple splashscreen:

splashscreen

The base screen displays a map with the tables in the restaurant. The color of the tables depends on the state of the visit (eg: just arrived, ordered some items, eating soup, eating dessert, paid the bill). There is also the possiblity to group tables. Offcourse you have the possibility to rearrange the tables and add/remove the maps:

groundplan restaurant

groundplan terrace

As soon as the waiter has choosen a visit he can add orders via an easy to use screen. He also has the possibility to add (pre-configured and/or custom) remarks to a given order. Each order is printed on the printer of the division that is responsible for the handling for the given type of menuitems:

order panel

remarks dialog

And least but not least, there is a screen that allows the waiter to generate, print and save one or more bills for each visit. If all ordered items have been paid, the visit goes into the PAID state:

billing panel

Offcourse we’ve also written list/detail panels for all the tables this restaurant uses. Here are screenshots of the list and detail panel for the menuitems:

menuitem list

menuitem detail