private static void weaveDNAStrands ( LinkedList < DNASegment > segments , int firstJulianDay , HashMap < Integer , DNAStrand > strands , int top , int bottom , int [ ] dayXs ) { // First, get rid of any colors that ended up with no segments Iterator < DNAStrand > strandIterator = strands . values ( ) . iterator ( ) ; while ( strandIterator . hasNext ( ) ) { DNAStrand strand = strandIterator . next ( ) ; if ( strand . count < 1 && strand . allDays == null ) { strandIterator . remove ( ) ; continue ; } strand . points = new float [ strand . count * 4 ] ; strand . position = 0 ; } // Go through each segment and compute its points for ( DNASegment segment : segments ) { // Add the points to the strand of that color DNAStrand strand = strands . get ( segment . color ) ; int dayIndex = segment . day - firstJulianDay ; int dayStartMinute = segment . startMinute % DAY_IN_MINUTES ; int dayEndMinute = segment . endMinute % DAY_IN_MINUTES ; int height = bottom - top ; int workDayHeight = height * 3 / 4 ; int remainderHeight = ( height - workDayHeight ) / 2 ; int x = dayXs [ dayIndex ] ; int y0 = 0 ; int y1 = 0 ; y0 = top + getPixelOffsetFromMinutes ( dayStartMinute , workDayHeight , remainderHeight ) ; y1 = top + getPixelOffsetFromMinutes ( dayEndMinute , workDayHeight , remainderHeight ) ; if ( DEBUG ) { Log . d ( TAG , "Adding " + Integer . toHexString ( segment . color ) + " at x,y0,y1: " + x + " " + y0 + " " + y1 + " for " + dayStartMinute + " " + dayEndMinute ) ; } strand . points [ strand . position ++ ] = x ; strand . points [ strand . position ++ ] = y0 ; strand . points [ strand . position ++ ] = x ; strand . points [ strand . position ++ ] = y1 ; } }
list of points to draw