software development

Editing an image

Posted on November 4, 2009. Filed under: blackberry, image manipulation, software development | Tags: , , , |


When you are working with a screen, it is pretty obvious how to overlay text, images and custom shapes.  All the heavy-lifting is accomplished in the onPaint functions and through the graphics object.  I recently ran into an issue where I need to give some rudimentary image editing capabilities.  In essence, I need to display an image and allow the user to annotate the image with text and then save the image.

The first part is easy to accomplish (I managed to find a few examples on how to pan around a large bitmap image), but the annotating of the image was a bit more difficult to accomplish. 

My first iteration involved me having a custom class that kept track of the annotation and the annotation co-ordinates.  Something along the lines of …

class annotation {

public int x;

public int y;

public String text;


However, this was fine for the onPaint function, but I couldn’t figure out how to merge these array of annotations with the actual bitmap.  After some searching through forums I decided to resort to the intelli-sense built-in to the eclipse pluging, and there it was!  the holy grail that I was looking for: graphics.

It turns out that you can pass a bitmap to the graphics class, and then use all the graphics functions to manipulate the underlaying bitmap.   And because it uses the same graphics class as used in the onPaint, there was no learning curve.

So my code now looks like…

protected void annotateImage(String s)
                        Graphics g = new Graphics(_bmImage);
                        int globalX = _crossHairPos.getLeft() +  _imagePos.getLeft() ;
                        int globalY = _crossHairPos.getTop() + _imagePos.getTop();
                        g.drawText(s, globalX, globalY);

Read Full Post | Make a Comment ( None so far )

EncodedImage – How to Resize

Posted on November 2, 2009. Filed under: blackberry, multiple devices, software development | Tags: , , , |


I have been working on an application that has a number of navigation buttons.  This buttons must always be displayed and I want them to take up about half the width of the screen.  This is a simple problem when you have a single width to deal with, but I recently needed to port the application from the Bold to the Pearl handset.

I wanted to keep the same images but needed to resize based on the display’s width.  There are trivial solutions easily found on the web (where the image’s size is cut in half) but nothing to set an arbitrary size.  So here is my solution (so that I can remember it at a later time).

I know this is an obvious thing to do, but I am continually searching through old projects or the web to remember the details on how to accomplish this task.

The key thing to remember is that the value for the scaleImage is the reciprical of what you would expect.  So if the scaled image is one half (1/2) of the original then your scale factor is (2/1).

protected Bitmap scaleBitmap(EncodedImage ei, int newXSize, int newYSize)
        int xScale = 0;
        int yScale = 0;
        int xSize = ei.getWidth();
        int ySize = ei.getHeight();

        xScale = Fixed32.div(xSize,newXSize);       
        yScale = Fixed32.div(ySize,newYSize);
        return ei.scaleImage32(xScale, yScale).getBitmap();

You can add some refinements:

  1. keep the aspect ratio: just decide what dimension is the limiting factor for display and then apply that scale to both dimensions.
  2. keep images a consistent size: put the size into your class that defines your presentation style
Read Full Post | Make a Comment ( None so far )

Installing Subversion (svn) onto Windows Server

Posted on October 22, 2009. Filed under: revision control, software development, source control | Tags: , , |


Ignorance is Bliss

This has got me angrified!  There are no simple steps on how to install an SVN server onto a windows server.  All the steps assume that you already have Apache installed.  I understand that you can run SVN as a stand-alone installation but I want to run it in conjunction with Apache and take advantage of single sign-in provided by integration with active directory.

I suddenly find myself eating my own words.  After writing my tirade, I went back and found a couple complete svn packages. The one that I opted for is called Visual SVN (  They have both a free and a pay version.  Being cheap, and generally against the principle of paying for open-source software, I opted for the free version.

My installation experience went something like this…

  1. download the msi package
  2. double-click and follow the steps to create repository and users
  3. run tortoise svn to access the newly created repository

It couldn’t have been simpler or more elegant even if Apple had created the product!  It may make the UNIX crowd angry as they seem to have created a product that does away with the arcanity of command line arguments, but these guys did an excellent job of bringing svn into the windows age.

Read Full Post | Make a Comment ( None so far )

How to use resource files in your blackberry app

Posted on August 30, 2009. Filed under: blackberry, software development | Tags: , , , , |


In a previous post I gave the steps on how to add resource files to your application.  In today’s discourse I will describe how to update your application to use those resource files.

They really are quite simple to use, provided that you realize the couple tricks.

Follow these steps to reference the resource file in your class.

Step 1 – include the resource interface

The magic of blackberry means that the resource files are converted into an interface and by implementing that interface on your class you get access to all the strings.

For example, my resource file is called ‘myApp.rrh’ and to include this resource file on my class, I do something like…

public class myApp extends UiApplication extends myAppResource

Trick #1 – The resource files’ interface name is an exact match to the resource file name + the key word ‘Resource’

Step 2 – include a reference to the resource

create a static variable and include it in your class…

private static ResourceBundle _res = ResourceBundle.getBundle(BUNDLE_ID,BUNDLE_NAME);

Trick #2 – BUNDLE_ID and BUNDLE_NAME are auto-generated by blackberry magic

reference your resource through the key name defined in your header file…

LabelField title = new LabelField(_res.getString(appName), LabelField.USE_ALL_WIDTH)

Step 3 – include a reference to a resource array

You can also create a resource array.  In the resource editor, right click your resource and select ‘ConvertToMultipleValues’.  The interface for adding values to this resource array is a bit clunky but hey “a poor craftsman blames his tools”.

You access the values through a string array…

String[] messages = _res.getStringArray(msg);

And that is about it.

Read Full Post | Make a Comment ( 1 so far )

How to add resource file to provide multi lingual support

Posted on August 28, 2009. Filed under: software development |


To reach the widest audience for your application you want to provide support for many different languages and cultures.  This process is known as internationalization.  The most common way of achieving this goal is through resource files for the different target languages (or cultures).

The first step to using resources is to add the resource files to your application (of course this is for the Blackberry plugin for Eclipse).

  1. open the package explorer and find your source package
  2. from the context menu (right-click) OR file->new, select Other [you can also use ctrl-N]
  3. open up the blackberry folder and select ‘Blackberry Resource File’
  4. click next
  5. Select the folder where you wish to save the file.  Generally you want to include it with your source code.
  6. type in the name of your resource file ‘applicationName.rrh’ .  IMPORTANT: the file must end with rrh.
  7. you will see that you have two files:  applicationName.rrh and applicationName.rrc.  the RRH file defines the symbols for each of your strings, and the RRC contains the strings.
  8. add in a file for each culture that you wish to include using the format: applicationName_xxx.rrc.  You must replace xxx with the culture abbreviation and you need the underscore
  9. You have now created your files.  Click on the files and start editing to your heart content.

Some of the common cultures:

Language neutral culture abbreviation
English en
French fr
spanish es
Chinese zh
Japanese ja

Culture definitions:

invariant culture This culture category is culture-insensitive. The category is to be used as essentially a default culture when consistency is desired.

One situation where this category might be desirable to use is creating a trial application with a hard-coded expiration date. Using an invariant will allow you to check for a specific date, regardless of the culture’s format, which will greatly simplify the task of comparing these dates.

The invariant culture is not based on the English language per se, but it is associated with it and bears more similarities to it than to any other identifiable culture.

Neutral Culture A neutral culture is associated with a language but has no relationship to countries or regions. For instance, the English spoken in England is different from that spoken in the United States. The same holds true for Spanish spoken in Mexico versus that spoken in Spain.

Although neutral cultures, like the invariant culture, might be tempting to use, they should be avoided as well, if possible, for the same reasons that invariants should be avoided. The language spoken in different countries that are covered by a neutral culture will almost certainly be different in at least a few respects. In reality, the differences will be many.

Specific Culture This is the most precise of the three categories and is represented by a neutral culture, a hyphen, and then a specific culture abbreviation. For instance, in the designations "en-CA" and "en-US", en represent the neutral culture (English), and CA and US represent the specific culture (Canada and the United States, respectively).
Read Full Post | Make a Comment ( 1 so far )

Blackberry simulator and Internet access

Posted on August 10, 2009. Filed under: blackberry, MDS, software development | Tags: , , , |

“communication is 9 parts listening and 1 part speaking”

I ran across another gotcha today when I was trying to get my application to make a web service call.  I could not communicate with the internet.  Either I’m getting better at this or I got lucky, but figuring out the solution only took about an hour this time.  The help files that I ran across were actually helpful this time.


The easiest way to test if your blackberry simulator has internet access is to use the ‘Browser’ from inside the simulator.  If you can open a web page then your applications will have network access.


The key to this whole thing is MDS (Mobile Data System?) and activating it automatically when you start the blackberry simulator.  Once I followed these steps (as taken from Eclipse Help system) everything worked just fine!


Start the BlackBerry MDS Simulator when you start the BlackBerry Smartphone Simulator
  1. On the Run menu, click Debug Configurations or Run Configurations.
  2. Perform one of the following tasks:
    • To work with an existing start configuration, under BlackBerry Simulator, select a start configuration.
    • To work with a new start configuration, right-click BlackBerry Simulator, select New.
  3. Click the Simulator tab.
  4. Click the General tab.
  5. Select the Launch Mobile Data System Connection Service (MDS-CS) with simulator option.
  6. Click OK.


The keywords that I used to find this …

  • Test a BlackBerry Application that uses an HTTP connection.
Read Full Post | Make a Comment ( 1 so far )

Step by Step – update blackberry jde component for eclipse

Posted on July 27, 2009. Filed under: software development |


“Knowing is half the battle”

In a previous post I described how to install and configure the Blackberry development environment.  I was quite excited when I got it working and could work on the first hello world application.  However, it soon became evident that if I wanted to take advantage of any cool touch features or target the widely distributed pearl handsets I had to update my JDE components.

Again, I spent several days trying to figure out how to update the Eclipse plug-in.  It was fairly straight-forward in downloading and updating the components for the Blackberry JDE but what was not so self-evident was updating the Eclipse plugin.

Updating Blackberry JDE Plugin for Eclipse

There is an automated method for updating the plugin that takes advantage of eclipse’s self-updater.  However, I was unable to get this working and by perusing other posts and boards it became evident that others had similar problems.

I’m hoping that these steps will work (however, RIM has a nasty habit of moving pages around so I’m hoping these links stay constant for a reasonable period of time).

  1. Download and save the zip file for the Appropriate JDE component from  Note: you will want to scroll down to the bottom of the page.
  2. Remember where you save the Zip file.  You won’t have to un-zip as Eclipse likes reading directly from the zip archive.
  3. Start up eclipse
  4. Select Help->Software Updates
  5. Click ‘Add Site’
  6. Click ‘archive’, browse and select the newly downloaded zip file.
  7. Wait for eclipse to import.

Updating Blackberry workspace to use different JDE Component

Once you have downloaded and installed the appropriate JDE, you will need to change the target of your blackberry workspace.

  1. Start up eclipse and load your workspace (should be default unless you are working on multiple projects).
  2. Choose Blackberry->Configure Blackberry Workspace
  3. Select, on the LHS, Blackberry JDE –> Installed Components
  4. Choose the target component and hit ‘OK’
  5. Wait till eclipse finishes thinking and you are good to go.
Read Full Post | Make a Comment ( None so far )

Setting up Blackberry Development Environment

Posted on July 24, 2009. Filed under: software development |


“The best defense is a good offense.”

I have decided to leave out the rant (well, perhaps some will slip in) and just stick to the facts.  As mentioned earlier, I have spent the better part of a week trying to get my development environment setup and running.  I have been frustrated by the inaccurate information, moved information and knowledge assumptions that have been made on various sites and discussion boards.  I am trying to lay out the base steps so that even a trained monkey can get things working.

The original set of tutorials that I tried to follow can be found here.

Set-up Java

The first part is to install the necessary java files on your computer.  These files install the virtual machine, libraries and associated files that everything else depends on. 

There are many different options to download; skip over the ‘bundles’ and look at the second section.  You only need to download the ‘Java SE Development Kit (JDK)

  1. Download the Java SE Development Kit (JDK).  The most recent version is fine (I installed JDK6u14).
    1. The direct link is here
  2. Once the download has completed, install the package.  I took the default options.

Set-up Development IDE

You have two choices when it comes down to development IDE: the blackberry IDE and eclipse.  I understand that there are some advanced features that will be unavailable in eclipse that are available in the blackberry IDE.  However, eclipse is much more friendly and usable and so you have a classic trade-off.  The good news is that the two are compatible (or so everyone claims).

Since I’m new to this whole endeavour and I favour having a modern IDE with built-in help and context sensitive menus, I chose to go with eclipse.  The caveat with eclipse is that you must go with an OLDER version of eclipse.  The newest version DOES NOT WORK with the blackberry software.

The supported version of eclipse is 3.4.1 (also known as Ganymede SR1).  Thou shalt not use 3.3, 3.4.2 (Ganymede SR2) nor 3.5 Galileo, and Pulsar (mobile eclipse) is right out.  Thou shalt use version 3.4.1 and thou shall only use version 3.4.1.

I only belabour this point as I learned this the hard way over the course of a long, frustrating day.  Oh, as usual, there are many different versions and options: Eclipse Classic 3.4.1

  1. Download Eclipse Classic 3.4.1 from here.
  2. The download should be a zip file that you can extract to its final resting place.
  3. I must say that eclipse is nice in that once you have unzipped it, it should just work.  If it doesn’t then I think you are up the creek without a paddle.

Once eclipse has been unzipped and you’ve started it, you are almost there.  Just need to download the eclipse plugin that will allow you to develop for the Blackberry.

  1. Download the BlackBerry JDE Plug-in for Eclipse here.  You can install the ‘Full Installer’ or scroll down to ‘Download the BlackBerry JDE Plug-in for Eclipse v1.0 with the BlackBerry® Java® Development Environment (BlackBerry JDE) v4.5 Component Pack
  2. Once the download completes, run the executable and follow the instructions.

Congratulations.  You have now installed your environment for developing for version 4.5 of the Blackberry.

Next: Installing other versions of the JDE.

Read Full Post | Make a Comment ( 2 so far )

Blackberry Development

Posted on July 24, 2009. Filed under: software development |


Well, I have decided to venture into the world of mobile phones and mobile development.  You are probably asking why I chose to pursue blackberry smartphones over the ever-popular and uber-sexy device known as the iPhone.  So am I, perhaps I’ll talk a bit later about my rationale behind starting with Blackberry over the Apple system.

What I do know is that it has been a very steep learning curve to even get started.  Before I venture into my rant, let me give a brief background on my technical skills.

I have been developing software for over 15 years and have a wide range of experience in all things windows and web related (at least as envisioned and presented by Microsoft).  As part of this time, I have spent several years doing embedded development and a couple of J2E projects.  I thought that I was a pretty smart guy and able to understand and figure things out fairly quickly. 

As such, my initial thoughts were that I would be able to sit down, install the IDE and API and get coding in a matter of a day, maybe two at the most.  Well, here I am at the end of the week and I have just managed to install the components necessary to develop for the Blackberry Storm. I have struggled with just about every step of the process.

It has been a very humbling experience and feel that I need to have a big piece of pie.  I have felt like the man banging his head against the wall just so that he can feel what it is like when he stops.  The past couple days have developed so much character that I’m giving it away free with every comment.

So without any further adieu, I’d like to dedicate the subsequent posts to all those people out there that feel that installation and setup of development environments is a useless waste of time that keeps you from the real job of producing quality and timely software.

Read Full Post | Make a Comment ( 1 so far )

Tools of the Trade – Write it Down

Posted on September 5, 2008. Filed under: software development |

  • Source Control
  • Bug Tracking Software
  • Dedicated Build Environment
  • Testing
  • Documentation
  • Modern Hardware

    Write it Down

    How do you know when you are finished?  How do the testers know that you are finished?  How does the customer know that you are finished?

    Well, unless something is written down then there is no way that all three of you will agree that you are finished.  Everyone hears things differently and perceives things differently. 

    Take three people who just witnessed an accident and ask them what they saw.  You will likely get three similar but slightly different descriptions of the event.  Wait a week and ask them about the accident, and you will get similar responses from the first time.  Wait for a month and ask them and what do you get?  Vague recollections and feelings about what they saw. 

    Get all three people together and quiz for details and you will get three very different responses.  Each person, depending on their memory and emotional reaction, will remember different aspects of the event.  This is the classic problem that forces us to have judges.  They sort through the different viewpoints and decide what is fact and what is fiction.  They then make a decision and pass judgement on an event.

  • Now imagine that you are in the middle of your project and it is time for testing to begin.  The testers, who were not present in the requirements sessions are starting to test the software that was written by someone who received the requirements through word of mouth by the architect who is now working on another project.  Does this sound like a disaster waiting to happen?

    Well, at that point in a project it is a disaster that will take many stressful, conflict filled meetings to hammer out.  Much better is to take the time at the start of the project to write out requirements and reach agreement on what is to be delivered.  It doesn’t matter what form the document takes; what is important is that every stake holder in the project has read and agreed that the contents of the document accurately reflect the functionality that will  be delivered.

    You need something that can be referenced by everyone involved in the project and use as the arbitrating source when conflict arise.  You will need to have someone assigned as the owner of the document and who will be responsible for updating and maintaining the document throughout the project.  The document needs to be in a format that is understandable and useful for everyone involved.

    There is little point in writing things down if no one will read the document.  Try and avoid hundred page documents of dry writing.  Inject some humour, add lots of pictures, put in information that will be useful.  Remember the target audience of the document and tailor the detail to that level.

    Perhaps you have business and technical users?  Well think about creating two different documents: one for business requirements and the second for technical requirements and design.

    Read Full Post | Make a Comment ( None so far )

    « Previous Entries

    Liked it here?
    Why not try sites on the blogroll...