src/org/gel/mauve/color/MultiplicityTypeColorScheme.java

Go to the documentation of this file.
00001 package org.gel.mauve.color;
00002 
00003 import java.awt.Color;
00004 
00005 import org.gel.mauve.BaseViewerModel;
00006 import org.gel.mauve.ColorScheme;
00007 import org.gel.mauve.Genome;
00008 import org.gel.mauve.Match;
00009 
00014 public class MultiplicityTypeColorScheme implements ColorScheme {
00015 
00016         public void apply (BaseViewerModel model) {
00017                 if (model.getSequenceCount () > 62) {
00018                         throw new RuntimeException (
00019                                         " Can't color by multiplicity type with more than 62 sequences.");
00020                 }
00021 
00022                 double mult_range = Math.pow (2, model.getSequenceCount ());
00023 
00024                 for (int matchI = 0; matchI < model.getMatchCount (); matchI++) {
00025                         Match cur_match = model.getMatch (matchI);
00026 
00027                         // color the match based on its multiplicity.
00028                         long color_type = 0;
00029                         for (int seqI = 0; seqI < model.getSequenceCount (); seqI++) {
00030                                 Genome g = model.getGenomeByViewingIndex (seqI);
00031                                 color_type <<= 1;
00032                                 if (cur_match.getStart (g) != Match.NO_MATCH) {
00033                                         color_type |= 1;
00034                                 }
00035                         }
00036                         double hue = (double) color_type / mult_range;
00037                         cur_match.color = Color.getHSBColor ((float) hue, MATCH_SAT,
00038                                         MATCH_BRIGHT);
00039                 }
00040         }
00041 
00042         public String toString () {
00043                 return "Multiplicity type";
00044         }
00045 
00046 }

Generated on Mon Aug 19 06:03:40 2013 for Mauve by doxygen 1.3.6