pairwise-logo.gif (1266 bytes)

Using

Introduction Demonstration Programmers Credits

 

Up

Data
Using
Internal
Java Doc
Download

 

Pairwise Comparative Map is very easy to incorporate in to your own programs. If you have not read the first part of the data section please do so. Once you have a PCM file and have downloaded the PCM.jar file you can proceed.

This hyperlinked simple program is just about the simplest Java program that you can write to create an applet that uses the PCM package to draw a Pairwise Comparative Map.

Please note

You might have to use the Border Layout on your panel and add the PCM to the 'center'- otherwise there seems to be problems getting the size correct.
If you plan to change the data file of the PCM whilst the component is running (like in Demo 1 where a choice box is used), you will probably have to call the method paintAll(getGraphics()) of the class Component afterwards to actually get the PCM to repaint. See the source of Demo 1 and 2 if you are still unclear. (The method you would call to do all this is addData().)

 

Multi PCM

It is nearly as easy to make a Multi PCM as it is to create a regular PCM. You just have to create a String array of the URLs or file paths to the files that you want to include in the Multi PCM. For example, the following few lines would create a Multi PCM:

//CREATE THE ARRAY
String[] filenames = new String[3];
filenames[0] = "http://wp0560.wpbs.bbsrc.ac.uk/pairwise/demo/multi/Arab_double.pcm";
filenames[1] = "http://wp0560.wpbs.bbsrc.ac.uk/pairwise/demo/multi/madeup1.pcm";
filenames[2] = "http://wp0560.wpbs.bbsrc.ac.uk/pairwise/demo/multi/madeup2.pcm";

//CREATE THE MULTI PCM
add(new MultiPCM(filenames, true));
//set 2nd variable to true if using URLs and false if using file paths

Cross-reference to DB

To set up the function where you can cross-reference to the appropriate database by double-clicking, you have to implement the action listener interface and add an action listener to the PCM object. Then you have to catch any action events in which the action command string looks like a URL, i.e. contain the substring "http". This can be achieved by the following code:

public void actionPerformed(ActionEvent parm1)
{  if(parm1.getActionCommand().indexOf("http") >= 0)
   {  try
      {  //CREATE URL OBJECT
         URL url = new URL(parm1.getActionCommand());
         //FIRE UP WEB PAGE
         getAppletContext().showDocument(url, "Pairwise Comparative Map Datum Object");
      }
      catch(MalformedURLException e)
      {    System.out.println("URL problem");
      }
    }
}

 

Integrated Development Environment, (IDE)

Both PairwiseComparativeMap and MultiPCM have Java BeanInfo classes. This means that they can be loaded in the component palettes of Java IDEs. If you load these classes on to the palette of Borland JBuilder, it looks like the following:

IDE_pallette.gif (2064 bytes)

The first 32x32 pixel icon represents the regular PCM and the second represents Multi PCM. 16x16 pixel images are also packaged in to the PCM.jar file.

All this means that you can use PCM in a drag and drop fashion. If you create an application with a frame in JBuilder and drag out each of the components from the palette on to the frame you will see something like the following:

IDE_view.gif (3574 bytes)

The first component is PCM and the second component is Multi PCM.

PCM has a special set of property descriptors. The JBuilder Inspector (editor for variables) for PCM looks like the following:

IDE_inspector.gif (4267 bytes)

You can set the file path in the PCM_File box, the two default database colours, the starting length of the two sausages and whether when you double click on a locus, the URL is produced (crossLinkToDatabase). You could easily set it to something like:

IDE_inspector-set.gif (4684 bytes)

I found that as you enter things like the file path or URL, colours and lengths in to the JBuilder Inspector, it dynamically adjusts your view even before you run the program. Very handy!

Multi PCM doesn't have such a developed Property Descriptor yet.

Back Up Next

cropnet-logo-small.jpg (2438 bytes)

ŠJeremy Dickson, October 1998.