Search This Blog

Tuesday, August 3, 2010

Adding color schemes

Currently I'm adding color schemes, including the covariation color scheme. When you add a color scheme, files need to be edited in the jalview.schemes, jalview.jbgui, and jalview.gui packages. The jbgui package is named for the fact that JBuilder was used initially to automatically generate some of the code. The gui and jbgui classes have matching classes, but the classes in jbgui are preceded by a "G."

The GAlignFrame class maintains a shadow class for the user interface, and the class in the gui package, AlignFrame, has most of the logic. This class includes objects that you see in Jalview, such as buttons. The jbInit method adds the buttons into the gui and sets the properties of the buttons.

Step 1: Create a color scheme and put it in the jalview.schemes package
1a. make it a subclass of ResidueColourScheme (extends)
1b. You will probably write findColour methods that overrides the ones found in ResidueColourScheme
1c. May need to call an index of colors (eg. based on characters in the alignment); store these in

Step 2: Edit in jalview.schemes package
2a. add in a new enumeration symbol for scheme
2b. List of functions to edit:
*getColourName(ColourSchemeI cs)
*getColourName(int index)
*getColour(java.util.Vector seqs, int width, int index)

Step 3: Add a new JRadioButtonMenuItem in GAlignFrame for scheme

Step 4: Edit setColourSelected function in GAlignFrame to check the menu item when the colourscheme is selected

Step 5: Add menu item text and action settings into the jbInit function so it calls a protected GAlignFrame action method (copy the nucleotideColour button example)
5a. Add protected void myButton_actionPerformed(ActionEvent e) function (at end of GAlignFrame)
5b. Add your menu item to the colourMenu window menu (at end of jbInit)
5c. Add your menu item to the colours ButtonGroup (above public void setColourSelected(String defaultColour)
*ButtonGroup colours -> syntax is colours.add(colorscheme)

Step 6. Create a new public method with the identical name (myButton_actionPerformed(ActionEvent e)) which calls changeColour(my new
colourscheme) in AlignFrame

Step 7: For more complex colourschemes, you'll need to make sure any calculated values (e.g. covariation) are completed before the color scheme is applied in the AlignFrame._actionPerformed function

Step 8: Repeat process in the PopupMenu
*There is no GPopupMenu! (this is because PopupMenu is a dynamic menu, so the JBuilder mechanism isn't used).

If you want to add the scheme to the Jmol applet:
Step 1: In jalview.gui package
*Create public void method, scheme_actionPerformed method that creates new scheme object (right above setJalviewColourScheme method)

Step2: In
*add new JMenuItem for scheme
*setText for scheme and add actionlistner for scheme (setText and addActionListner)
*add empty public void scheme_actionPerformed method
*add scheme to colourMenu

If you want to add the scheme to the Jalview applet, it looks like you change these items:
*Add MenuItem in
*Add action listener scheme.addActionListner(this);
*add to coloursMenu
*In actionPerformed method, setJalviewcolorscheme

No comments:

Post a Comment